[BUG] KASAN: slab-use-after-free in dma_set_mask (async probe vs module unload) [sdhci_pci] [syzkaller]
From: Yang Zi
Date: Wed Aug 12 2026 - 12:37:40 EST
Hi,
While fuzzing kernel v7.1 with syzkaller we hit a slab-use-after-free in
dma_set_mask() during a racing module unload of sdhci_pci.
Reproducer summary (see attached report):
BUG: KASAN: slab-use-after-free in dma_set_mask kernel/dma/mapping.c:925
Write of size 8 at addr ... by task kworker/u4:1/27
dma_set_mask -> sdhci_set_dma_mask -> sdhci_setup_host -> async_run_entry_fn
Root cause: the async probe work queued by mmc_add_host (running
sdhci_setup_host) is not synchronized with module removal; dma_set_mask()
performs `*dev->dma_mask = mask` on an msics_host that was already released by
device_release().
The crash report attached below:
==================================================================
BUG: KASAN: slab-use-after-free in dma_set_mask+0xa1/0xd0 kernel/dma/mapping.c:925
Write of size 8 at addr ffff888059a6ca28 by task kworker/u4:1/27
CPU: 0 UID: 0 PID: 27 Comm: kworker/u4:1 Tainted: G W O 7.1.0 #1 PREEMPT(lazy)
Tainted: [W]=WARN, [O]=OOT_MODULE
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
Workqueue: async async_run_entry_fn
Call Trace:
<TASK>
dump_stack_lvl+0xa2/0xd0 lib/dump_stack.c:120
print_address_description+0x77/0x200 mm/kasan/report.c:378
print_report+0x58/0x70 mm/kasan/report.c:482
kasan_report+0x117/0x150 mm/kasan/report.c:595
dma_set_mask+0xa1/0xd0 kernel/dma/mapping.c:925
dma_set_mask_and_coherent include/linux/dma-mapping.h:643 [inline] [sdhci]
sdhci_set_dma_mask drivers/mmc/host/sdhci.c:4129 [inline] [sdhci]
sdhci_setup_host+0x2efb/0x14360 drivers/mmc/host/sdhci.c:4364 [sdhci]
</TASK>
Allocated by task 60:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0x72/0x90 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__do_kmalloc_node mm/slub.c:5296 [inline]
__kmalloc_noprof+0x20b/0x680 mm/slub.c:5308
kmalloc_noprof include/linux/slab.h:954 [inline] [mmc_core]
kzalloc_noprof include/linux/slab.h:1188 [inline] [mmc_core]
mmc_alloc_host+0x116/0x1c60 drivers/mmc/core/host.c:518 [mmc_core]
Freed by task 6314:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x3a/0x60 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2689 [inline]
slab_free mm/slub.c:6251 [inline]
kfree+0x1af/0x590 mm/slub.c:6566
device_release+0x81/0x150 drivers/base/core.c:-1
kobject_cleanup lib/kobject.c:689 [inline]
kobject_release lib/kobject.c:720 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0xfd/0x1c0 lib/kobject.c:737
release_nodes drivers/base/devres.c:546 [inline]
devres_release_all+0x102/0x170 drivers/base/devres.c:576
device_unbind_cleanup drivers/base/dd.c:598 [inline]
__device_release_driver drivers/base/dd.c:1357 [inline]
device_release_driver_internal+0x369/0x540 drivers/base/dd.c:1375
driver_detach+0x161/0x1f0 drivers/base/dd.c:1438
bus_remove_driver+0x17f/0x1c0 drivers/base/bus.c:825
pci_unregister_driver+0x20/0xe0 drivers/pci/pci-driver.c:1502
__do_sys_delete_module kernel/module/main.c:863 [inline]
__se_sys_delete_module+0x21c/0x370 kernel/module/main.c:804
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x143/0x470 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Last potentially related work creation:
kasan_save_stack+0x3e/0x60 mm/kasan/common.c:57
kasan_record_aux_stack+0x99/0xb0 mm/kasan/generic.c:556
insert_work+0x22/0x170 kernel/workqueue.c:2226
__queue_work+0x8d6/0xaa0 kernel/workqueue.c:2393
queue_delayed_work_on+0xf8/0x170 kernel/workqueue.c:2612
mmc_add_host+0x12cd/0x1350 drivers/mmc/core/host.c:665 [mmc_core]
The buggy address belongs to the object at ffff888059a6c000
which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 2600 bytes inside of
freed 8192-byte region [ffff888059a6c000, ffff888059a6e000)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x59a68
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x100000000000040(head|node=0|zone=1)
page_type: f5(slab)
raw: 0100000000000040 ffff888008042280 dead000000000100 dead000000000122
raw: 0000000000000000 0000000800020002 00000000f5000000 0000000000000000
head: 0100000000000040 ffff888008042280 dead000000000100 dead000000000122
head: 0000000000000000 0000000800020002 00000000f5000000 0000000000000000
head: 0100000000000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff
head: 0000000000000028 0000000000000000 00000000ffffffff 0000000000000008
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888059a6c900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888059a6c980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888059a6ca00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888059a6ca80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888059a6cb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Regards,
Yang Zi