syzbot


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

Status: upstream: reported on 2024/09/27 15:10
Subsystems: kernfs
[Documentation on labels]
Reported-by: syzbot+81380e5b57bacce8a9f6@syzkaller.appspotmail.com
First crash: 87d, last: 1d17h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [kernfs?] KASAN: slab-use-after-free Read in kernfs_add_one 0 (1) 2024/09/27 15:10
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in kernfs_add_one kernfs C error inconclusive 39 238d 1169d 0/28 auto-obsoleted due to no activity on 2024/08/14 07:44
linux-6.1 KASAN: use-after-free Read in kernfs_add_one (2) 1 228d 228d 0/3 auto-obsoleted due to no activity on 2024/07/29 04:04
linux-6.1 KASAN: use-after-free Read in kernfs_add_one (3) 1 121d 121d 0/3 auto-obsoleted due to no activity on 2024/11/13 12:08
linux-6.1 KASAN: use-after-free Read in kernfs_add_one 1 535d 535d 0/3 auto-obsoleted due to no activity on 2023/09/26 01:13
linux-5.15 KASAN: use-after-free Read in kernfs_add_one 1 431d 431d 0/3 auto-obsoleted due to no activity on 2024/01/09 18:18

Sample crash report:
usb 4-1: Falling back to sysfs fallback for: ueagle-atm/eagleII.fw
==================================================================
BUG: KASAN: slab-use-after-free in kernfs_root fs/kernfs/kernfs-internal.h:70 [inline]
BUG: KASAN: slab-use-after-free in kernfs_next_descendant_post fs/kernfs/dir.c:1351 [inline]
BUG: KASAN: slab-use-after-free in kernfs_activate fs/kernfs/dir.c:1406 [inline]
BUG: KASAN: slab-use-after-free in kernfs_add_one+0x4f0/0x8b0 fs/kernfs/dir.c:819
Read of size 8 at addr ffff88802b9765d0 by task kworker/0:3/5882

