syzbot


KASAN: use-after-free Read in append_radio_msg
Status: auto-closed as invalid on 2022/04/26 10:38
Reported-by: syzbot+7e638ddf0851bdc98422@syzkaller.appspotmail.com
First crash: 122d, last: 122d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in strlen+0x79/0x90 lib/string.c:487
Read of size 1 at addr ffff888076b3b5c8 by task syz-executor.1/18913

CPU: 1 PID: 18913 Comm: syz-executor.1 Not tainted 5.16.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0x8d/0x336 mm/kasan/report.c:255
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
 strlen+0x79/0x90 lib/string.c:487
 strlen include/linux/fortify-string.h:102 [inline]
 append_radio_msg+0x282/0x440 drivers/net/wireless/mac80211_hwsim.c:2768
 hwsim_mcast_new_radio drivers/net/wireless/mac80211_hwsim.c:2791 [inline]
 mac80211_hwsim_new_radio+0x35d1/0x4b20 drivers/net/wireless/mac80211_hwsim.c:3525
 hwsim_new_radio_nl+0x9bc/0x1080 drivers/net/wireless/mac80211_hwsim.c:4053
 genl_family_rcv_msg_doit+0x228/0x320 net/netlink/genetlink.c:731
 genl_family_rcv_msg net/netlink/genetlink.c:775 [inline]
 genl_rcv_msg+0x328/0x580 net/netlink/genetlink.c:792
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:803
 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
 netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343
 netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919
 sock_sendmsg_nosec net/socket.c:705 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:725
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2413
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2467
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2496
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f67a37aa059
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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:00007f67a211f168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f67a38bcf60 RCX: 00007f67a37aa059
RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000004
RBP: 00007f67a380408d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffdf337b66f R14: 00007f67a211f300 R15: 0000000000022000
 </TASK>

Allocated by task 5300:
 kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:437 [inline]
 ____kasan_kmalloc mm/kasan/common.c:516 [inline]
 ____kasan_kmalloc mm/kasan/common.c:475 [inline]
 __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:525
 kmalloc_node include/linux/slab.h:604 [inline]
 __vmalloc_area_node mm/vmalloc.c:2948 [inline]
 __vmalloc_node_range+0x444/0x1060 mm/vmalloc.c:3107
 __vmalloc_node mm/vmalloc.c:3157 [inline]
 vzalloc+0x67/0x80 mm/vmalloc.c:3227
 do_ipt_get_ctl+0x60d/0x9d0 net/ipv4/netfilter/ip_tables.c:801
 nf_getsockopt+0x72/0xd0 net/netfilter/nf_sockopt.c:116
 ip_getsockopt net/ipv4/ip_sockglue.c:1786 [inline]
 ip_getsockopt+0x164/0x1c0 net/ipv4/ip_sockglue.c:1765
 tcp_getsockopt+0x86/0xd0 net/ipv4/tcp.c:4285
 __sys_getsockopt+0x21f/0x5f0 net/socket.c:2224
 __do_sys_getsockopt net/socket.c:2239 [inline]
 __se_sys_getsockopt net/socket.c:2236 [inline]
 __x64_sys_getsockopt+0xba/0x150 net/socket.c:2236
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 18915:
 kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
 kasan_set_track+0x21/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:367 [inline]
 ____kasan_slab_free+0x130/0x160 mm/kasan/common.c:329
 kasan_slab_free include/linux/kasan.h:236 [inline]
 slab_free_hook mm/slub.c:1728 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1754
 slab_free mm/slub.c:3509 [inline]
 kfree+0xcb/0x280 mm/slub.c:4562
 kfree_const+0x51/0x60 mm/util.c:40
 kobject_rename+0x165/0x250 lib/kobject.c:540
 device_rename+0x151/0x230 drivers/base/core.c:4240
 cfg80211_dev_rename+0xc9/0x230 net/wireless/core.c:141
 nl80211_set_wiphy+0x226/0x2c20 net/wireless/nl80211.c:3301
 genl_family_rcv_msg_doit+0x228/0x320 net/netlink/genetlink.c:731
 genl_family_rcv_msg net/netlink/genetlink.c:775 [inline]
 genl_rcv_msg+0x328/0x580 net/netlink/genetlink.c:792
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:803
 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
 netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343
 netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919
 sock_sendmsg_nosec net/socket.c:705 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:725
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2413
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2467
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2496
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff888076b3b5c8
 which belongs to the cache kmalloc-8 of size 8
