* [PATCH] ASoC: intel: atom: SST: sync the DSP threaded IRQ against the PCM close path (uaf of sst_runtime_stream and snd_pcm_runtime)
@ 2026-12-01 18:16 Hanxiang Xu
2026-12-02 2:53 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Hanxiang Xu @ 2026-12-01 18:16 UTC (permalink / raw)
To: Cezary Rojewski, Liam Girdwood, Pierre-Louis Bossart
Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-kernel
The SST PCM close path frees the platform sst_runtime_stream
(sst_media_close()) and the snd_pcm_runtime
(snd_pcm_detach_substream()) without any barrier against the DSP
threaded IRQ handler. process_fw_async_msg() gates the slot callback
only on STREAM_INIT, so a message processed while sst_free_stream()
has already switched the slot to STREAM_UN_INIT - but not yet cleared
period_elapsed/pcm_substream, which happens only after the
FREE_STREAM firmware round trip returns - still fires
sst_period_elapsed() on objects the close path frees right under it.
The suspend paths already use synchronize_irq(ctx->irq_num) for the
same purpose; the close path never does, and neither the component
.sync_stop nor card->sync_irq exists for this hardware.
Gate the PERIOD_ELAPSED handler on STREAM_RUNNING, drain the threaded
IRQ in sst_close_pcm_stream(), and clear
substream->runtime->private_data before kfree(stream).
Also reproduced on 7.4.0-rc5: 68 slab-use-after-free reports in
sst_period_elapsed()/sst_get_stream_status() with a KASAN kernel
(negative control clean).
Cc: <stable@vger.kernel.org>
Signed-off-by: Hanxiang Xu <xuhx@hust.edu.cn>
---
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
index 8c0e4c1..b280132 100644
--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
@@ -362,6 +362,7 @@
if (str_id)
stream->ops->close(sst->dev, str_id);
module_put(sst->dev->driver->owner);
+ substream->runtime->private_data = NULL;
kfree(stream);
}
diff --git a/sound/soc/intel/atom/sst/sst_drv_interface.c b/sound/soc/intel/atom/sst/sst_drv_interface.c
index 2646c46..612f59c 100644
--- a/sound/soc/intel/atom/sst/sst_drv_interface.c
+++ b/sound/soc/intel/atom/sst/sst_drv_interface.c
@@ -443,6 +443,7 @@
stream->status = STREAM_UN_INIT;
stream->period_elapsed = NULL;
ctx->stream_cnt--;
+ synchronize_irq(ctx->irq_num);
if (retval)
dev_err(ctx->dev, "free stream returned err %d\n", retval);
diff --git a/sound/soc/intel/atom/sst/sst_ipc.c b/sound/soc/intel/atom/sst/sst_ipc.c
index 6c19ab6..77dff41 100644
--- a/sound/soc/intel/atom/sst/sst_ipc.c
+++ b/sound/soc/intel/atom/sst/sst_ipc.c
@@ -268,8 +268,9 @@
"Period elapsed rcvd for pipe id 0x%x\n",
pipe_id);
stream = &sst_drv_ctx->streams[str_id];
- /* If stream is dropped, skip processing this message*/
- if (stream->status == STREAM_INIT)
+ /* Only a running stream owns valid slot callbacks; STREAM_INIT
+ * (dropped) and STREAM_UN_INIT (closed) must not fire them */
+ if (stream->status != STREAM_RUNNING)
break;
if (stream->period_elapsed)
stream->period_elapsed(stream->pcm_substream);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: intel: atom: SST: sync the DSP threaded IRQ against the PCM close path (uaf of sst_runtime_stream and snd_pcm_runtime)
2026-12-01 18:16 [PATCH] ASoC: intel: atom: SST: sync the DSP threaded IRQ against the PCM close path (uaf of sst_runtime_stream and snd_pcm_runtime) Hanxiang Xu
@ 2026-12-02 2:53 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-02 2:53 UTC (permalink / raw)
To: Hanxiang Xu; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] ASoC: intel: atom: NULL pointer dereference in
sst_media_close() [1]
--
commit a2f8411a02b3eded3b6e9cfa2cd597b87af64776
Author: Hanxiang Xu <xuhx@hust.edu.cn>
ASoC: intel: atom: SST: sync the DSP threaded IRQ against the PCM close path (uaf of sst_runtime_stream and snd_pcm_runtime)
This commit synchronizes the DSP threaded IRQ handler with the PCM stream
close path and gates PERIOD_ELAPSED handling on STREAM_RUNNING to prevent
use-after-free on sst_runtime_stream and snd_pcm_runtime.
> diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
> index bbd43d1b5bfa3..f0ec299a34df5 100644
> --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
> +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
> @@ -361,6 +361,7 @@ static void sst_media_close(struct snd_pcm_substream *substream,
> if (str_id)
> stream->ops->close(sst->dev, str_id);
> module_put(sst->dev->driver->owner);
> + substream->runtime->private_data = NULL;
[Severity: High]
This problem wasn't introduced by this patch, but can sst_media_close() and
power_down_sst() trigger a NULL pointer dereference on sst [1] if an
active PCM stream is closed after the DSP device is unbound?
When the DSP device is unbound, sst_unregister_dsp() clears the global sst
pointer to NULL while the ALSA card remains registered. If userspace then
closes an open stream, power_down_sst() and sst_media_close() dereference
sst->dev without checking sst or holding sst_lock.
[1] https://sashiko.dev/#/bug/linux-8e69848a-8b71-4130-b540-29b3c6f2eb39
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202021639.1-1-xuhx@hust.edu.cn?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-02 2:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 18:16 [PATCH] ASoC: intel: atom: SST: sync the DSP threaded IRQ against the PCM close path (uaf of sst_runtime_stream and snd_pcm_runtime) Hanxiang Xu
2026-12-02 2:53 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox