KASAN: slab-use-after-free Read in hdm_disconnect ( v6.14-rc4 kernel)

From: Strforexc yn
Date: Sun Mar 02 2025 - 22:29:16 EST


Dear Maintainers, When using our customized Syzkaller to fuzz the
latest Linux kernel, the following crashwas triggered.

Kernel commit: v6.14-rc4 (Commits on Feb 24, 2025)
Kernel Config : https://github.com/Strforexc/LinuxKernelbug/blob/main/.config
Kernel Log: https://github.com/Strforexc/LinuxKernelbug/blob/main/slab_uaf_read_gfs2_dis/log0
Reproduce.c: https://github.com/Strforexc/LinuxKernelbug/blob/main/slab_uaf_read_hdm_disconnect/repro.cprog

KASAN detects a use-after-free read of size 8 at address
ffff88806e3c9898 in hdm_disconnect (drivers/most/most_usb.c:1125),
triggered by a USB disconnect event processed via the usb_hub_wq
workqueue.

This bug seems to have been reported and fixed in the old kernel,
which seems to be a regression issue? If you fix this issue, please
add the following tag to the commit:
Reported-by: Zhizhuo Tang strforexctzzchange@xxxxxxxxxxx, Jianzhou
Zhao xnxc22xnxc22@xxxxxx, Haoran Liu <cherest_san@xxxxxxx>

usb 7-1: USB disconnect, device number 9
==================================================================
BUG: KASAN: slab-use-after-free in hdm_disconnect+0x227/0x250
drivers/most/most_usb.c:1125
Read of size 8 at addr ffff88806e3c9898 by task kworker/0:1/9

CPU: 0 UID: 0 PID: 9 Comm: kworker/0:1 Not tainted 6.14.0-rc4 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
Workqueue: usb_hub_wq hub_event
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x116/0x1b0 lib/dump_stack.c:120
print_address_description.constprop.0+0x2c/0x420 mm/kasan/report.c:408
print_report+0xaa/0x270 mm/kasan/report.c:521
kasan_report+0xbd/0x100 mm/kasan/report.c:634
hdm_disconnect+0x227/0x250 drivers/most/most_usb.c:1125
usb_unbind_interface+0x1e5/0x980 drivers/usb/core/driver.c:458
device_remove+0x125/0x170 drivers/base/dd.c:569
__device_release_driver drivers/base/dd.c:1273 [inline]
device_release_driver_internal+0x443/0x620 drivers/base/dd.c:1296
bus_remove_device+0x22f/0x420 drivers/base/bus.c:579
device_del+0x395/0x9e0 drivers/base/core.c:3854
usb_disable_device+0x360/0x7b0 drivers/usb/core/message.c:1418
usb_disconnect+0x2db/0x930 drivers/usb/core/hub.c:2316
hub_port_connect+0x1f7/0x2730 drivers/usb/core/hub.c:5373
hub_port_connect_change+0x27c/0x7f0 drivers/usb/core/hub.c:5673
port_event+0xe3d/0x1220 drivers/usb/core/hub.c:5833
hub_event+0x517/0xca0 drivers/usb/core/hub.c:5915
process_one_work+0x109d/0x18c0 kernel/workqueue.c:3236
process_scheduled_works kernel/workqueue.c:3317 [inline]
worker_thread+0x677/0xe90 kernel/workqueue.c:3398
kthread+0x3b3/0x760 kernel/kthread.c:464
ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
</TASK>