The buggy address is located 0 bytes inside of
 8-byte region [ffff888076b3b5c8, ffff888076b3b5d0)
The buggy address belongs to the page:
page:ffffea0001dacec0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x76b3b
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000001 ffff888010c41280
raw: 0000000000000000 0000000080660066 00000001ffffffff 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 3628, ts 263499476589, free_ts 263499313731
 prep_new_page mm/page_alloc.c:2434 [inline]
 get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4165
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5389
 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2271
 alloc_slab_page mm/slub.c:1799 [inline]
 allocate_slab mm/slub.c:1944 [inline]
 new_slab+0x28a/0x3b0 mm/slub.c:2004
 ___slab_alloc+0x87c/0xe90 mm/slub.c:3018
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3105
 slab_alloc_node mm/slub.c:3196 [inline]
 __kmalloc_node+0x2cb/0x390 mm/slub.c:4468
 kmalloc_node include/linux/slab.h:604 [inline]
 __vmalloc_area_node mm/vmalloc.c:2948 [inline]
 __vmalloc_node_range+0x444/0x1060 mm/vmalloc.c:3107
 __vmalloc_node mm/vmalloc.c:3157 [inline]
 vzalloc+0x67/0x80 mm/vmalloc.c:3227
 xt_counters_alloc+0x4c/0x70 net/netfilter/x_tables.c:1379
 __do_replace+0x9a/0x870 net/ipv4/netfilter/ip_tables.c:1049
 do_replace net/ipv4/netfilter/ip_tables.c:1140 [inline]
 do_ipt_set_ctl+0x901/0xb80 net/ipv4/netfilter/ip_tables.c:1630
 nf_setsockopt+0x83/0xe0 net/netfilter/nf_sockopt.c:101
 ip_setsockopt+0x3c3/0x3a90 net/ipv4/ip_sockglue.c:1444
 tcp_setsockopt+0x136/0x2520 net/ipv4/tcp.c:3686
 __sys_setsockopt+0x2db/0x610 net/socket.c:2180
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1352 [inline]
 free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1404
 free_unref_page_prepare mm/page_alloc.c:3325 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3404
 __vunmap+0x798/0xc50 mm/vmalloc.c:2635
 __vfree+0x3c/0xd0 mm/vmalloc.c:2683
 vfree+0x5a/0x90 mm/vmalloc.c:2714
 copy_entries_to_user net/ipv4/netfilter/ip_tables.c:868 [inline]
 get_entries net/ipv4/netfilter/ip_tables.c:1024 [inline]
 do_ipt_get_ctl+0x7fe/0x9d0 net/ipv4/netfilter/ip_tables.c:1663
 nf_getsockopt+0x72/0xd0 net/netfilter/nf_sockopt.c:116
 ip_getsockopt net/ipv4/ip_sockglue.c:1786 [inline]
 ip_getsockopt+0x164/0x1c0 net/ipv4/ip_sockglue.c:1765
 tcp_getsockopt+0x86/0xd0 net/ipv4/tcp.c:4285
 __sys_getsockopt+0x21f/0x5f0 net/socket.c:2224
 __do_sys_getsockopt net/socket.c:2239 [inline]
 __se_sys_getsockopt net/socket.c:2236 [inline]
 __x64_sys_getsockopt+0xba/0x150 net/socket.c:2236
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Memory state around the buggy address:
 ffff888076b3b480: fc 00 fc fc fc fc 00 fc fc fc fc fa fc fc fc fc
 ffff888076b3b500: fa fc fc fc fc fa fc fc fc fc 00 fc fc fc fc 00
>ffff888076b3b580: fc fc fc fc fb fc fc fc fc fa fc fc fc fc 00 fc
                                              ^
 ffff888076b3b600: fc fc fc 00 fc fc fc fc 00 fc fc fc fc fb fc fc
 ffff888076b3b680: fc fc fa fc fc fc fc fa fc fc fc fc 00 fc fc fc
==================================================================

Crashes (1):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-bpf-kasan-gce 2022/01/26 10:37 bpf e2bcbd7769ee 2cbffd88 .config log report info KASAN: use-after-free Read in append_radio_msg