* [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured streams
@ 2026-03-26 14:52 Mark Brown
2026-03-27 2:09 ` Liao, Bard
2026-03-27 9:49 ` Péter Ujfalusi
0 siblings, 2 replies; 5+ messages in thread
From: Mark Brown @ 2026-03-26 14:52 UTC (permalink / raw)
To: Liam Girdwood, Peter Ujfalusi, Bard Liao, Ranjani Sridharan,
Daniel Baluta, Kai Vehmanen, Pierre-Louis Bossart,
Jaroslav Kysela, Takashi Iwai, Paul Olaru, Laurentiu Mihalcea
Cc: sound-open-firmware, linux-sound, linux-kernel, Mark Brown,
stable
When reporting the pointer for a compressed stream we report the current
I/O frame position by dividing the position by the number of channels
multiplied by the number of container bytes. These values default to 0 and
are only configured as part of setting the stream parameters so this allows
a divide by zero to be configured. Validate that they are non zero,
returning an error if not
Fixes: c1a731c71359 ("ASoC: SOF: compress: Add support for computing timestamps")
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
---
sound/soc/sof/compress.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c
index 96570121aae0..90f056eae1c3 100644
--- a/sound/soc/sof/compress.c
+++ b/sound/soc/sof/compress.c
@@ -379,6 +379,9 @@ static int sof_compr_pointer(struct snd_soc_component *component,
if (!spcm)
return -EINVAL;
+ if (!sstream->channels || !sstream->sample_container_bytes)
+ return -EBUSY;
+
tstamp->sampling_rate = sstream->sampling_rate;
tstamp->copied_total = sstream->copied_total;
tstamp->pcm_io_frames = div_u64(spcm->stream[cstream->direction].posn.dai_posn,
---
base-commit: c369299895a591d96745d6492d4888259b004a9e
change-id: 20260326-asoc-compress-tstamp-params-296f38f15217
Best regards,
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured streams
2026-03-26 14:52 [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured streams Mark Brown
@ 2026-03-27 2:09 ` Liao, Bard
2026-03-27 16:48 ` Mark Brown
2026-03-27 9:49 ` Péter Ujfalusi
1 sibling, 1 reply; 5+ messages in thread
From: Liao, Bard @ 2026-03-27 2:09 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood, Peter Ujfalusi, Bard Liao,
Ranjani Sridharan, Daniel Baluta, Kai Vehmanen,
Pierre-Louis Bossart, Jaroslav Kysela, Takashi Iwai, Paul Olaru,
Laurentiu Mihalcea
Cc: sound-open-firmware@alsa-project.org, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
> -----Original Message-----
> From: Mark Brown <broonie@kernel.org>
> Sent: Thursday, March 26, 2026 10:53 PM
> To: Liam Girdwood <lgirdwood@gmail.com>; Peter Ujfalusi
> <peter.ujfalusi@linux.intel.com>; Bard Liao <yung-
> chuan.liao@linux.intel.com>; Ranjani Sridharan
> <ranjani.sridharan@linux.intel.com>; Daniel Baluta <daniel.baluta@nxp.com>;
> Kai Vehmanen <kai.vehmanen@linux.intel.com>; Pierre-Louis Bossart <pierre-
> louis.bossart@linux.dev>; Jaroslav Kysela <perex@perex.cz>; Takashi Iwai
> <tiwai@suse.com>; Paul Olaru <paul.olaru@oss.nxp.com>; Laurentiu Mihalcea
> <laurentiu.mihalcea@nxp.com>
> Cc: sound-open-firmware@alsa-project.org; linux-sound@vger.kernel.org;
> linux-kernel@vger.kernel.org; Mark Brown <broonie@kernel.org>;
> stable@vger.kernel.org
> Subject: [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured
> streams
>
> When reporting the pointer for a compressed stream we report the current
> I/O frame position by dividing the position by the number of channels
> multiplied by the number of container bytes. These values default to 0 and
> are only configured as part of setting the stream parameters so this allows
> a divide by zero to be configured. Validate that they are non zero,
> returning an error if not
>
> Fixes: c1a731c71359 ("ASoC: SOF: compress: Add support for computing
> timestamps")
> Signed-off-by: Mark Brown <broonie@kernel.org>
> Cc: stable@vger.kernel.org
> ---
> sound/soc/sof/compress.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c
> index 96570121aae0..90f056eae1c3 100644
> --- a/sound/soc/sof/compress.c
> +++ b/sound/soc/sof/compress.c
> @@ -379,6 +379,9 @@ static int sof_compr_pointer(struct
> snd_soc_component *component,
> if (!spcm)
> return -EINVAL;
>
> + if (!sstream->channels || !sstream->sample_container_bytes)
> + return -EBUSY;
Sorry, but why it is BUSY in this case?
> +
> tstamp->sampling_rate = sstream->sampling_rate;
> tstamp->copied_total = sstream->copied_total;
> tstamp->pcm_io_frames = div_u64(spcm->stream[cstream-
> >direction].posn.dai_posn,
>
> ---
> base-commit: c369299895a591d96745d6492d4888259b004a9e
> change-id: 20260326-asoc-compress-tstamp-params-296f38f15217
>
> Best regards,
> --
> Mark Brown <broonie@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured streams
2026-03-26 14:52 [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured streams Mark Brown
2026-03-27 2:09 ` Liao, Bard
@ 2026-03-27 9:49 ` Péter Ujfalusi
2026-03-27 16:52 ` Mark Brown
1 sibling, 1 reply; 5+ messages in thread
From: Péter Ujfalusi @ 2026-03-27 9:49 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood, Bard Liao, Ranjani Sridharan,
Daniel Baluta, Kai Vehmanen, Pierre-Louis Bossart,
Jaroslav Kysela, Takashi Iwai, Paul Olaru, Laurentiu Mihalcea
Cc: sound-open-firmware, linux-sound, linux-kernel, stable
On 26/03/2026 16:52, Mark Brown wrote:
> When reporting the pointer for a compressed stream we report the current
> I/O frame position by dividing the position by the number of channels
> multiplied by the number of container bytes. These values default to 0 and
> are only configured as part of setting the stream parameters so this allows
> a divide by zero to be configured. Validate that they are non zero,
> returning an error if not
>
> Fixes: c1a731c71359 ("ASoC: SOF: compress: Add support for computing timestamps")
> Signed-off-by: Mark Brown <broonie@kernel.org>
> Cc: stable@vger.kernel.org
> ---
> sound/soc/sof/compress.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c
> index 96570121aae0..90f056eae1c3 100644
> --- a/sound/soc/sof/compress.c
> +++ b/sound/soc/sof/compress.c
> @@ -379,6 +379,9 @@ static int sof_compr_pointer(struct snd_soc_component *component,
> if (!spcm)
> return -EINVAL;
>
> + if (!sstream->channels || !sstream->sample_container_bytes)
> + return -EBUSY;
> +
Is this a theoretical fix?
I don't think this can happen in real world as set_params would need to
fail and if that failed then applications would not ask for a pointer as
the compress stream cannot be even started.
> tstamp->sampling_rate = sstream->sampling_rate;
> tstamp->copied_total = sstream->copied_total;
> tstamp->pcm_io_frames = div_u64(spcm->stream[cstream->direction].posn.dai_posn,
>
> ---
> base-commit: c369299895a591d96745d6492d4888259b004a9e
> change-id: 20260326-asoc-compress-tstamp-params-296f38f15217
>
> Best regards,
> --
> Mark Brown <broonie@kernel.org>
>
>
--
Péter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured streams
2026-03-27 2:09 ` Liao, Bard
@ 2026-03-27 16:48 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-03-27 16:48 UTC (permalink / raw)
To: Liao, Bard
Cc: Liam Girdwood, Peter Ujfalusi, Bard Liao, Ranjani Sridharan,
Daniel Baluta, Kai Vehmanen, Pierre-Louis Bossart,
Jaroslav Kysela, Takashi Iwai, Paul Olaru, Laurentiu Mihalcea,
sound-open-firmware@alsa-project.org, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 331 bytes --]
On Fri, Mar 27, 2026 at 02:09:40AM +0000, Liao, Bard wrote:
> > + if (!sstream->channels || !sstream->sample_container_bytes)
> > + return -EBUSY;
> Sorry, but why it is BUSY in this case?
-EBUSY is often "wrong state". Could also be -EINVAL, it doesn't super
make a difference I think - nobody should actually be doing this.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured streams
2026-03-27 9:49 ` Péter Ujfalusi
@ 2026-03-27 16:52 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-03-27 16:52 UTC (permalink / raw)
To: Péter Ujfalusi
Cc: Liam Girdwood, Bard Liao, Ranjani Sridharan, Daniel Baluta,
Kai Vehmanen, Pierre-Louis Bossart, Jaroslav Kysela, Takashi Iwai,
Paul Olaru, Laurentiu Mihalcea, sound-open-firmware, linux-sound,
linux-kernel, stable
[-- Attachment #1: Type: text/plain, Size: 586 bytes --]
On Fri, Mar 27, 2026 at 11:49:41AM +0200, Péter Ujfalusi wrote:
> On 26/03/2026 16:52, Mark Brown wrote:
> > + if (!sstream->channels || !sstream->sample_container_bytes)
> > + return -EBUSY;
> > +
> Is this a theoretical fix?
> I don't think this can happen in real world as set_params would need to
> fail and if that failed then applications would not ask for a pointer as
> the compress stream cannot be even started.
Yes, it's not something that would happen in the real world with a non
buggy (or hostile) userspace. Still, we shouldn't leave this stuff
open.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-03-27 16:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26 14:52 [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured streams Mark Brown
2026-03-27 2:09 ` Liao, Bard
2026-03-27 16:48 ` Mark Brown
2026-03-27 9:49 ` Péter Ujfalusi
2026-03-27 16:52 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox