syzbot


KASAN: slab-use-after-free Read in lockref_get

Status: upstream: reported C repro on 2024/07/16 02:02
Subsystems: wireless fs
[Documentation on labels]
Reported-by: syzbot+d5dc2801166df6d34774@syzkaller.appspotmail.com
First crash: 189d, last: 1d00h
Cause bisection: introduced by (bisect log) :
commit 0a3d898ee9a8303d5b3982b97ef0703919c3ea76
Author: Benjamin Berg <benjamin.berg@intel.com>
Date: Wed Dec 20 02:38:01 2023 +0000

  wifi: mac80211: add/remove driver debugfs entries as appropriate

Crash: KASAN: slab-use-after-free Read in lockref_get (log)
Repro: C syz .config
  
Discussions (3)
Title Replies (including bot) Last reply
Managing debugfs entries and https://syzkaller.appspot.com/bug?extid=d5dc2801166df6d34774 2 (2) 2024/07/19 09:38
[syzbot] [fs?] KASAN: slab-use-after-free Read in lockref_get 8 (17) 2024/07/18 14:18
[PATCH] wifi: wireless: fix more UBSAN noise in cfg80211_conn_scan() 2 (2) 2024/07/16 18:21
Last patch testing requests (13)
Created Duration User Patch Repo Result
2024/10/22 07:32 46m retest repro net-next report log
2024/10/22 07:32 21m retest repro net-next report log
2024/10/08 06:51 21m retest repro net-next report log
2024/07/30 06:28 26m retest repro net-next report log
2024/07/30 06:28 19m retest repro net-next report log
2024/07/30 06:28 18m retest repro net-next report log
2024/07/18 10:40 1h35m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git 58f9416d413a OK log
2024/07/17 14:07 1h37m eadavis@qq.com patch git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 58f9416d413a OK log
2024/07/17 13:19 18m eadavis@qq.com patch git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 58f9416d413a report log
2024/07/17 11:39 1h09m eadavis@qq.com patch git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 58f9416d413a report log
2024/07/17 10:59 17m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git 58f9416d413a report log
2024/07/17 03:24 21m eadavis@qq.com patch git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 58f9416d413a report log
2024/07/16 11:20 1h13m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git 58f9416d413a report log

Sample crash report:
wlan1: authentication with 08:02:11:00:00:00 timed out
==================================================================
BUG: KASAN: slab-use-after-free in __lock_acquire+0x78/0x2100 kernel/locking/lockdep.c:5089
Read of size 8 at addr ffff88807bfb76d8 by task kworker/u8:7/1171

CPU: 1 UID: 0 PID: 1171 Comm: kworker/u8:7 Not tainted 6.13.0-rc1-syzkaller-00230-g15bfb14727bc #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/25/2024
Workqueue: events_unbound cfg80211_wiphy_work
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:378 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:489
 kasan_report+0x143/0x180 mm/kasan/report.c:602
 __lock_acquire+0x78/0x2100 kernel/locking/lockdep.c:5089
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
 __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
 _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
 spin_lock include/linux/spinlock.h:351 [inline]
 lockref_get+0x15/0x60 lib/lockref.c:50
 dget include/linux/dcache.h:340 [inline]
 simple_recursive_removal+0x35/0x8f0 fs/libfs.c:618
 debugfs_remove+0x49/0x70 fs/debugfs/inode.c:812
 ieee80211_sta_debugfs_remove+0x40/0x60 net/mac80211/debugfs_sta.c:1284
 __sta_info_destroy_part2+0x35e/0x450 net/mac80211/sta_info.c:1476
 __sta_info_destroy net/mac80211/sta_info.c:1492 [inline]
 sta_info_destroy_addr+0xf4/0x140 net/mac80211/sta_info.c:1504
 ieee80211_destroy_auth_data+0x139/0x270 net/mac80211/mlme.c:4230
 ieee80211_sta_work+0x1256/0x3890 net/mac80211/mlme.c:7878
 cfg80211_wiphy_work+0x2db/0x480 net/wireless/core.c:440
 process_one_work kernel/workqueue.c:3229 [inline]
 process_scheduled_works+0xa66/0x1840 kernel/workqueue.c:3310
 worker_thread+0x870/0xd30 kernel/workqueue.c:3391
 kthread+0x2f0/0x390 kernel/kthread.c:389
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>

