ALSA: pcm: prevent snd_pcm_action after substream detach
PATCH 1/1 ALSA: pcm: prevent snd_pcm_action after substream detach
syzbot reported a slab use-after-free in snd_pcm_post_stop() caused by snd_pcm_action() being invoked after snd_pcm_detach_substream() has already freed the PCM runtime.
The previous approach attempted to guard against NULL runtime access in the post-action callback, which only masked the symptom. As pointed out in review, this does not address the underlying lifetime issue.
Fix the root cause by preventing snd_pcm_action() from running once the substream runtime has been detached, ensuring that no PCM actions are executed after teardown.
--- sound/core/pcm_native.c | 3 +++ 1 file changed, 3 insertions(+)
sound/core/pcm_native.c +3 -0
@@ -1391,6 +1391,9 @@ static int snd_pcm_action(const struct action_ops *ops,struct snd_pcm_group *group;int res; +if (WARN_ON_ONCE (!substream->runtime)) +return 0 ; + group =snd_pcm_stream_group_ref (substream);if (group) res =snd_pcm_action_group (ops, substream, state, true);
Signature · 1 line
2.34.1
Quoted 9 lines · Soham Kute
syzbot reported a slab use-after-free in
snd_pcm_post_stop()caused bysnd_pcm_action()being invoked aftersnd_pcm_detach_substream()has already freed the PCM runtime.The previous approach attempted to guard against NULL runtime access in the post-action callback, which only masked the symptom. As pointed out in review, this does not address the underlying lifetime issue.
Quoted 7 lines
Fix the root cause by preventing
snd_pcm_action()from running once the substream runtime has been detached, ensuring that no PCM actions are executed after teardown.Reported-by [email protected]Signed-off-by Soham Kute <[email protected]>
Thanks for the revised patch. This patch puts the check at a better place than the previous patch, but it's still misleading; this doesn't address the root cause at all. It's just plugging a hole at a middle point of the code path.
I guess you're trying to fix the UAF report for aloop driver, and this was already addressed by the recent patch (included in 6.19). Please check whether you still see the problem with 6.19 release.
thanks,
Takashi