From: Arnav Kapoor <kapoorarnav43@gmail.com>
To: Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Daniel Baluta <daniel.baluta@nxp.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.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>,
sound-open-firmware@alsa-project.org,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Arnav Kapoor <kapoorarnav43@gmail.com>
Subject: [PATCH 4/4] ASoC: SOF: control: reject out-of-range enum values
Date: Tue, 17 Nov 2026 16:29:50 +0530 [thread overview]
Message-ID: <20261117105953.188645-5-kapoorarnav43@gmail.com> (raw)
In-Reply-To: <20261117105953.188645-1-kapoorarnav43@gmail.com>
snd_sof_enum_put() passes the item indexes from user space to the IPC
enum_put() op unchecked, and the IPC3 and IPC4 ops store them as they
are and send them to the DSP. With the IPC4 sof-hda-generic-2ch.tplg on
a Tiger Lake laptop, "Dmic0 Capture TDFB angle set enum" has 13 items
but accepts 13 and 0xffffffff, and reads them back. The ALSA mixer-test
selftest reports this as a write_invalid failure.
Reject indexes past the last item, as snd_soc_put_enum_double() does.
Fixes: c3078f539704 ("ASoC: SOF: Add Sound Open Firmware KControl support")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
sound/soc/sof/control.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
index a36c4c1d4505..aa02376d61e6 100644
--- a/sound/soc/sof/control.c
+++ b/sound/soc/sof/control.c
@@ -141,6 +141,11 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
struct snd_soc_component *scomp = scontrol->scomp;
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg);
+ unsigned int i;
+
+ for (i = 0; i < scontrol->num_channels; i++)
+ if (ucontrol->value.enumerated.item[i] >= se->items)
+ return -EINVAL;
if (tplg_ops && tplg_ops->control && tplg_ops->control->enum_put)
return tplg_ops->control->enum_put(scontrol, ucontrol);
--
2.53.0
next prev parent reply other threads:[~2026-11-17 11:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 10:59 [PATCH 0/4] ASoC: SOF: control: fix volume, switch and enum value handling Arnav Kapoor
2026-11-17 10:59 ` [PATCH 1/4] ASoC: SOF: control: reject out-of-range volume values Arnav Kapoor
2026-11-17 10:59 ` [PATCH 2/4] ASoC: SOF: control: reject invalid switch values Arnav Kapoor
2026-11-17 10:59 ` [PATCH 3/4] ASoC: SOF: report volume changes in mixer steps Arnav Kapoor
2026-11-17 10:59 ` Arnav Kapoor [this message]
2026-11-17 12:24 ` [PATCH 0/4] ASoC: SOF: control: fix volume, switch and enum value handling HyeongJun An
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261117105953.188645-5-kapoorarnav43@gmail.com \
--to=kapoorarnav43@gmail.com \
--cc=broonie@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=ranjani.sridharan@linux.intel.com \
--cc=sound-open-firmware@alsa-project.org \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®