syzbot


KASAN: slab-out-of-bounds Read in led_tg_check

Status: upstream: reported C repro on 2024/11/21 02:46
Subsystems: netfilter
[Documentation on labels]
Reported-by: syzbot+6c8215822f35fdb35667@syzkaller.appspotmail.com
First crash: 4d04h, last: 4d03h
Cause bisection: introduced by (bisect log) :
commit 6001a930ce0378b62210d4f83583fc88a903d89d
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date: Mon Feb 15 11:28:07 2021 +0000

  netfilter: nftables: introduce table ownership

Crash: KASAN: slab-out-of-bounds Read in led_tg_check (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[PATCH] netfilter: x_tables: fix LED ID check in led_tg_check() 1 (1) 2024/11/21 06:55
[syzbot] [netfilter?] KASAN: slab-out-of-bounds Read in led_tg_check 0 (2) 2024/11/21 05:47
Last patch testing requests (1)
Created Duration User Patch Repo Result
2024/11/21 05:47 1h07m dmantipov@yandex.ru patch git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git dd7207838d38780b51e4690ee508ab2d5057e099 OK log

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in strlen+0x58/0x70 lib/string.c:402
Read of size 1 at addr ffff8881422aa1c8 by task syz-executor355/5842

CPU: 1 UID: 0 PID: 5842 Comm: syz-executor355 Not tainted 6.12.0-rc7-syzkaller-01681-g38f83a57aa8e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 strlen+0x58/0x70 lib/string.c:402
 kstrdup+0x20/0x80 mm/util.c:63
 led_tg_check+0x18b/0x3c0 net/netfilter/xt_LED.c:115
 xt_check_target+0x3b9/0xa40 net/netfilter/x_tables.c:1038
 nft_target_init+0x82d/0xc30 net/netfilter/nft_compat.c:267
 nf_tables_newexpr net/netfilter/nf_tables_api.c:3444 [inline]
 nf_tables_newrule+0x185e/0x2980 net/netfilter/nf_tables_api.c:4272
 nfnetlink_rcv_batch net/netfilter/nfnetlink.c:524 [inline]
 nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:647 [inline]
 nfnetlink_rcv+0x14e3/0x2ab0 net/netfilter/nfnetlink.c:665
 netlink_unicast_kernel net/netlink/af_netlink.c:1316 [inline]
 netlink_unicast+0x7f6/0x990 net/netlink/af_netlink.c:1342
 netlink_sendmsg+0x8e4/0xcb0 net/netlink/af_netlink.c:1886
 sock_sendmsg_nosec net/socket.c:729 [inline]
 __sock_sendmsg+0x221/0x270 net/socket.c:744
 ____sys_sendmsg+0x52a/0x7e0 net/socket.c:2609
 ___sys_sendmsg net/socket.c:2663 [inline]
 __sys_sendmsg+0x292/0x380 net/socket.c:2692
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f56d8509729
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffc32fd10f8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007ffc32fd12c8 RCX: 00007f56d8509729
RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000003
RBP: 00007f56d857c610 R08: 0000000000000011 R09: 00007ffc32fd12c8
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffc32fd12b8 R14: 0000000000000001 R15: 0000000000000001
 </TASK>

Allocated by task 5842:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
 __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:394
 kasan_kmalloc include/linux/kasan.h:257 [inline]
 __do_kmalloc_node mm/slub.c:4264 [inline]
 __kmalloc_noprof+0x1fc/0x400 mm/slub.c:4276
 kmalloc_noprof include/linux/slab.h:882 [inline]
 kzalloc_noprof include/linux/slab.h:1014 [inline]
 nf_tables_newrule+0x1609/0x2980 net/netfilter/nf_tables_api.c:4254
 nfnetlink_rcv_batch net/netfilter/nfnetlink.c:524 [inline]
 nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:647 [inline]
 nfnetlink_rcv+0x14e3/0x2ab0 net/netfilter/nfnetlink.c:665
 netlink_unicast_kernel net/netlink/af_netlink.c:1316 [inline]
 netlink_unicast+0x7f6/0x990 net/netlink/af_netlink.c:1342
 netlink_sendmsg+0x8e4/0xcb0 net/netlink/af_netlink.c:1886
 sock_sendmsg_nosec net/socket.c:729 [inline]
 __sock_sendmsg+0x221/0x270 net/socket.c:744
 ____sys_sendmsg+0x52a/0x7e0 net/socket.c:2609
 ___sys_sendmsg net/socket.c:2663 [inline]
 __sys_sendmsg+0x292/0x380 net/socket.c:2692
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff8881422aa180
 which belongs to the cache kmalloc-cg-96 of size 96
The buggy address is located 0 bytes to the right of
 allocated 72-byte region [ffff8881422aa180, ffff8881422aa1c8)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1422aa
flags: 0x57ff00000000000(node=1|zone=2|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 057ff00000000000 ffff88801ac4d640 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080200020 00000001f5000000 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 1, tgid 1 (swapper/0), ts 2682440014, free_ts 0
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1556
 prep_new_page mm/page_alloc.c:1564 [inline]
 get_page_from_freelist+0x3649/0x3790 mm/page_alloc.c:3474
 __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4750
 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265
 alloc_slab_page+0x6a/0x140 mm/slub.c:2412
 allocate_slab+0x5a/0x2f0 mm/slub.c:2578
 new_slab mm/slub.c:2631 [inline]
 ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3818
 __slab_alloc+0x58/0xa0 mm/slub.c:3908
 __slab_alloc_node mm/slub.c:3961 [inline]
 slab_alloc_node mm/slub.c:4122 [inline]
 __do_kmalloc_node mm/slub.c:4263 [inline]
 __kmalloc_noprof+0x25a/0x400 mm/slub.c:4276
 kmalloc_noprof include/linux/slab.h:882 [inline]
 kzalloc_noprof include/linux/slab.h:1014 [inline]
 __register_sysctl_table+0x65/0x1550 fs/proc/proc_sysctl.c:1368
 net_sysctl_init+0x20/0x90 net/sysctl_net.c:103
 sock_init+0x6b/0x1c0 net/socket.c:3293
 do_one_initcall+0x248/0x880 init/main.c:1269
 do_initcall_level+0x157/0x210 init/main.c:1331
 do_initcalls+0x3f/0x80 init/main.c:1347
 kernel_init_freeable+0x435/0x5d0 init/main.c:1580
page_owner free stack trace missing

Memory state around the buggy address:
 ffff8881422aa080: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc
 ffff8881422aa100: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc
>ffff8881422aa180: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc
                                              ^
 ffff8881422aa200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8881422aa280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/17 04:21 net-next 38f83a57aa8e cfe3a04a .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Read in led_tg_check
2024/11/17 03:54 net-next 38f83a57aa8e cfe3a04a .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Read in led_tg_check
2024/11/17 03:09 net-next 38f83a57aa8e cfe3a04a .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Read in led_tg_check
2024/11/17 02:35 net-next 38f83a57aa8e cfe3a04a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Read in led_tg_check
2024/11/17 02:35 net-next 38f83a57aa8e cfe3a04a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-out-of-bounds Read in led_tg_check
* Struck through repros no longer work on HEAD.