syzbot


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

Status: moderation: reported on 2025/07/09 13:59
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+1e1f9de12b2231befdaa@syzkaller.appspotmail.com
First crash: 6d01h, last: 5d20h

Sample crash report:
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 0000000000000000 R14: 00007f9b4bdb5fa0 R15: 00007ffc9b6ea518
 </TASK>
comedi comedi1: c6xdigio: I/O port conflict (0x8001,3)
==================================================================
BUG: KASAN: slab-use-after-free in sysfs_remove_file_ns+0x3d/0x70 fs/sysfs/file.c:522
Read of size 8 at addr ffff888146a88630 by task syz.2.940/11029

CPU: 1 UID: 0 PID: 11029 Comm: syz.2.940 Not tainted 6.16.0-rc4-next-20250704-syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:408 [inline]
 print_report+0xd2/0x2b0 mm/kasan/report.c:521
 kasan_report+0x118/0x150 mm/kasan/report.c:634
 sysfs_remove_file_ns+0x3d/0x70 fs/sysfs/file.c:522
 remove_bind_files drivers/base/bus.c:605 [inline]
 bus_remove_driver+0x198/0x2f0 drivers/base/bus.c:743
 comedi_device_detach+0x134/0x720 drivers/comedi/drivers.c:207
 comedi_device_attach+0x568/0x670 drivers/comedi/drivers.c:1000
 do_devconfig_ioctl drivers/comedi/comedi_fops.c:855 [inline]
 comedi_unlocked_ioctl+0x686/0xf40 drivers/comedi/comedi_fops.c:2136
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:598 [inline]
 __se_sys_ioctl+0xf9/0x170 fs/ioctl.c:584
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f9b4bb8e929
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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f9b4c9ec038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f9b4bdb5fa0 RCX: 00007f9b4bb8e929
RDX: 0000200000000100 RSI: 0000000040946400 RDI: 0000000000000003
RBP: 00007f9b4c9ec090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 0000000000000000 R14: 00007f9b4bdb5fa0 R15: 00007ffc9b6ea518
 </TASK>

Allocated by task 11011:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
 __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:394
 kasan_kmalloc include/linux/kasan.h:260 [inline]
 __kmalloc_cache_noprof+0x230/0x3d0 mm/slub.c:4396
 kmalloc_noprof include/linux/slab.h:905 [inline]
 kzalloc_noprof include/linux/slab.h:1039 [inline]
 bus_add_driver+0x162/0x640 drivers/base/bus.c:662
 driver_register+0x23a/0x320 drivers/base/driver.c:249
 c6xdigio_attach+0x94/0x890 drivers/comedi/drivers/c6xdigio.c:253
 comedi_device_attach+0x520/0x670 drivers/comedi/drivers.c:996
 do_devconfig_ioctl drivers/comedi/comedi_fops.c:855 [inline]
 comedi_unlocked_ioctl+0x686/0xf40 drivers/comedi/comedi_fops.c:2136
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:598 [inline]
 __se_sys_ioctl+0xf9/0x170 fs/ioctl.c:584
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 11013:
 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:247 [inline]
 __kasan_slab_free+0x62/0x70 mm/kasan/common.c:264
 kasan_slab_free include/linux/kasan.h:233 [inline]
 slab_free_hook mm/slub.c:2417 [inline]
 slab_free mm/slub.c:4680 [inline]
 kfree+0x18e/0x440 mm/slub.c:4879
 kobject_cleanup lib/kobject.c:689 [inline]
 kobject_release lib/kobject.c:720 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x22b/0x480 lib/kobject.c:737
 bus_remove_driver+0x245/0x2f0 drivers/base/bus.c:749
 comedi_device_detach+0x134/0x720 drivers/comedi/drivers.c:207
 do_devconfig_ioctl drivers/comedi/comedi_fops.c:833 [inline]
 comedi_unlocked_ioctl+0xc4b/0xf40 drivers/comedi/comedi_fops.c:2136
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:598 [inline]
 __se_sys_ioctl+0xf9/0x170 fs/ioctl.c:584
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888146a88600
 which belongs to the cache kmalloc-256 of size 256
The buggy address is located 48 bytes inside of
 freed 256-byte region [ffff888146a88600, ffff888146a88700)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x146a88
head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x57ff00000000040(head|node=1|zone=2|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 057ff00000000040 ffff88801a441b40 ffffea0001dbe880 dead000000000006
raw: 0000000000000000 0000000000100010 00000000f5000000 0000000000000000
head: 057ff00000000040 ffff88801a441b40 ffffea0001dbe880 dead000000000006
head: 0000000000000000 0000000000100010 00000000f5000000 0000000000000000
head: 057ff00000000001 ffffea00051aa201 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000002
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, tgid 1 (swapper/0), ts 13106412839, free_ts 0
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x240/0x2a0 mm/page_alloc.c:1848
 prep_new_page mm/page_alloc.c:1856 [inline]
 get_page_from_freelist+0x21e4/0x22c0 mm/page_alloc.c:3855
 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:5145
 alloc_pages_mpol+0x232/0x4a0 mm/mempolicy.c:2419
 alloc_slab_page mm/slub.c:2487 [inline]
 allocate_slab+0x8a/0x370 mm/slub.c:2655
 new_slab mm/slub.c:2709 [inline]
 ___slab_alloc+0xbeb/0x1410 mm/slub.c:3891
 __slab_alloc mm/slub.c:3981 [inline]
 __slab_alloc_node mm/slub.c:4056 [inline]
 slab_alloc_node mm/slub.c:4217 [inline]
 __kmalloc_cache_noprof+0x296/0x3d0 mm/slub.c:4391
 kmalloc_noprof include/linux/slab.h:905 [inline]
 kzalloc_noprof include/linux/slab.h:1039 [inline]
 bus_add_driver+0x162/0x640 drivers/base/bus.c:662
 driver_register+0x23a/0x320 drivers/base/driver.c:249
 usb_register_driver+0x1e4/0x390 drivers/usb/core/driver.c:1078
 __usb_serial_register_drivers+0x204/0xc80 drivers/usb/serial/usb-serial.c:1505
 do_one_initcall+0x233/0x820 init/main.c:1269
 do_initcall_level+0x137/0x1f0 init/main.c:1331
 do_initcalls+0x69/0xd0 init/main.c:1347
 kernel_init_freeable+0x3d9/0x570 init/main.c:1579
 kernel_init+0x1d/0x1d0 init/main.c:1469
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888146a88500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888146a88580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888146a88600: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                     ^
 ffff888146a88680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888146a88700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/07/05 18:54 linux-next 26ffb3d6f02c 4f67c4ae .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in bus_remove_driver
2025/07/05 13:53 linux-next 26ffb3d6f02c 4f67c4ae .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-rust-kasan-gce KASAN: slab-use-after-free Read in bus_remove_driver
2025/07/05 13:53 linux-next 26ffb3d6f02c 4f67c4ae .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-rust-kasan-gce KASAN: slab-use-after-free Read in bus_remove_driver
* Struck through repros no longer work on HEAD.