syzbot


KASAN: use-after-free Read in bus_remove_driver

Status: upstream: reported on 2025/07/18 14:32
Reported-by: syzbot+0f925d3e49a1341907ee@syzkaller.appspotmail.com
First crash: 64d, last: 33d
Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in bus_remove_driver fs 19 37 23m 73d 0/29 moderation: reported on 2025/07/09 13:59
linux-6.6 KASAN: slab-use-after-free Read in bus_remove_driver 19 5 31d 64d 0/2 upstream: reported on 2025/07/18 15:51

Sample crash report:
comedi comedi0: c6xdigio: I/O port conflict (0xb011,3)
==================================================================
BUG: KASAN: use-after-free in sysfs_remove_file_ns+0x39/0x70 fs/sysfs/file.c:491
Read of size 8 at addr ffff8880267ba430 by task syz.3.682/7450

CPU: 1 PID: 7450 Comm: syz.3.682 Not tainted 6.1.148-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x168/0x22e lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0xa8/0x210 mm/kasan/report.c:420
 kasan_report+0x10b/0x140 mm/kasan/report.c:524
 sysfs_remove_file_ns+0x39/0x70 fs/sysfs/file.c:491
 remove_bind_files drivers/base/bus.c:550 [inline]
 bus_remove_driver+0x89/0x230 drivers/base/bus.c:674
 comedi_device_detach+0x12d/0x6e0 drivers/comedi/drivers.c:206
 comedi_device_attach+0x55d/0x650 drivers/comedi/drivers.c:1002
 do_devconfig_ioctl drivers/comedi/comedi_fops.c:851 [inline]
 comedi_unlocked_ioctl+0x5ec/0xf20 drivers/comedi/comedi_fops.c:2151
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7ff72e78ebe9
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:00007ff72f65e038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ff72e9b5fa0 RCX: 00007ff72e78ebe9
RDX: 0000200000000400 RSI: 0000000040946400 RDI: 000000000000000d
RBP: 00007ff72e811e19 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ff72e9b6038 R14: 00007ff72e9b5fa0 R15: 00007ffd5ceeb008
 </TASK>

Allocated by task 6527:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x8e/0xa0 mm/kasan/common.c:383
 kmalloc include/linux/slab.h:563 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 bus_add_driver+0xda/0x5a0 drivers/base/bus.c:604
 driver_register+0x32d/0x430 drivers/base/driver.c:246
 c6xdigio_attach+0x90/0x880 drivers/comedi/drivers/c6xdigio.c:253
 comedi_device_attach+0x515/0x650 drivers/comedi/drivers.c:998
 do_devconfig_ioctl drivers/comedi/comedi_fops.c:851 [inline]
 comedi_unlocked_ioctl+0x5ec/0xf20 drivers/comedi/comedi_fops.c:2151
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 7278:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2d/0x50 mm/kasan/generic.c:516
 ____kasan_slab_free+0x126/0x1e0 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook+0x131/0x1a0 mm/slub.c:1750
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0xb6/0x1f0 mm/slub.c:3674
 kobject_cleanup lib/kobject.c:681 [inline]
 kobject_release lib/kobject.c:712 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x21d/0x460 lib/kobject.c:729
 bus_remove_driver+0x13c/0x230 drivers/base/bus.c:681
 comedi_device_detach+0x12d/0x6e0 drivers/comedi/drivers.c:206
 comedi_device_attach+0x55d/0x650 drivers/comedi/drivers.c:1002
 do_devconfig_ioctl drivers/comedi/comedi_fops.c:851 [inline]
 comedi_unlocked_ioctl+0x5ec/0xf20 drivers/comedi/comedi_fops.c:2151
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Last potentially related work creation:
 kasan_save_stack+0x3a/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb2/0xc0 mm/kasan/generic.c:486
 call_rcu+0x154/0x980 kernel/rcu/tree.c:2849
 __vlan_vid_del net/bridge/br_vlan.c:154 [inline]
 __vlan_del+0x3a4/0x910 net/bridge/br_vlan.c:400
 __vlan_flush+0x1be/0x3c0 net/bridge/br_vlan.c:459
 nbp_vlan_flush+0x106/0x1b0 net/bridge/br_vlan.c:1375
 del_nbp+0x650/0xb40 net/bridge/br_if.c:356
 br_del_if+0x15d/0x330 net/bridge/br_if.c:739
 do_set_master net/core/rtnetlink.c:2616 [inline]
 do_setlink+0xe3c/0x3c40 net/core/rtnetlink.c:2840
 __rtnl_newlink net/core/rtnetlink.c:3608 [inline]
 rtnl_newlink+0x17d6/0x1ff0 net/core/rtnetlink.c:3655
 rtnetlink_rcv_msg+0x79b/0xed0 net/core/rtnetlink.c:6153
 netlink_rcv_skb+0x1de/0x420 net/netlink/af_netlink.c:2511
 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
 netlink_unicast+0x74d/0x8d0 net/netlink/af_netlink.c:1344
 netlink_sendmsg+0x89e/0xbc0 net/netlink/af_netlink.c:1872
 sock_sendmsg_nosec net/socket.c:718 [inline]
 __sock_sendmsg net/socket.c:730 [inline]
 ____sys_sendmsg+0x59b/0x970 net/socket.c:2519
 ___sys_sendmsg+0x21c/0x290 net/socket.c:2573
 __sys_sendmsg net/socket.c:2602 [inline]
 __do_sys_sendmsg net/socket.c:2611 [inline]
 __se_sys_sendmsg+0x19e/0x270 net/socket.c:2609
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

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