Allocated by task 46:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 unpoison_slab_object mm/kasan/common.c:319 [inline]
 __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:345
 kasan_slab_alloc include/linux/kasan.h:250 [inline]
 slab_post_alloc_hook mm/slub.c:4104 [inline]
 slab_alloc_node mm/slub.c:4153 [inline]
 kmem_cache_alloc_lru_noprof+0x1dd/0x390 mm/slub.c:4172
 __d_alloc+0x31/0x700 fs/dcache.c:1646
 d_alloc fs/dcache.c:1726 [inline]
 d_alloc_parallel+0xdf/0x1600 fs/dcache.c:2490
 __lookup_slow+0x117/0x3f0 fs/namei.c:1776
 lookup_one_len+0x18b/0x2d0 fs/namei.c:2905
 start_creating+0x187/0x310 fs/debugfs/inode.c:378
 debugfs_create_dir+0x25/0x430 fs/debugfs/inode.c:582
 ieee80211_sta_debugfs_add+0x132/0x820 net/mac80211/debugfs_sta.c:1259
 sta_info_insert_finish net/mac80211/sta_info.c:881 [inline]
 sta_info_insert_rcu+0xecf/0x1900 net/mac80211/sta_info.c:949
 sta_info_insert+0x16/0xc0 net/mac80211/sta_info.c:954
 ieee80211_prep_connection+0xecd/0x12d0 net/mac80211/mlme.c:8396
 ieee80211_mgd_auth+0xd42/0x14c0 net/mac80211/mlme.c:8641
 rdev_auth net/wireless/rdev-ops.h:486 [inline]
 cfg80211_mlme_auth+0x59f/0x970 net/wireless/mlme.c:291
 cfg80211_conn_do_work+0x5ed/0xe60 net/wireless/sme.c:183
 cfg80211_conn_work+0x27c/0x4d0 net/wireless/sme.c:273
 process_one_work kernel/workqueue.c:3229 [inline]
 process_scheduled_works+0xa66/0x1840 kernel/workqueue.c:3310
 worker_thread+0x870/0xd30 kernel/workqueue.c:3391
 kthread+0x2f0/0x390 kernel/kthread.c:389
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Freed by task 0:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:582
 poison_slab_object mm/kasan/common.c:247 [inline]
 __kasan_slab_free+0x59/0x70 mm/kasan/common.c:264
 kasan_slab_free include/linux/kasan.h:233 [inline]
 slab_free_hook mm/slub.c:2338 [inline]
 slab_free mm/slub.c:4598 [inline]
 kmem_cache_free+0x195/0x410 mm/slub.c:4700
 rcu_do_batch kernel/rcu/tree.c:2567 [inline]
 rcu_core+0xaaa/0x17a0 kernel/rcu/tree.c:2823
 handle_softirqs+0x2d4/0x9b0 kernel/softirq.c:554
 __do_softirq kernel/softirq.c:588 [inline]
 invoke_softirq kernel/softirq.c:428 [inline]
 __irq_exit_rcu+0xf7/0x220 kernel/softirq.c:655
 irq_exit_rcu+0x9/0x30 kernel/softirq.c:671
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1049 [inline]
 sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1049
 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702

Last potentially related work creation:
 kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47
 __kasan_record_aux_stack+0xac/0xc0 mm/kasan/generic.c:544
 __call_rcu_common kernel/rcu/tree.c:3086 [inline]
 call_rcu+0x167/0xa70 kernel/rcu/tree.c:3190
 __dentry_kill+0x497/0x630 fs/dcache.c:644
 dput+0x19f/0x2b0 fs/dcache.c:867
 find_next_child fs/libfs.c:611 [inline]
 simple_recursive_removal+0x2bd/0x8f0 fs/libfs.c:626
 debugfs_remove+0x49/0x70 fs/debugfs/inode.c:812
 ieee80211_debugfs_remove_netdev net/mac80211/debugfs_netdev.c:1021 [inline]
 ieee80211_debugfs_recreate_netdev+0xc4/0x1400 net/mac80211/debugfs_netdev.c:1043
 drv_remove_interface+0x1e1/0x590 net/mac80211/driver-ops.c:120
 _ieee80211_change_mac net/mac80211/iface.c:277 [inline]
 ieee80211_change_mac+0xaf5/0x11e0 net/mac80211/iface.c:309
 dev_set_mac_address+0x327/0x510 net/core/dev.c:9207
 dev_set_mac_address_user+0x31/0x50 net/core/dev.c:9226
 dev_ifsioc+0xbd9/0xe70 net/core/dev_ioctl.c:538
 dev_ioctl+0x719/0x1340 net/core/dev_ioctl.c:783
 sock_do_ioctl+0x240/0x460 net/socket.c:1223
 sock_ioctl+0x626/0x8e0 net/socket.c:1328
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:906 [inline]
 __se_sys_ioctl+0xf5/0x170 fs/ioctl.c:892
 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 ffff88807bfb7608
 which belongs to the cache dentry of size 312