Allocated by task 9:
kasan_save_stack+0x24/0x50 mm/kasan/common.c:47
kasan_save_track+0x14/0x40 mm/kasan/common.c:68
poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
__kasan_kmalloc+0xba/0xc0 mm/kasan/common.c:394
kmalloc_noprof include/linux/slab.h:901 [inline]
kzalloc_noprof include/linux/slab.h:1037 [inline]
hdm_probe+0xb7/0x18b0 drivers/most/most_usb.c:959
usb_probe_interface+0x30b/0x9e0 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:579 [inline]
really_probe+0x252/0xaa0 drivers/base/dd.c:658
__driver_probe_device+0x1df/0x460 drivers/base/dd.c:800
driver_probe_device+0x49/0x120 drivers/base/dd.c:830
__device_attach_driver+0x1e3/0x2f0 drivers/base/dd.c:958
bus_for_each_drv+0x14c/0x1e0 drivers/base/bus.c:462
__device_attach+0x1f2/0x4d0 drivers/base/dd.c:1030
bus_probe_device+0x17f/0x1c0 drivers/base/bus.c:537
device_add+0xc5e/0x1490 drivers/base/core.c:3665
usb_set_configuration+0x11a5/0x1c50 drivers/usb/core/message.c:2210
usb_generic_driver_probe+0xbf/0x120 drivers/usb/core/generic.c:250
usb_probe_device+0xed/0x3e0 drivers/usb/core/driver.c:291
call_driver_probe drivers/base/dd.c:579 [inline]
really_probe+0x252/0xaa0 drivers/base/dd.c:658
__driver_probe_device+0x1df/0x460 drivers/base/dd.c:800
driver_probe_device+0x49/0x120 drivers/base/dd.c:830
__device_attach_driver+0x1e3/0x2f0 drivers/base/dd.c:958
bus_for_each_drv+0x14c/0x1e0 drivers/base/bus.c:462
__device_attach+0x1f2/0x4d0 drivers/base/dd.c:1030
bus_probe_device+0x17f/0x1c0 drivers/base/bus.c:537
device_add+0xc5e/0x1490 drivers/base/core.c:3665
usb_new_device+0x8f4/0x1430 drivers/usb/core/hub.c:2663
hub_port_connect+0x1122/0x2730 drivers/usb/core/hub.c:5533
hub_port_connect_change+0x27c/0x7f0 drivers/usb/core/hub.c:5673
port_event+0xe3d/0x1220 drivers/usb/core/hub.c:5833
hub_event+0x517/0xca0 drivers/usb/core/hub.c:5915
process_one_work+0x109d/0x18c0 kernel/workqueue.c:3236
process_scheduled_works kernel/workqueue.c:3317 [inline]
worker_thread+0x677/0xe90 kernel/workqueue.c:3398
kthread+0x3b3/0x760 kernel/kthread.c:464
ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Freed by task 9:
kasan_save_stack+0x24/0x50 mm/kasan/common.c:47
kasan_save_track+0x14/0x40 mm/kasan/common.c:68
kasan_save_free_info+0x3b/0x80 mm/kasan/generic.c:576
poison_slab_object mm/kasan/common.c:247 [inline]
__kasan_slab_free+0x54/0x80 mm/kasan/common.c:264
kasan_slab_free include/linux/kasan.h:233 [inline]
slab_free_hook mm/slub.c:2353 [inline]
slab_free mm/slub.c:4609 [inline]
kfree+0x12e/0x420 mm/slub.c:4757
device_release+0xa6/0x240 drivers/base/core.c:2567
kobject_cleanup+0x136/0x410 lib/kobject.c:689
kobject_release lib/kobject.c:720 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0xf0/0x130 lib/kobject.c:737
put_device drivers/base/core.c:3773 [inline]
device_unregister+0x30/0xc0 drivers/base/core.c:3896
hdm_disconnect+0x10b/0x250 drivers/most/most_usb.c:1123
usb_unbind_interface+0x1e5/0x980 drivers/usb/core/driver.c:458
device_remove+0x125/0x170 drivers/base/dd.c:569
__device_release_driver drivers/base/dd.c:1273 [inline]
device_release_driver_internal+0x443/0x620 drivers/base/dd.c:1296
bus_remove_device+0x22f/0x420 drivers/base/bus.c:579
device_del+0x395/0x9e0 drivers/base/core.c:3854
usb_disable_device+0x360/0x7b0 drivers/usb/core/message.c:1418
usb_disconnect+0x2db/0x930 drivers/usb/core/hub.c:2316
hub_port_connect+0x1f7/0x2730 drivers/usb/core/hub.c:5373
hub_port_connect_change+0x27c/0x7f0 drivers/usb/core/hub.c:5673
port_event+0xe3d/0x1220 drivers/usb/core/hub.c:5833
hub_event+0x517/0xca0 drivers/usb/core/hub.c:5915
process_one_work+0x109d/0x18c0 kernel/workqueue.c:3236
process_scheduled_works kernel/workqueue.c:3317 [inline]
worker_thread+0x677/0xe90 kernel/workqueue.c:3398
kthread+0x3b3/0x760 kernel/kthread.c:464
ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

