Re: [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured streams

From: Péter Ujfalusi

Date: Mon Mar 30 2026 - 03:02:11 EST




On 27/03/2026 18:52, Mark Brown wrote:
> 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.

Yes, hostile user space is a valid concern, in theory it can ask for
TSTAMP or AVAIL before it would be meaningful (a configuration is set -
buffer config is known).

For avail the state sanity check is in wrong place in
snd_compr_ioctl_avail(), it should be before calling snd_compr_calc_avail().

tstamp does not even have a sanity validity check in
sound/cor/comrpess_offload.c, which it should as well - snd_compr_tstamp()

Should this be fixed in core level to avoid repeating the same check in
every driver?

--
Péter