syzbot


KASAN: use-after-free Read in nf_tables_bind_set

Status: auto-closed as invalid on 2022/02/12 20:29
Reported-by: syzbot+4bf3063945424e8d8af3@syzkaller.appspotmail.com
First crash: 323d, last: 319d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __list_add_valid+0x93/0xa0 lib/list_debug.c:26
Read of size 8 at addr ffff88804eb45740 by task syz-executor.2/24201

CPU: 1 PID: 24201 Comm: syz-executor.2 Not tainted 5.15.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/0x320 mm/kasan/report.c:247
 __kasan_report mm/kasan/report.c:433 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:450
 __list_add_valid+0x93/0xa0 lib/list_debug.c:26
 __list_add_rcu include/linux/rculist.h:79 [inline]
 list_add_tail_rcu include/linux/rculist.h:128 [inline]
 nf_tables_bind_set+0x3df/0x870 net/netfilter/nf_tables_api.c:4643
 nft_dynset_init+0xcc3/0x2210 net/netfilter/nft_dynset.c:315
 nf_tables_newexpr net/netfilter/nf_tables_api.c:2750 [inline]
 nft_expr_init+0x13e/0x2d0 net/netfilter/nf_tables_api.c:2788
 nft_set_elem_expr_alloc+0x27/0x280 net/netfilter/nf_tables_api.c:5316
 nf_tables_newset+0x20e9/0x3360 net/netfilter/nf_tables_api.c:4417
 nfnetlink_rcv_batch+0x1710/0x25f0 net/netfilter/nfnetlink.c:513
 nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:634 [inline]
 nfnetlink_rcv+0x3af/0x420 net/netfilter/nfnetlink.c:652
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x86d/0xda0 net/netlink/af_netlink.c:1916
 sock_sendmsg_nosec net/socket.c:704 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:724
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2409
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2463
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2492
 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:0x7f6292668ae9
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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f628fbde188 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f629277bf60 RCX: 00007f6292668ae9
RDX: 0000000000000000 RSI: 00000000200000c0 RDI: 0000000000000003
RBP: 00007f62926c2f6d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fff9ada1a0f R14: 00007f628fbde300 R15: 0000000000022000
 </TASK>

Allocated by task 23867:
 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:434 [inline]
 ____kasan_kmalloc mm/kasan/common.c:513 [inline]
 ____kasan_kmalloc mm/kasan/common.c:472 [inline]
 __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:522
 kmalloc include/linux/slab.h:595 [inline]
 kzalloc include/linux/slab.h:724 [inline]
 nft_expr_init+0xcf/0x2d0 net/netfilter/nf_tables_api.c:2784
 nft_set_elem_expr_alloc+0x27/0x280 net/netfilter/nf_tables_api.c:5316
 nf_tables_newset+0x20e9/0x3360 net/netfilter/nf_tables_api.c:4417
 nfnetlink_rcv_batch+0x1710/0x25f0 net/netfilter/nfnetlink.c:513
 nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:634 [inline]
 nfnetlink_rcv+0x3af/0x420 net/netfilter/nfnetlink.c:652
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x86d/0xda0 net/netlink/af_netlink.c:1916
 sock_sendmsg_nosec net/socket.c:704 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:724
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2409
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2463
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2492
 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 23867:
 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:366 [inline]
 ____kasan_slab_free mm/kasan/common.c:328 [inline]
 __kasan_slab_free+0xff/0x130 mm/kasan/common.c:374
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:1723 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1749
 slab_free mm/slub.c:3513 [inline]
 kfree+0xf6/0x560 mm/slub.c:4561
 nft_expr_destroy net/netfilter/nf_tables_api.c:2826 [inline]
 nft_set_elem_expr_alloc+0x220/0x280 net/netfilter/nf_tables_api.c:5335
 nf_tables_newset+0x20e9/0x3360 net/netfilter/nf_tables_api.c:4417
 nfnetlink_rcv_batch+0x1710/0x25f0 net/netfilter/nfnetlink.c:513
 nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:634 [inline]
 nfnetlink_rcv+0x3af/0x420 net/netfilter/nfnetlink.c:652
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x86d/0xda0 net/netlink/af_netlink.c:1916
 sock_sendmsg_nosec net/socket.c:704 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:724
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2409
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2463
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2492
 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

Last potentially related work creation:
 kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xf5/0x120 mm/kasan/generic.c:348
 kvfree_call_rcu+0x74/0x990 kernel/rcu/tree.c:3550
 cfg80211_update_known_bss+0x833/0xa60 net/wireless/scan.c:1663
 cfg80211_bss_update+0xef/0x2070 net/wireless/scan.c:1710
 cfg80211_inform_single_bss_frame_data+0x6e8/0xee0 net/wireless/scan.c:2425
 cfg80211_inform_bss_frame_data+0xa7/0xb50 net/wireless/scan.c:2458
 ieee80211_bss_info_update+0x35b/0xb30 net/mac80211/scan.c:190
 ieee80211_rx_bss_info net/mac80211/ibss.c:1119 [inline]
 ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1610 [inline]
 ieee80211_ibss_rx_queued_mgmt+0x19cf/0x3130 net/mac80211/ibss.c:1639
 ieee80211_iface_process_skb net/mac80211/iface.c:1466 [inline]
 ieee80211_iface_work+0xa65/0xd00 net/mac80211/iface.c:1520
 process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298
 worker_thread+0x658/0x11f0 kernel/workqueue.c:2445
 kthread+0x405/0x4f0 kernel/kthread.c:327
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Second to last potentially related work creation:
 kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xf5/0x120 mm/kasan/generic.c:348
 kvfree_call_rcu+0x74/0x990 kernel/rcu/tree.c:3550
 cfg80211_update_known_bss+0x833/0xa60 net/wireless/scan.c:1663
 cfg80211_bss_update+0xef/0x2070 net/wireless/scan.c:1710
 cfg80211_inform_single_bss_frame_data+0x6e8/0xee0 net/wireless/scan.c:2425
 cfg80211_inform_bss_frame_data+0xa7/0xb50 net/wireless/scan.c:2458
 ieee80211_bss_info_update+0x35b/0xb30 net/mac80211/scan.c:190
 ieee80211_rx_bss_info net/mac80211/ibss.c:1119 [inline]
 ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1610 [inline]
 ieee80211_ibss_rx_queued_mgmt+0x19cf/0x3130 net/mac80211/ibss.c:1639
 ieee80211_iface_process_skb net/mac80211/iface.c:1466 [inline]
 ieee80211_iface_work+0xa65/0xd00 net/mac80211/iface.c:1520
 process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298
 worker_thread+0x658/0x11f0 kernel/workqueue.c:2445
 kthread+0x405/0x4f0 kernel/kthread.c:327
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

The buggy address belongs to the object at ffff88804eb45700
 which belongs to the cache kmalloc-96 of size 96
The buggy address is located 64 bytes inside of
 96-byte region [ffff88804eb45700, ffff88804eb45760)
The buggy address belongs to the page:
page:ffffea00013ad140 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4eb45
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea0001bed380 dead000000000002 ffff888010c41780
raw: 0000000000000000 0000000000200020 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 0x12c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY), pid 6553, ts 1737514995072, free_ts 1737502840419
 prep_new_page mm/page_alloc.c:2418 [inline]
 get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4149
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5369
 alloc_pages+0x1a7/0x300 mm/mempolicy.c:2191
 alloc_slab_page mm/slub.c:1793 [inline]
 allocate_slab mm/slub.c:1930 [inline]
 new_slab+0x32d/0x4a0 mm/slub.c:1993
 ___slab_alloc+0x918/0xfe0 mm/slub.c:3022
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3109
 slab_alloc_node mm/slub.c:3200 [inline]
 slab_alloc mm/slub.c:3242 [inline]
 __kmalloc+0x2fb/0x340 mm/slub.c:4419
 kmalloc_array include/linux/slab.h:630 [inline]
 kcalloc include/linux/slab.h:661 [inline]
 ext4_find_extent+0xa38/0xd10 fs/ext4/extents.c:905
 ext4_ext_map_blocks+0x1e2/0x5fd0 fs/ext4/extents.c:4101
 ext4_map_blocks+0x653/0x17d0 fs/ext4/inode.c:637
 ext4_getblk+0x144/0x6b0 fs/ext4/inode.c:847
 ext4_bread+0x2a/0x1c0 fs/ext4/inode.c:900
 ext4_append+0x177/0x3a0 fs/ext4/namei.c:67
 ext4_init_new_dir+0x33f/0x5e0 fs/ext4/namei.c:2893
 ext4_mkdir+0x3cf/0xb20 fs/ext4/namei.c:2939
 vfs_mkdir+0x1c3/0x3b0 fs/namei.c:3883
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1338 [inline]
 free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1389
 free_unref_page_prepare mm/page_alloc.c:3309 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3388
 __vunmap+0x781/0xb70 mm/vmalloc.c:2632
 free_work+0x58/0x70 mm/vmalloc.c:95
 process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298
 worker_thread+0x658/0x11f0 kernel/workqueue.c:2445
 kthread+0x405/0x4f0 kernel/kthread.c:327
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
 ffff88804eb45600: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff88804eb45680: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff88804eb45700: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
                                           ^
 ffff88804eb45780: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff88804eb45800: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================

Crashes (3):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-net-kasan-gce 2021/11/14 20:28 net-next 1274a4eb318d 83f5c9b5 .config log report info KASAN: use-after-free Read in nf_tables_bind_set
ci-upstream-net-kasan-gce 2021/11/13 17:49 net-next 66f4beaa6c1d 83f5c9b5 .config log report info KASAN: use-after-free Read in nf_tables_bind_set
ci-upstream-net-kasan-gce 2021/11/11 04:41 net-next cc0356d6a02e 75b04091 .config log report info KASAN: use-after-free Read in nf_tables_bind_set
* Struck through repros no longer work on HEAD.