The buggy address belongs to the object at ffff88806e3c8000
which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 6296 bytes inside of
freed 8192-byte region [ffff88806e3c8000, ffff88806e3ca000)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x6e3c8
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
ksm flags: 0x4fff00000000040(head|node=1|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 04fff00000000040 ffff88801b442280 ffffea0001242000 dead000000000003
raw: 0000000000000000 0000000080020002 00000000f5000000 0000000000000000
head: 04fff00000000040 ffff88801b442280 ffffea0001242000 dead000000000003
head: 0000000000000000 0000000080020002 00000000f5000000 0000000000000000
head: 04fff00000000003 ffffea0001b8f201 ffffffffffffffff 0000000000000000
head: 0000000000000008 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask
0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC),
pid 16917, tgid 16916 (syz.6.368), ts 182425166303, free_ts
182208588085
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x1a3/0x1d0 mm/page_alloc.c:1551
prep_new_page mm/page_alloc.c:1559 [inline]
get_page_from_freelist+0x8a5/0xfa0 mm/page_alloc.c:3477
__alloc_frozen_pages_noprof+0x1d8/0x3b0 mm/page_alloc.c:4739
alloc_pages_mpol+0x1f2/0x550 mm/mempolicy.c:2270
alloc_slab_page mm/slub.c:2423 [inline]
allocate_slab+0x229/0x310 mm/slub.c:2587
___slab_alloc+0x7f3/0x12b0 mm/slub.c:3826
__slab_alloc.constprop.0+0x56/0xc0 mm/slub.c:3916
__slab_alloc_node mm/slub.c:3991 [inline]
slab_alloc_node mm/slub.c:4152 [inline]
__kmalloc_cache_noprof+0x280/0x450 mm/slub.c:4320
kmalloc_noprof include/linux/slab.h:901 [inline]
kzalloc_noprof include/linux/slab.h:1037 [inline]
cryptomgr_schedule_probe+0x92/0xab0 crypto/algboss.c:87
cryptomgr_notify+0x49/0x70 crypto/algboss.c:225
notifier_call_chain+0xd7/0x250 kernel/notifier.c:85
blocking_notifier_call_chain+0x6b/0xb0 kernel/notifier.c:380
crypto_probing_notify crypto/api.c:322 [inline]
crypto_alg_mod_lookup+0x350/0x500 crypto/api.c:352
crypto_type_has_alg+0x2d/0xa0 crypto/algapi.c:1006
xfrm_probe_algs+0x16b/0x400 net/xfrm/xfrm_algo.c:825
pfkey_register+0xef/0x270 net/key/af_key.c:1701
page last free pid 5211 tgid 5211 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
free_pages_prepare mm/page_alloc.c:1127 [inline]
free_frozen_pages+0x71f/0xff0 mm/page_alloc.c:2660
__put_partials+0x13b/0x190 mm/slub.c:3153
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x50/0x130 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x1a5/0x1f0 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x6f/0xa0 mm/kasan/common.c:329
kasan_slab_alloc include/linux/kasan.h:250 [inline]
slab_post_alloc_hook mm/slub.c:4115 [inline]
slab_alloc_node mm/slub.c:4164 [inline]
kmem_cache_alloc_noprof+0x167/0x400 mm/slub.c:4171
getname_flags+0xd2/0x620 fs/namei.c:139
do_sys_openat2+0xf2/0x1d0 fs/open.c:1422
do_sys_open fs/open.c:1443 [inline]
__do_sys_openat fs/open.c:1459 [inline]
__se_sys_openat fs/open.c:1454 [inline]
__x64_sys_openat+0x140/0x200 fs/open.c:1454
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcb/0x260 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
ffff88806e3c9780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88806e3c9800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88806e3c9880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88806e3c9900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88806e3c9980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Regards,
Zhizhuo Tang