[PATCH 2/2] ASoC: qcom: q6asm-dai: reject compress rings larger than the DMA buffer

From: Julius Bairaktaris

Date: Wed Nov 11 2026 - 03:08:40 EST


q6asm_dai_compr_open() allocates a fixed 8 MiB DMA buffer, but
q6asm_dai_compr_set_params() takes the ring size from the fragment size
and count that userspace passes to SNDRV_COMPRESS_SET_PARAMS without
checking it against that buffer. The compress core checks the geometry
against the runtime buffer only for drivers without a copy callback.
q6asm_compr_copy() places each write() at the stream position modulo the
ring size, so a ring larger than the DMA buffer lets write() copy user
data past its end, and after SNDRV_COMPRESS_NEXT_TRACK the copy starts at
the next multiple of the fragment size.

Reject a ring larger than the DMA buffer.

Fixes: a08cd56a4524 ("ASoC: q6asm-dai: add support to copy callback")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Julius Bairaktaris <julius@xxxxxxxxxxxxxx>
---
sound/soc/qcom/qdsp6/q6asm-dai.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
index 4261c3048c368..1cd99a1d5b516 100644
--- a/sound/soc/qcom/qdsp6/q6asm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
@@ -897,6 +897,9 @@ static int q6asm_dai_compr_set_params(struct snd_soc_component *component,
return -EINVAL;
}

+ if (runtime->buffer_size > prtd->dma_buffer.bytes)
+ return -EINVAL;
+
prtd->periods = runtime->fragments;
prtd->pcm_count = runtime->fragment_size;
prtd->pcm_size = runtime->fragments * runtime->fragment_size;
--
2.53.0