* [PATCH v1 1/3] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw()
[not found] <20220124153253.3548853-1-broonie@kernel.org>
@ 2022-01-24 15:32 ` Mark Brown
2022-01-24 15:32 ` [PATCH v1 2/3] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx() Mark Brown
2022-01-24 15:32 ` [PATCH v1 3/3] ASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx() Mark Brown
2 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-01-24 15:32 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel, Mark Brown, stable
We don't currently validate that the values being set are within the range
we advertised to userspace as being valid, do so and reject any values
that are out of range.
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
---
sound/soc/soc-ops.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index 08eaa9ddf191..fbe5d326b0f2 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -316,13 +316,27 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
if (sign_bit)
mask = BIT(sign_bit + 1) - 1;
- val = ((ucontrol->value.integer.value[0] + min) & mask);
+ val = ucontrol->value.integer.value[0];
+ if (mc->platform_max && val > mc->platform_max)
+ return -EINVAL;
+ if (val > max - min)
+ return -EINVAL;
+ if (val < 0)
+ return -EINVAL;
+ val = (val + min) & mask;
if (invert)
val = max - val;
val_mask = mask << shift;
val = val << shift;
if (snd_soc_volsw_is_stereo(mc)) {
- val2 = ((ucontrol->value.integer.value[1] + min) & mask);
+ val2 = ucontrol->value.integer.value[1];
+ if (mc->platform_max && val2 > mc->platform_max)
+ return -EINVAL;
+ if (val2 > max - min)
+ return -EINVAL;
+ if (val2 < 0)
+ return -EINVAL;
+ val2 = (val2 + min) & mask;
if (invert)
val2 = max - val2;
if (reg == reg2) {
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v1 2/3] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()
[not found] <20220124153253.3548853-1-broonie@kernel.org>
2022-01-24 15:32 ` [PATCH v1 1/3] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw() Mark Brown
@ 2022-01-24 15:32 ` Mark Brown
2022-01-24 15:32 ` [PATCH v1 3/3] ASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx() Mark Brown
2 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-01-24 15:32 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel, Mark Brown, stable
We don't currently validate that the values being set are within the range
we advertised to userspace as being valid, do so and reject any values
that are out of range.
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
---
sound/soc/soc-ops.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index fbe5d326b0f2..c31e63b27193 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -423,8 +423,15 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
int err = 0;
unsigned int val, val_mask;
+ val = ucontrol->value.integer.value[0];
+ if (mc->platform_max && val > mc->platform_max)
+ return -EINVAL;
+ if (val > max - min)
+ return -EINVAL;
+ if (val < 0)
+ return -EINVAL;
val_mask = mask << shift;
- val = (ucontrol->value.integer.value[0] + min) & mask;
+ val = (val + min) & mask;
val = val << shift;
err = snd_soc_component_update_bits(component, reg, val_mask, val);
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v1 3/3] ASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx()
[not found] <20220124153253.3548853-1-broonie@kernel.org>
2022-01-24 15:32 ` [PATCH v1 1/3] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw() Mark Brown
2022-01-24 15:32 ` [PATCH v1 2/3] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx() Mark Brown
@ 2022-01-24 15:32 ` Mark Brown
2 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-01-24 15:32 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel, Mark Brown, stable
We don't currently validate that the values being set are within the range
we advertised to userspace as being valid, do so and reject any values
that are out of range.
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
---
sound/soc/soc-ops.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index c31e63b27193..dc0e7c8d31f3 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -879,6 +879,8 @@ int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
long val = ucontrol->value.integer.value[0];
unsigned int i;
+ if (val < mc->min || val > mc->max)
+ return -EINVAL;
if (invert)
val = max - val;
val &= mask;
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-24 15:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20220124153253.3548853-1-broonie@kernel.org>
2022-01-24 15:32 ` [PATCH v1 1/3] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw() Mark Brown
2022-01-24 15:32 ` [PATCH v1 2/3] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx() Mark Brown
2022-01-24 15:32 ` [PATCH v1 3/3] ASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx() Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).