The buggy address belongs to the physical page:
page:ffffea000099ee80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x267ba
head:ffffea000099ee80 order:1 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0000c20f80 dead000000000006 ffff888017441b40
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
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 4282, tgid 4282 (syz-executor), ts 60893212884, free_ts 60787324892
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x173/0x1a0 mm/page_alloc.c:2532
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x1a26/0x1ac0 mm/page_alloc.c:4328
 __alloc_pages+0x1df/0x4e0 mm/page_alloc.c:5614
 alloc_slab_page+0x5d/0x160 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x87/0x2c0 mm/slub.c:1992
 ___slab_alloc+0xbc6/0x1220 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x1a0/0x260 mm/slub.c:3437
 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1026
 kmalloc include/linux/slab.h:563 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 vlan_info_alloc net/8021q/vlan_core.c:153 [inline]
 vlan_vid_add+0x141/0x750 net/8021q/vlan_core.c:329
 __vlan_vid_add net/bridge/br_vlan.c:114 [inline]
 __vlan_add+0x2b2/0x26e0 net/bridge/br_vlan.c:284
 nbp_vlan_add+0x25e/0x3b0 net/bridge/br_vlan.c:1341
 nbp_vlan_init+0x354/0x440 net/bridge/br_vlan.c:1280
 br_add_if+0xaa4/0xec0 net/bridge/br_if.c:676
 do_set_master net/core/rtnetlink.c:2630 [inline]
 do_setlink+0xdc0/0x3c40 net/core/rtnetlink.c:2840
 __rtnl_newlink net/core/rtnetlink.c:3608 [inline]
 rtnl_newlink+0x17d6/0x1ff0 net/core/rtnetlink.c:3655
 rtnetlink_rcv_msg+0x79b/0xed0 net/core/rtnetlink.c:6153
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1459 [inline]
 free_pcp_prepare mm/page_alloc.c:1509 [inline]
 free_unref_page_prepare+0x8b4/0x9a0 mm/page_alloc.c:3384
 free_unref_page+0x2e/0x3f0 mm/page_alloc.c:3479
 free_slab mm/slub.c:2031 [inline]
 discard_slab mm/slub.c:2037 [inline]
 __unfreeze_partials+0x1a5/0x200 mm/slub.c:2586
 put_cpu_partial+0x17c/0x250 mm/slub.c:2662
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x76/0xe0 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x144/0x160 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x1e/0x80 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x4b/0x480 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 __kmem_cache_alloc_node+0x140/0x260 mm/slub.c:3437
 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1026
 kmalloc include/linux/slab.h:563 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 kobject_uevent_env+0x270/0x8a0 lib/kobject_uevent.c:539
 __kobject_del+0xd2/0x2f0 lib/kobject.c:593
 kobject_cleanup lib/kobject.c:672 [inline]
 kobject_release lib/kobject.c:712 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x235/0x460 lib/kobject.c:729
 net_rx_queue_update_kobjects+0x43e/0x4a0 net/core/net-sysfs.c:1126
 netif_set_real_num_rx_queues+0xfe/0x1e0 net/core/dev.c:2999
 veth_init_queues drivers/net/veth.c:1655 [inline]
 veth_newlink+0x917/0xbe0 drivers/net/veth.c:1767

Memory state around the buggy address:
 ffff8880267ba300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880267ba380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880267ba400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                     ^
 ffff8880267ba480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880267ba500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/08/17 23:28 linux-6.1.y 0bc96de781b4 1804e95e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in bus_remove_driver
2025/07/23 18:22 linux-6.1.y 3369c6df2fae e1dd4f22 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in bus_remove_driver
2025/07/18 14:32 linux-6.1.y 3369c6df2fae 88248e14 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in bus_remove_driver
2025/07/18 14:32 linux-6.1.y 3369c6df2fae 88248e14 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in bus_remove_driver
* Struck through repros no longer work on HEAD.