CVE-2026-90198: ALSA: core: Fix use-after-free in snd_card_do_free()
In the Linux kernel, the following vulnerability has been resolved:
ALSA: core: Fix use-after-free in sndcarddofree()
A use-after-free was detected in sndcarddofree() when a sound card managed by devres is unbound while a user-space application still holds an open file descriptor.
For managed cards, the memory is allocated using devresalloc(), and its release function is set to sndcardrelease(), which calls sndcardfree(). When the device is unbound, the unbind thread calls sndcardfree(), which drops a reference to the card's device. If the user thread still has an open file descriptor, the reference count does not reach zero, and the unbind thread blocks on waitforcompletion(&released).
When the user thread closes the file descriptor, it drops the final reference, invoking the device release callback releasecarddevice(), which calls sndcarddofree(). sndcarddofree() performs cleanup and calls complete(card->releasecompletion). This wakes up the unbind thread, which returns from sndcardfree() and sndcardrelease(). The devres core then immediately frees the memory block containing the sndcard structure.
Meanwhile, the user thread continues execution in sndcarddofree() and evaluates if (!card->managed). It reads the managed boolean from the sndcard structure that was just freed by the unbind thread, triggering a KASAN use-after-free.
Fix this by caching the value of card->managed in a local variable before calling complete(). This ensures that the card pointer is not dereferenced after the unbind thread has been woken up and potentially freed the card.
BUG: KASAN: use-after-free in sndcarddofree sound/core/init.c:604 [inline] BUG: KASAN: use-after-free in releasecarddevice+0x1ab/0x1b0 sound/core/init.c:153 Read of size 1 at addr ffff8881912ec909 by task syz-executor130/5857
Call Trace: <TASK> dumpstacklvl+0xe8/0x150 lib/dumpstack.c:120 printaddressdescription+0x55/0x1e0 mm/kasan/report.c:378 printreport+0x58/0x70 mm/kasan/report.c:482 kasanreport+0x117/0x150 mm/kasan/report.c:595 sndcarddofree sound/core/init.c:604 [inline] releasecarddevice+0x1ab/0x1b0 sound/core/init.c:153 devicerelease+0xc4/0x1f0 drivers/base/core.c:-1 kobjectcleanup lib/kobject.c:689 [inline] kobjectrelease lib/kobject.c:720 [inline] krefput include/linux/kref.h:65 [inline] kobjectput+0x222/0x550 lib/kobject.c:737 sndcardfileremove+0x331/0x390 sound/core/init.c:1125 sndpcmrelease+0x12c/0x160 sound/core/pcmnative.c:2986 fput+0x418/0xa50 fs/filetable.c:512 fputclosesync+0x11f/0x240 fs/filetable.c:617 dosysclose fs/open.c:1511 [inline] sesysclose fs/open.c:1496 [inline] x64sysclose+0x7e/0x110 fs/open.c:1496 dosyscallx64 arch/x86/entry/syscall64.c:63 [inline] dosyscall64+0x174/0x580 arch/x86/entry/syscall64.c:94 entrySYSCALL64afterhwframe+0x77/0x7f </TASK>
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Configuration
Fix the KASAN use-after-free by caching the value of `card->managed` into a local variable in `snd_card_do_free()` before any code paths that may trigger unbind/free of the `card` device; then use the cached value for the `if (!card->managed)` evaluation.
Linux kernel ALSA core (sound/core/init.c) managed boolean caching in snd_card_do_free() = cache card->managed into a local variable before checking if (!card->managed)
Event History
Frequently Asked Questions
Which deployments are exposed to this race condition?
The affected scenario involves ALSA sound cards managed by devres. The race occurs when such a card is unbound while a user-space application still holds an open file descriptor for the card.
What sequence triggers the use-after-free?
One thread must unbind the device and enter card teardown while another user-space thread retains and then closes the final open file descriptor. Closing that descriptor can invoke snd_card_do_free() as the unbind path is released, allowing devres to free the card structure while the user thread continues execution.