syzbot


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

Status: upstream: reported on 2025/06/03 11:10
Subsystems: kernfs
[Documentation on labels]
Reported-by: syzbot+ce1e5a1b4e086b43e56d@syzkaller.appspotmail.com
First crash: 112d, last: 2d01h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [kernfs?] KASAN: slab-use-after-free Read in kernfs_root 0 (1) 2025/06/03 11:10

Sample crash report:
usb 10-1: Direct firmware load for ueagle-atm/eagleII.fw failed with error -2
usb 10-1: Falling back to sysfs fallback for: ueagle-atm/eagleII.fw
==================================================================
BUG: KASAN: slab-use-after-free in kernfs_root+0xda/0x230 fs/kernfs/kernfs-internal.h:76
Read of size 8 at addr ffff8880646983f0 by task kworker/1:2/920

CPU: 1 UID: 0 PID: 920 Comm: kworker/1:2 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/18/2025
Workqueue: events request_firmware_work_func
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xca/0x240 mm/kasan/report.c:482
 kasan_report+0x118/0x150 mm/kasan/report.c:595
 kernfs_root+0xda/0x230 fs/kernfs/kernfs-internal.h:76
 kernfs_add_one+0x27c/0x520 fs/kernfs/dir.c:833
 __kernfs_create_file+0x22b/0x2e0 fs/kernfs/file.c:1086
 sysfs_add_bin_file_mode_ns+0x2e6/0x360 fs/sysfs/file.c:360
 create_files fs/sysfs/group.c:109 [inline]
 internal_create_group+0xa0f/0x1110 fs/sysfs/group.c:183
 internal_create_groups fs/sysfs/group.c:223 [inline]
 sysfs_create_groups+0x59/0x120 fs/sysfs/group.c:249
 device_add_groups drivers/base/core.c:2836 [inline]
 device_add_attrs+0x1c4/0x5a0 drivers/base/core.c:2911
 device_add+0x496/0xb50 drivers/base/core.c:3643
 fw_load_sysfs_fallback drivers/base/firmware_loader/fallback.c:86 [inline]
 fw_load_from_user_helper drivers/base/firmware_loader/fallback.c:162 [inline]
 firmware_fallback_sysfs+0x2e4/0x9b0 drivers/base/firmware_loader/fallback.c:238
 _request_firmware+0xf83/0x15b0 drivers/base/firmware_loader/main.c:906
 request_firmware_work_func+0xaf/0x1c0 drivers/base/firmware_loader/main.c:1159
 process_one_work kernel/workqueue.c:3236 [inline]
 process_scheduled_works+0xae1/0x17b0 kernel/workqueue.c:3319
 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3400
 kthread+0x70e/0x8a0 kernel/kthread.c:463
 ret_from_fork+0x436/0x7d0 arch/x86/kernel/process.c:148
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>

Allocated by task 920:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:68
 unpoison_slab_object mm/kasan/common.c:330 [inline]
 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:356
 kasan_slab_alloc include/linux/kasan.h:250 [inline]
 slab_post_alloc_hook mm/slub.c:4191 [inline]
 slab_alloc_node mm/slub.c:4240 [inline]
 kmem_cache_alloc_noprof+0x1c1/0x3c0 mm/slub.c:4247
 __kernfs_new_node+0xd7/0x7e0 fs/kernfs/dir.c:637
 kernfs_new_node+0x102/0x210 fs/kernfs/dir.c:713
 __kernfs_create_file+0x4b/0x2e0 fs/kernfs/file.c:1057
 sysfs_add_bin_file_mode_ns+0x2e6/0x360 fs/sysfs/file.c:360
 create_files fs/sysfs/group.c:109 [inline]
 internal_create_group+0xa0f/0x1110 fs/sysfs/group.c:183
 internal_create_groups fs/sysfs/group.c:223 [inline]
 sysfs_create_groups+0x59/0x120 fs/sysfs/group.c:249
 device_add_groups drivers/base/core.c:2836 [inline]
 device_add_attrs+0x1c4/0x5a0 drivers/base/core.c:2911
 device_add+0x496/0xb50 drivers/base/core.c:3643
 fw_load_sysfs_fallback drivers/base/firmware_loader/fallback.c:86 [inline]
 fw_load_from_user_helper drivers/base/firmware_loader/fallback.c:162 [inline]
 firmware_fallback_sysfs+0x2e4/0x9b0 drivers/base/firmware_loader/fallback.c:238
 _request_firmware+0xf83/0x15b0 drivers/base/firmware_loader/main.c:906
 request_firmware_work_func+0xaf/0x1c0 drivers/base/firmware_loader/main.c:1159
 process_one_work kernel/workqueue.c:3236 [inline]
 process_scheduled_works+0xae1/0x17b0 kernel/workqueue.c:3319
 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3400
 kthread+0x70e/0x8a0 kernel/kthread.c:463
 ret_from_fork+0x436/0x7d0 arch/x86/kernel/process.c:148
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

