SX control bounds check fixups
cover SX control bounds check fixups
These two SX control fixups seem to have got lost somewhere along the line. They were merged back in 5.18 but never seems to actually make it into the kernel:
https://lore.kernel.org/all/[email protected]/
Apologies if resending isn't the correct course but it seemed the safest way to go. Note I have made a slight fixup to the second patch.
Thanks,
Charles
Mark Brown (2):
ASoC: ops: Fix bounds check for _sx controls
ASoC: ops: Check bounds for second channel in snd_soc_put_volsw_sx()
sound/soc/soc-ops.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/2 ASoC: ops: Fix bounds check for _sx controls
From: Mark Brown <[email protected]>
For _sx controls the semantics of the max field is not the usual one, max is the number of steps rather than the maximum value. This means that our check in snd_soc_put_volsw_sx() needs to just check against the maximum value.
--- sound/soc/soc-ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-ops.c +1 -1
@@ -452,7 +452,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, val = ucontrol->value.integer.value[0 ];if (mc->platform_max && val > mc->platform_max)return -EINVAL ; -if (val > max - min) +if (val > max)return -EINVAL ; val_mask = mask << shift; val = (val + min) & mask;
Signature · 1 line
2.30.2
PATCH 2/2 ASoC: ops: Check bounds for second channel in snd_soc_put_volsw_sx()
In reply to Charles KeepaxFrom: Mark Brown <[email protected]>
The bounds checks in snd_soc_put_volsw_sx() are only being applied to the first channel, meaning it is possible to write out of bounds values to the second channel in stereo controls. Add appropriate checks.
---
Slight fixup was made over your original version to make the check of val2 > max be without the min and mask applied.
Thanks,
Charles
sound/soc/soc-ops.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
sound/soc/soc-ops.c +7 -2
@@ -464,10 +464,15 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, ret = err;if (snd_soc_volsw_is_stereo (mc)) { -unsigned int val2; +unsigned int val2 = ucontrol->value.integer.value[1 ]; + +if (mc->platform_max && val2 > mc->platform_max) +return -EINVAL ; +if (val2 > max) +return -EINVAL ; val_mask = mask << rshift; - val2 = (ucontrol->value.integer.value[1 ] + min) & mask; + val2 = (val2 + min) & mask; val2 = val2 << rshift; err = snd_soc_component_update_bits(component, reg2, val_mask,
Signature · 1 line
2.30.2
Mark Brown
maintainerQuoted 8 lines · Charles Keepax
These two SX control fixups seem to have got lost somewhere along the line. They were merged back in 5.18 but never seems to actually make it into the kernel:
https://lore.kernel.org/all/[email protected]/
Apologies if resending isn't the correct course but it seemed the safest way to go. Note I have made a slight fixup to the second patch.
These should already be queued as fixes.