* [PATCH] ALSA: pcm: fix use-after-free in snd_pcm_post_stop
@ 2026-02-08 10:20 Soham Kute
2026-02-08 16:37 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Soham Kute @ 2026-02-08 10:20 UTC (permalink / raw)
To: tiwai
Cc: perex, linux-sound, linux-kernel, Soham Kute,
syzbot+16b2b67ae905feb8a289
syzbot reported a slab-use-after-free in snd_pcm_post_stop() when the
PCM runtime may already be freed during teardown.
snd_pcm_post_stop() can be called after snd_pcm_detach_substream()
releases the runtime, leading to a use-after-free when accessing
runtime state and wait queues.
Add a defensive check to avoid dereferencing a freed runtime pointer.
Reported-by: syzbot+16b2b67ae905feb8a289@syzkaller.appspotmail.com
Signed-off-by: Soham Kute <officialsohamkute@gmail.com>
---
sound/core/pcm_native.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 932a9bf98..7b9e2aea5 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1542,6 +1542,10 @@ static void snd_pcm_post_stop(struct snd_pcm_substream *substream,
snd_pcm_state_t state)
{
struct snd_pcm_runtime *runtime = substream->runtime;
+
+ if (!runtime)
+ return;
+
if (runtime->state != state) {
snd_pcm_trigger_tstamp(substream);
__snd_pcm_set_state(runtime, state);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: pcm: fix use-after-free in snd_pcm_post_stop
2026-02-08 10:20 [PATCH] ALSA: pcm: fix use-after-free in snd_pcm_post_stop Soham Kute
@ 2026-02-08 16:37 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-02-08 16:37 UTC (permalink / raw)
To: Soham Kute
Cc: tiwai, perex, linux-sound, linux-kernel, syzbot+16b2b67ae905feb8a289
On Sun, 08 Feb 2026 11:20:58 +0100,
Soham Kute wrote:
>
> syzbot reported a slab-use-after-free in snd_pcm_post_stop() when the
> PCM runtime may already be freed during teardown.
>
> snd_pcm_post_stop() can be called after snd_pcm_detach_substream()
> releases the runtime, leading to a use-after-free when accessing
> runtime state and wait queues.
>
> Add a defensive check to avoid dereferencing a freed runtime pointer.
>
> Reported-by: syzbot+16b2b67ae905feb8a289@syzkaller.appspotmail.com
>
> Signed-off-by: Soham Kute <officialsohamkute@gmail.com>
Thanks for the patch, but IMO it's rather a wrong "fix". It just
papers over some place that had casually a NULL dereference due to a
UAF. That is, this change itself is no fix for UAF, but just trying
to avoid a casual Oops; more worse, it may still happen at another
place if happening at a little bit different moment even if you plug
like that.
If any, we could put such a sanity check with WARN_ON() to indicate
the obvious code flow error. But, still there is no much reason to
put the check only here at this place. After all, the actual UAF must
be fixed in the caller side.
thanks,
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-08 16:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-08 10:20 [PATCH] ALSA: pcm: fix use-after-free in snd_pcm_post_stop Soham Kute
2026-02-08 16:37 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®