CPU: 0 UID: 0 PID: 5882 Comm: kworker/0:3 Not tainted 6.13.0-rc1-syzkaller-00002-gcdd30ebb1b9f #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: events request_firmware_work_func
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
 kernfs_root fs/kernfs/kernfs-internal.h:70 [inline]
 kernfs_next_descendant_post fs/kernfs/dir.c:1351 [inline]
 kernfs_activate fs/kernfs/dir.c:1406 [inline]
 kernfs_add_one+0x4f0/0x8b0 fs/kernfs/dir.c:819
 __kernfs_create_file+0x22e/0x2e0 fs/kernfs/file.c:1063
 sysfs_add_file_mode_ns+0x24a/0x310 fs/sysfs/file.c:313
 sysfs_merge_group+0x1fd/0x450 fs/sysfs/group.c:376
 dpm_sysfs_add+0xd3/0x280 drivers/base/power/sysfs.c:708
 device_add+0x5bc/0xbf0 drivers/base/core.c:3625
 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+0x307/0x9e0 drivers/base/firmware_loader/fallback.c:238
 _request_firmware+0xdf7/0x13b0 drivers/base/firmware_loader/main.c:941
 request_firmware_work_func+0x12a/0x280 drivers/base/firmware_loader/main.c:1194
 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 5882:
 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_noprof+0x1d9/0x380 mm/slub.c:4160
 __kernfs_new_node+0xd8/0x870 fs/kernfs/dir.c:624
 kernfs_new_node+0x137/0x240 fs/kernfs/dir.c:700
 __kernfs_create_file+0x49/0x2e0 fs/kernfs/file.c:1034
 sysfs_add_file_mode_ns+0x24a/0x310 fs/sysfs/file.c:313
 sysfs_merge_group+0x1fd/0x450 fs/sysfs/group.c:376
 dpm_sysfs_add+0xd3/0x280 drivers/base/power/sysfs.c:708
 device_add+0x5bc/0xbf0 drivers/base/core.c:3625
 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+0x307/0x9e0 drivers/base/firmware_loader/fallback.c:238
 _request_firmware+0xdf7/0x13b0 drivers/base/firmware_loader/main.c:941
 request_firmware_work_func+0x12a/0x280 drivers/base/firmware_loader/main.c:1194
 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 16:
 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
 run_ksoftirqd+0xca/0x130 kernel/softirq.c:943
 smpboot_thread_fn+0x544/0xa30 kernel/smpboot.c:164
 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

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
 kernfs_put+0x1dc/0x370 fs/kernfs/dir.c:578
 __kernfs_remove+0x768/0x870 fs/kernfs/dir.c:1508
 kernfs_remove+0x7a/0xa0 fs/kernfs/dir.c:1528
 __kobject_del+0xe2/0x310 lib/kobject.c:604
 kobject_del+0x45/0x60 lib/kobject.c:627
 device_del+0x7ff/0x9b0 drivers/base/core.c:3874
 usb_disconnect+0x60b/0x950 drivers/usb/core/hub.c:2332
 hub_port_connect drivers/usb/core/hub.c:5361 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5661 [inline]
 port_event drivers/usb/core/hub.c:5821 [inline]
 hub_event+0x1ebc/0x5150 drivers/usb/core/hub.c:5903
 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

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

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2b976
anon flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000000 ffff888140aaf000 ffffea0001eb2140 dead000000000005
raw: 0000000000000000 0000000080110011 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 5845, tgid 5845 (syz-executor), ts 75780826056, free_ts 75689748240
 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_noprof+0x268/0x380 mm/slub.c:4160
 __kernfs_new_node+0xd8/0x870 fs/kernfs/dir.c:624
 kernfs_new_node+0x137/0x240 fs/kernfs/dir.c:700
 __kernfs_create_file+0x49/0x2e0 fs/kernfs/file.c:1034
 sysfs_add_file_mode_ns+0x24a/0x310 fs/sysfs/file.c:313
 create_files fs/sysfs/group.c:76 [inline]
 internal_create_group+0x782/0x12d0 fs/sysfs/group.c:183
 internal_create_groups fs/sysfs/group.c:223 [inline]
 sysfs_create_groups+0x56/0x120 fs/sysfs/group.c:249
 device_add_groups drivers/base/core.c:2812 [inline]
 device_add_attrs+0x199/0x600 drivers/base/core.c:2887
page last free pid 5848 tgid 5848 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
 __slab_free+0x31b/0x3d0 mm/slub.c:4509
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x9a/0x140 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:329
 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_noprof+0x1d9/0x380 mm/slub.c:4160
 alloc_empty_file+0x9e/0x1d0 fs/file_table.c:228
 alloc_file fs/file_table.c:345 [inline]
 alloc_file_pseudo+0x1da/0x290 fs/file_table.c:376
 sock_alloc_file+0xb8/0x280 net/socket.c:468
 sock_map_fd net/socket.c:493 [inline]
 __sys_socket+0x1dd/0x3c0 net/socket.c:1709
 __do_sys_socket net/socket.c:1714 [inline]
 __se_sys_socket net/socket.c:1712 [inline]
 __x64_sys_socket+0x7a/0x90 net/socket.c:1712
 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

Memory state around the buggy address:
 ffff88802b976480: fc fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb
 ffff88802b976500: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff88802b976580: fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff88802b976600: fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc
 ffff88802b976680: fc fc fa fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/03 02:13 upstream cdd30ebb1b9f bb326ffb .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in kernfs_add_one
2024/11/15 18:41 upstream cfaaa7d010d1 f6ede3a3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in kernfs_add_one
2024/11/15 08:50 upstream cfaaa7d010d1 f6ede3a3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in kernfs_add_one
2024/10/31 21:56 upstream 0fc810ae3ae1 96eb609f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in kernfs_add_one
2024/09/08 10:37 upstream d1f2d51b711a 9750182a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: slab-use-after-free Read in kernfs_add_one
* Struck through repros no longer work on HEAD.