From: Jaroslav Kysela <perex@perex.cz>
To: Takashi Iwai <tiwai@suse.de>, linux-sound@vger.kernel.org
Cc: Paul Menzel <pmenzel@molgen.mpg.de>,
Mark Brown <broonie@kernel.org>,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 3/5] ALSA: control: Apply sanity check of input values for user elements
Date: Fri, 14 Jun 2024 15:06:25 +0200 [thread overview]
Message-ID: <f7df8606-1697-4e82-bcdc-ef7b595ff83c@perex.cz> (raw)
In-Reply-To: <20240614124728.27901-4-tiwai@suse.de>
On 14. 06. 24 14:47, Takashi Iwai wrote:
> Although we have already a mechanism for sanity checks of input values
> for control writes, it's not applied unless the kconfig
> CONFIG_SND_CTL_INPUT_VALIDATION is set due to the performance reason.
> Nevertheless, it still makes sense to apply the check for user
> elements despite of its cost, as that's the only way to filter out the
> invalid values; the user controls are handled solely in ALSA core
> code, and there is no corresponding driver, after all.
>
> This patch enables the input value validation for user control
> elements no matter whether CONFIG_SND_CTL_INPUT_VALIDATION is set or
> not. The kselftest will be happier with this change, as the incorrect
> values will be bailed out now with errors.
>
> For other normal controls, the check is applied still only when
> CONFIG_SND_CTL_INPUT_VALIDATION is set.
>
> Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
> Closes: https://lore.kernel.org/r/1d44be36-9bb9-4d82-8953-5ae2a4f09405@molgen.mpg.de
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> sound/core/control.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/sound/core/control.c b/sound/core/control.c
> index fb0c60044f7b..50890983d7e2 100644
> --- a/sound/core/control.c
> +++ b/sound/core/control.c
> @@ -1317,7 +1317,8 @@ static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,
> snd_ctl_build_ioff(&control->id, kctl, index_offset);
> result = snd_power_ref_and_wait(card);
> /* validate input values */
> - if (IS_ENABLED(CONFIG_SND_CTL_INPUT_VALIDATION) && !result) {
> + if ((IS_ENABLED(CONFIG_SND_CTL_INPUT_VALIDATION) ||
> + (vd->access & SNDRV_CTL_ELEM_ACCESS_USER)) && !result) {
> struct snd_ctl_elem_info info;
The info structure for user elements may be used directly without this
intermediate variable for the validation. But it may be a possible future
improvement.
Jaroslav
--
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
next prev parent reply other threads:[~2024-06-14 13:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 12:47 [PATCH 0/5] ALSA: some driver fixes for control input validations Takashi Iwai
2024-06-14 12:47 ` [PATCH 1/5] ALSA: vmaster: Return error for invalid input values Takashi Iwai
2024-06-14 12:47 ` [PATCH 2/5] ALSA: hda: Return -EINVAL for invalid volume/switch inputs Takashi Iwai
2024-06-14 12:47 ` [PATCH 3/5] ALSA: control: Apply sanity check of input values for user elements Takashi Iwai
2024-06-14 13:06 ` Jaroslav Kysela [this message]
2024-06-14 14:25 ` Mark Brown
2024-06-14 12:47 ` [PATCH 4/5] kselftest/alsa: mixer-test: Skip write tests for volatile controls Takashi Iwai
2024-06-14 14:29 ` Mark Brown
2024-06-14 14:40 ` Takashi Iwai
2024-06-14 12:47 ` [PATCH 5/5] ALSA: chmap: Mark Channel Map controls as volatile Takashi Iwai
2024-06-14 13:06 ` [PATCH 0/5] ALSA: some driver fixes for control input validations Jaroslav Kysela
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=f7df8606-1697-4e82-bcdc-ef7b595ff83c@perex.cz \
--to=perex@perex.cz \
--cc=broonie@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=pmenzel@molgen.mpg.de \
--cc=tiwai@suse.de \
/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