* [PATCH] ASoC: intel: atom: SST: clear the compress drain callbacks on close and gate them on the stream status (uaf of snd_compr_stream)
@ 2026-12-01 18:17 Hanxiang Xu
2026-12-02 2:59 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Hanxiang Xu @ 2026-12-01 18:17 UTC (permalink / raw)
To: Cezary Rojewski, Liam Girdwood, Pierre-Louis Bossart
Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-kernel
sst_cdev_open() registers four callbacks into the persistent DSP
stream slot, but sst_cdev_close() clears only the compr_cb pair and
leaves drain_notify/drain_cb_param armed, and never clears the slot's
pipe_id. process_fw_async_msg() dispatches IPC_IA_DRAIN_STREAM_MRFLD
purely on "pipe_id matches, drain_notify != NULL" with no status
check, so a drain completion that arrives after the close path has
run snd_compr_free() - which kfrees the runtime and the
snd_compr_file containing the cstream - is dispatched as
sst_drain_notify(cstream) -> snd_compr_drain_notify(), writing the
freed cstream->runtime->state and waking the freed runtime->sleep.
SST implements non-blocking drain, so "drain, then close while the
firmware is still draining" is a routine user sequence, and nothing
synchronizes the threaded IRQ on this path.
Clear all four callbacks plus pipe_id in sst_cdev_close() and drain
in-flight completions with synchronize_irq(ctx->irq_num) before
returning; gate the DRAIN branch on STREAM_RUNNING like the
PERIOD_ELAPSED branch already does.
Also reproduced on 7.4.0-rc5: 104 slab-use-after-free reports
(49 in sst_drain_notify itself) with a KASAN kernel; negative control
(callbacks never armed) clean.
Cc: <stable@vger.kernel.org>
Signed-off-by: Hanxiang Xu <xuhx@hust.edu.cn>
---
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/sound/soc/intel/atom/sst/sst_drv_interface.c b/sound/soc/intel/atom/sst/sst_drv_interface.c
index 2646c46..d145ea9 100644
--- a/sound/soc/intel/atom/sst/sst_drv_interface.c
+++ b/sound/soc/intel/atom/sst/sst_drv_interface.c
@@ -214,6 +214,10 @@
retval = sst_free_stream(ctx, str_id);
stream->compr_cb_param = NULL;
stream->compr_cb = NULL;
+ stream->drain_cb_param = NULL;
+ stream->drain_notify = NULL;
+ stream->pipe_id = PIPE_RSVD;
+ synchronize_irq(ctx->irq_num);
if (retval)
dev_err(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..e77eff0 100644
--- a/sound/soc/intel/atom/sst/sst_ipc.c
+++ b/sound/soc/intel/atom/sst/sst_ipc.c
@@ -283,6 +283,10 @@
str_id = get_stream_id_mrfld(sst_drv_ctx, pipe_id);
if (str_id > 0) {
stream = &sst_drv_ctx->streams[str_id];
+ /* Only a running stream can complete a drain; after close the
+ * cstream the callback would touch is gone */
+ if (stream->status != STREAM_RUNNING)
+ break;
if (stream->drain_notify)
stream->drain_notify(stream->drain_cb_param);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: intel: atom: SST: clear the compress drain callbacks on close and gate them on the stream status (uaf of snd_compr_stream)
2026-12-01 18:17 [PATCH] ASoC: intel: atom: SST: clear the compress drain callbacks on close and gate them on the stream status (uaf of snd_compr_stream) Hanxiang Xu
@ 2026-12-02 2:59 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-02 2:59 UTC (permalink / raw)
To: Hanxiang Xu; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ASoC: intel: atom: missing Fixes trailer in commit message
--
commit 8b22e969b6edb39c81e25e25be00f9bd0eddc9fb
Author: Hanxiang Xu <xuhx@hust.edu.cn>
> ASoC: intel: atom: SST: clear the compress drain callbacks on close and gate them on the stream status (uaf of snd_compr_stream)
>
> sst_cdev_open() registers four callbacks into the persistent DSP
> stream slot, but sst_cdev_close() clears only the compr_cb pair and
> leaves drain_notify/drain_cb_param armed, and never clears the slot's
> pipe_id. process_fw_async_msg() dispatches IPC_IA_DRAIN_STREAM_MRFLD
> purely on "pipe_id matches, drain_notify != NULL" with no status
> check, so a drain completion that arrives after the close path has
> run snd_compr_free() - which kfrees the runtime and the
> snd_compr_file containing the cstream - is dispatched as
> sst_drain_notify(cstream) -> snd_compr_drain_notify(), writing the
> freed cstream->runtime->state and waking the freed runtime->sleep.
> SST implements non-blocking drain, so "drain, then close while the
> firmware is still draining" is a routine user sequence, and nothing
> synchronizes the threaded IRQ on this path.
>
> Clear all four callbacks plus pipe_id in sst_cdev_close() and drain
> in-flight completions with synchronize_irq(ctx->irq_num) before
> returning; gate the DRAIN branch on STREAM_RUNNING like the
> PERIOD_ELAPSED branch already does.
>
> Also reproduced on 7.4.0-rc5: 104 slab-use-after-free reports
> (49 in sst_drain_notify itself) with a KASAN kernel; negative control
> (callbacks never armed) clean.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Hanxiang Xu <xuhx@hust.edu.cn>
[Severity: Low]
Since this fixes the missing drain callback cleanup in sst_cdev_close() and
is tagged for stable, should it include a Fixes: tag?
Fixes: 7adab122a57c ("ASoC: Intel: sst - add compressed ops handling")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202021739.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:59 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:17 [PATCH] ASoC: intel: atom: SST: clear the compress drain callbacks on close and gate them on the stream status (uaf of snd_compr_stream) Hanxiang Xu
2026-12-02 2:59 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox