CVE-2026-142913: ALSA: pcm: Protect delay DMA sync against concurrent HW_FREE
In the Linux kernel, the following vulnerability has been resolved:
ALSA: pcm: Protect delay DMA sync against concurrent HWFREE
A PCM DMA buffer must remain allocated until explicit DMA synchronization finishes. sndpcmdelay() calls sndpcmdmabuffersync() after dropping the stream lock, without participating in the buffer-access exclusion used by HWFREE.
With a managed NONCONTIG buffer requiring explicit sync, HWPARAMS can allocate a separate runtime descriptor when the requested ring exceeds the preallocation. In PREPARED state with mmapcount zero, concurrent HWSYNC and HWFREE calls on the same open PCM file can interleave:
1. HWSYNC checks the state in sndpcmdelay() under the stream lock and releases that lock. 2. The sync helper fetches runtime->dmabufferp and enters snddmanoncontigsync() with that descriptor. 3. HWFREE takes the negative buffer-access count, checks PREPARED under the stream lock, releases the lock, and frees the DMA allocation and dynamic descriptor through sndpcmlibfreepages(). 4. The sync callback resumes and reads the freed descriptor.
The stream lock does not cover the allocation's release, and the sync operation has no positive buffer-access count to prevent it. The stale read causes a use-after-free in snddmanoncontigsync(). DELAY uses the same sndpcmdelay() path.
Take a positive buffer-access count before checking the state and keep it until the DMA sync finishes, as the transfer and mmap paths already do. HWFREE then returns -EBUSY while this access is active. If a buffer writer has already entered, sndpcmdelay() returns -EBUSY before using the buffer. Keep the sync outside the stream lock and balance the count on the state-error path as well.
KASAN report as below:
BUG: KASAN: slab-use-after-free in snddmanoncontigsync+0x295/0x310 [sndpcm] Read of size 4 at addr ffff888108f58584 by task pcm-uaf-fixture/487
CPU: 1 UID: 0 PID: 487 Comm: pcm-uaf-fixture Not tainted 7.2.0-rc6-pmb-alsa-functional-v2+ #1 PREEMPT(lazy) Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, archcaps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: <TASK> dumpstacklvl+0x93/0xd0 printreport+0xce/0x630 ? snddmanoncontigsync+0x295/0x310 [sndpcm] ? srsoaliasreturnthunk+0x5/0xfbef5 ? virtaddrvalid+0x20d/0x410 ? snddmanoncontigsync+0x295/0x310 [sndpcm] kasanreport+0xe0/0x110 ? snddmanoncontigsync+0x295/0x310 [sndpcm] ? pfxsnddmanoncontigsync+0x10/0x10 [sndpcm] snddmanoncontigsync+0x295/0x310 [sndpcm] ? pfxsnddmanoncontigsync+0x10/0x10 [sndpcm] snddmabuffersync+0xc9/0x110 [sndpcm] sndpcmdelay+0x3bd/0x550 [sndpcm] sndpcmcommonioctl+0x1e7/0x3aa0 [sndpcm] ? srsoaliasreturnthunk+0x5/0xfbef5 ? dovfsioctl+0x1f5/0x1280 ? pfxdovfsioctl+0x10/0x10 ? ioctlhasperm.constprop.0.isra.0+0x34f/0x500 ? pfxsndpcmcommonioctl+0x10/0x10 [sndpcm] ? srsoaliasreturnthunk+0x5/0xfbef5 sndpcmioctl+0x76/0xb0 [sndpcm] ? pfxsndpcmioctl+0x10/0x10 [sndpcm] x64sysioctl+0x163/0x1d0 dosyscall64+0x115/0x6a0 entrySYSCALL64afterhwframe+0x77/0x7f RIP: 0033:0x7f1cae7ab91b Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1c 48 8b 44 24 18 64 48 2b 04 25 28 00 00 RSP: 002b:00007ffe12d544f0 EFLAGS: 00000246 ORIGRAX: 0000000000000010 RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f1cae7ab91b RDX: 0000000000000000 RSI: 0000000000004122 RDI: 0000000000000003 RBP: 00000000000001ee R08: 0000000000000073 R09: 00000000ffffffff R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000003 R13: 0000000000000001 R14: 00005584f32b1398 R15: 00005584f32b2ce8 </TASK>
Allocated by task 487: kasansa ---truncated---
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In snd_pcm_delay(), take a positive buffer-access count before checking the state and retain it on the state-error path; keep DMA synchronization outside the stream lock and balance the count only after synchronization finishes.