REDHAT-BUG-2541360: Use After Free
In the Linux kernel, the following vulnerability has been resolved:
ALSA: pcm: Serialize PCM mmap with buffer reallocation to fix page UAF
sndpcmhwparams() and sndpcmhwfree() guard buffer reallocation with an mmapcount check performed under the PCM stream lock, but the lock is released long before the buffer is actually freed: sndpcmsyncstop(), constraint refinement and dofreepages() all happen in between. sndpcmmmapdata(), on the other hand, takes no lock at all: it validates against the old buffer's state and dmabytes, remaps its pages into the VMA, and only then increments mmapcount.
A concurrent mmap() can therefore slip in between the check and the free. remappfnrange() installs writable PTEs for the old buffer's pages without taking page references, and the subsequent dofreepages() returns those pages to the page allocator while the VMA still maps them. This leaves a stale, writable mapping of freed pages: a page-level use-after-free that can be leveraged for local privilege escalation.
Make sndpcmmmapdata() participate in the buffer-access scheme introduced for hwparams/hwfree: acquire runtime->bufferaccessing before validating and remapping, and release it afterwards. Buffer reallocation already fails with -EBUSY while accessors are active, and the mmap side now fails with -EBUSY while a reallocation is in progress, so the validate/remap sequence and the check/free sequence can no longer interleave.
A reproducer that turns this race into a stale writable mapping of the freed DMA buffer pages is available on request.
Affected Software
Event History
Frequently Asked Questions
Who is exposed to this issue?
Systems running an affected Linux kernel where ALSA PCM device buffers can be memory-mapped are exposed. Exploitation is local and can lead to privilege escalation.
What does an attacker need to exploit it?
An attacker needs local access and must race PCM buffer reallocation or freeing through snd_pcm_hw_params() or snd_pcm_hw_free() against mmap() of the PCM buffer. The race can leave a writable mapping to pages that have been returned to the page allocator.
How can I determine whether a system has been remediated?
Check whether the installed kernel includes the ALSA PCM change that serializes snd_pcm_mmap_data() with buffer reallocation by acquiring runtime->buffer_accessing before validating and remapping the buffer. Red Hat errata RHSA-2026:98100 and RHSA-2026:98099 are referenced for fixes.