The buggy address is located 208 bytes inside of
 freed 312-byte region [ffff88807bfb7608, ffff88807bfb7740)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7bfb6
head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88801baff8c0 ffffea0001ef8100 dead000000000002
raw: 0000000000000000 0000000000150015 00000001f5000000 0000000000000000
head: 00fff00000000040 ffff88801baff8c0 ffffea0001ef8100 dead000000000002
head: 0000000000000000 0000000000150015 00000001f5000000 0000000000000000
head: 00fff00000000001 ffffea0001efed81 ffffffffffffffff 0000000000000000
head: 0000000000000002 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Reclaimable, gfp_mask 0xd20d0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_RECLAIMABLE), pid 5214, tgid 5214 (udevd), ts 35293024299, free_ts 18333902605
 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+0x365c/0x37a0 mm/page_alloc.c:3474
 __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4751
 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265
 alloc_slab_page+0x6a/0x140 mm/slub.c:2408
 allocate_slab+0x5a/0x2f0 mm/slub.c:2574
 new_slab mm/slub.c:2627 [inline]
 ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3815
 __slab_alloc+0x58/0xa0 mm/slub.c:3905
 __slab_alloc_node mm/slub.c:3980 [inline]
 slab_alloc_node mm/slub.c:4141 [inline]
 kmem_cache_alloc_lru_noprof+0x26c/0x390 mm/slub.c:4172
 __d_alloc+0x31/0x700 fs/dcache.c:1646
 d_alloc+0x4b/0x190 fs/dcache.c:1726
 lookup_one_qstr_excl+0xce/0x260 fs/namei.c:1688
 do_renameat2+0x706/0x13f0 fs/namei.c:5174
 __do_sys_rename fs/namei.c:5271 [inline]
 __se_sys_rename fs/namei.c:5269 [inline]
 __x64_sys_rename+0x82/0x90 fs/namei.c:5269
 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
page last free pid 1 tgid 1 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1127 [inline]
 free_unref_page+0xdef/0x1130 mm/page_alloc.c:2657
 free_contig_range+0x152/0x550 mm/page_alloc.c:6630
 destroy_args+0x92/0x910 mm/debug_vm_pgtable.c:1017
 debug_vm_pgtable+0x4be/0x550 mm/debug_vm_pgtable.c:1397
 do_one_initcall+0x248/0x870 init/main.c:1266
 do_initcall_level+0x157/0x210 init/main.c:1328
 do_initcalls+0x3f/0x80 init/main.c:1344
 kernel_init_freeable+0x435/0x5d0 init/main.c:1577
 kernel_init+0x1d/0x2b0 init/main.c:1466
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Memory state around the buggy address:
 ffff88807bfb7580: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc
 ffff88807bfb7600: fc fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807bfb7680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff88807bfb7700: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88807bfb7780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/12 09:55 net 15bfb14727bc ff949d25 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce KASAN: slab-use-after-free Read in lockref_get
2024/12/12 08:51 net 15bfb14727bc ff949d25 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce KASAN: slab-use-after-free Read in lockref_get
2024/07/16 06:16 net-next 58f9416d413a e8709b21 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci2-upstream-net-next-test-gce KASAN: slab-use-after-free Read in lockref_get
2024/07/16 04:14 net-next 58f9416d413a e8709b21 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci2-upstream-net-next-test-gce KASAN: slab-use-after-free Read in lockref_get
2024/07/16 02:01 net-next 58f9416d413a e8709b21 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci2-upstream-net-next-test-gce KASAN: slab-use-after-free Read in lockref_get
2024/06/07 02:07 net-next 749332814479 121701b6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-net-next-test-gce KASAN: slab-use-after-free Read in lockref_get
2024/06/07 02:07 net-next 749332814479 121701b6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-net-next-test-gce KASAN: slab-use-after-free Read in lockref_get
* Struck through repros no longer work on HEAD.