Freed by task 23:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:576
 poison_slab_object mm/kasan/common.c:243 [inline]
 __kasan_slab_free+0x5b/0x80 mm/kasan/common.c:275
 kasan_slab_free include/linux/kasan.h:233 [inline]
 slab_free_hook mm/slub.c:2422 [inline]
 slab_free mm/slub.c:4695 [inline]
 kmem_cache_free+0x18f/0x400 mm/slub.c:4797
 rcu_do_batch kernel/rcu/tree.c:2605 [inline]
 rcu_core+0xcab/0x1770 kernel/rcu/tree.c:2861
 handle_softirqs+0x283/0x870 kernel/softirq.c:579
 run_ksoftirqd+0x9b/0x100 kernel/softirq.c:968
 smpboot_thread_fn+0x53f/0xa60 kernel/smpboot.c:160
 kthread+0x70e/0x8a0 kernel/kthread.c:463
 ret_from_fork+0x436/0x7d0 arch/x86/kernel/process.c:148
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

Last potentially related work creation:
 kasan_save_stack+0x3e/0x60 mm/kasan/common.c:47
 kasan_record_aux_stack+0xbd/0xd0 mm/kasan/generic.c:548
 __call_rcu_common kernel/rcu/tree.c:3123 [inline]
 call_rcu+0x157/0x9c0 kernel/rcu/tree.c:3243
 kernfs_put+0x19e/0x480 fs/kernfs/dir.c:591
 __kernfs_remove+0x3f6/0x570 fs/kernfs/dir.c:1530
 kernfs_remove+0x38/0x60 fs/kernfs/dir.c:1550
 __kobject_del+0xe1/0x300 lib/kobject.c:604
 kobject_del+0x45/0x60 lib/kobject.c:627
 device_del+0x75f/0x8e0 drivers/base/core.c:3898
 usb_disconnect+0x614/0x950 drivers/usb/core/hub.c:2375
 hub_port_connect drivers/usb/core/hub.c:5406 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5706 [inline]
 port_event drivers/usb/core/hub.c:5870 [inline]
 hub_event+0x1cf5/0x4a20 drivers/usb/core/hub.c:5952
 process_one_work kernel/workqueue.c:3236 [inline]
 process_scheduled_works+0xae1/0x17b0 kernel/workqueue.c:3319
 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3400
 kthread+0x70e/0x8a0 kernel/kthread.c:463
 ret_from_fork+0x436/0x7d0 arch/x86/kernel/process.c:148
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

The buggy address belongs to the object at ffff8880646983c0
 which belongs to the cache kernfs_node_cache of size 176
