CVE-2026-139277: ALSA: pcm: Remove channel-map controls before freeing substreams
In the Linux kernel, the following vulnerability has been resolved:
ALSA: pcm: Remove channel-map controls before freeing substreams
A late HDA codec bind on an already registered card builds new PCMs before registering them. addstdchmaps() publishes generic channel-map controls during this BUILD stage. If an earlier chmap succeeds and a later allocation fails, probe cleanup frees the BUILD PCM while the card's control device remains accessible.
These generic controls are added directly by sndpcmaddchmapctls(); sndhdactlsclear() only removes codec-tracked mixer controls. BUILD devices also skip devdisconnect. sndpcmfreestream() then frees the substreams before freechmap() withdraws their generic control:
Late HDA codec bind / rollback Control GET on the live card ------------------------------ ---------------------------- hdacodecdriverprobe() sndhdacodecbuildpcms() PCM is BUILD sndhdacodecbuildcontrols() addstdchmaps() publish an earlier chmap later allocation: -ENOMEM sndhdacodeccleanupforunbind() sndhdactlsclear() generic chmap remains codecreleasepcms() snddevicefree() BUILD: skip devdisconnect sndpcmfreestream() kfree(substream) sndctlelemread() downread(controlsrwsem) pcmchmapctlget() walk freed substream freechmap() sndctlremove() wait for GET upread(controlsrwsem)
The control read lock cannot protect a substream already freed before control removal starts. The failure above occurs before sndcardregister(), so the PCM has not transitioned out of BUILD.
Move freechmap() before the substream free loop. Its sndctlremove() withdraws the control and drains readers under controlsrwsem before any substream is released. Normal registered-device disconnect already removes the control, so the later call remains harmless on that path.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In snd_pcm_free_stream(), call free_chmap() before the loop that frees substreams, so generic channel-map controls are withdrawn before their substreams are released.