The buggy address is located 48 bytes inside of
 freed 176-byte region [ffff8880646983c0, ffff888064698470)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x64698
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000000 ffff88801bad6dc0 ffffea0001904540 dead000000000008
raw: 0000000000000000 0000000080110011 00000000f5000000 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 13821, tgid 13821 (syz-executor), ts 581667623538, free_ts 579998574341
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x240/0x2a0 mm/page_alloc.c:1851
 prep_new_page mm/page_alloc.c:1859 [inline]
 get_page_from_freelist+0x21e4/0x22c0 mm/page_alloc.c:3858
 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:5148
 alloc_pages_mpol+0x232/0x4a0 mm/mempolicy.c:2416
 alloc_slab_page mm/slub.c:2492 [inline]
 allocate_slab+0x8a/0x370 mm/slub.c:2660
 new_slab mm/slub.c:2714 [inline]
 ___slab_alloc+0xbeb/0x1420 mm/slub.c:3901
 __slab_alloc mm/slub.c:3992 [inline]
 __slab_alloc_node mm/slub.c:4067 [inline]
 slab_alloc_node mm/slub.c:4228 [inline]
 kmem_cache_alloc_noprof+0x283/0x3c0 mm/slub.c:4247
 __kernfs_new_node+0xd7/0x7e0 fs/kernfs/dir.c:637
 kernfs_new_node+0x102/0x210 fs/kernfs/dir.c:713
 __kernfs_create_file+0x4b/0x2e0 fs/kernfs/file.c:1057
 sysfs_add_file_mode_ns+0x238/0x300 fs/sysfs/file.c:319
 create_files fs/sysfs/group.c:76 [inline]
 internal_create_group+0x66d/0x1110 fs/sysfs/group.c:183
 internal_create_groups fs/sysfs/group.c:223 [inline]
 sysfs_create_groups+0x59/0x120 fs/sysfs/group.c:249
 netdev_queue_add_kobject net/core/net-sysfs.c:2001 [inline]
 netdev_queue_update_kobjects+0x2a6/0x6c0 net/core/net-sysfs.c:2054
 register_queue_kobjects net/core/net-sysfs.c:2117 [inline]
 netdev_register_kobject+0x258/0x310 net/core/net-sysfs.c:2360
 register_netdevice+0x126c/0x1ae0 net/core/dev.c:11206
page last free pid 13937 tgid 13933 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1395 [inline]
 __free_frozen_pages+0xbc4/0xd30 mm/page_alloc.c:2895
 vfree+0x25a/0x400 mm/vmalloc.c:3434
 do_free_pages sound/core/pcm_memory.c:88 [inline]
 snd_pcm_lib_free_pages+0x250/0x2e0 sound/core/pcm_memory.c:495
 do_hw_free sound/core/pcm_native.c:906 [inline]
 snd_pcm_release_substream+0x2b7/0x480 sound/core/pcm_native.c:2730
 snd_pcm_oss_release_file sound/core/oss/pcm_oss.c:2397 [inline]
 snd_pcm_oss_release+0x181/0x250 sound/core/oss/pcm_oss.c:2576
 __fput+0x44c/0xa70 fs/file_table.c:468
 task_work_run+0x1d1/0x260 kernel/task_work.c:227
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 exit_to_user_mode_loop+0xec/0x110 kernel/entry/common.c:43
 exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline]
 syscall_exit_to_user_mode_work include/linux/entry-common.h:175 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:210 [inline]
 do_syscall_64+0x2bd/0x3b0 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff888064698280: fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb fb
 ffff888064698300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888064698380: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
                                                             ^
 ffff888064698400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
 ffff888064698480: fc fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (11):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/09/16 20:29 upstream 46a51f4f5eda e2beed91 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in kernfs_root
2025/05/29 12:42 upstream 90b83efa6701 3d2f584d .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in kernfs_root
2025/08/04 05:29 upstream 3c4a063b1f8a 7368264b .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root general protection fault in kernfs_root
2025/07/20 12:45 upstream f4a40a4282f4 7117feec .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root general protection fault in kernfs_root
2025/08/14 07:19 upstream 91325f31afc1 22ec1469 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: global-out-of-bounds Read in kernfs_root
2025/07/27 22:07 upstream b711733e89a3 fb8f743d .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream general protection fault in kernfs_root
2025/09/11 07:53 upstream 7aac71907bde fdeaa69b .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 general protection fault in kernfs_root
2025/08/21 21:27 upstream 32b7144f806e 3e79b825 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 general protection fault in kernfs_root
2025/08/21 03:51 upstream 41cd3fd15263 0b9605c8 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 general protection fault in kernfs_root
2025/08/20 11:46 upstream b19a97d57c15 bd178e57 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: slab-out-of-bounds Read in kernfs_root
2025/07/18 07:55 linux-next 024e09e444bd 0d1223f1 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: global-out-of-bounds Read in kernfs_root
* Struck through repros no longer work on HEAD.