From: Takashi Iwai <tiwai@suse.de>
To: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
perex@perex.cz, tiwai@suse.com, tiwai@suse.de
Subject: Re: [PATCH v3] ALSA: control: Validate element info in compat ioctl
Date: Tue, 10 Nov 2026 11:38:02 +0100 [thread overview]
Message-ID: <87y0b1ug39.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261108172501.2887-1-sreekuttan2156239@gmail.com>
On Sun, 08 Nov 2026 18:25:01 +0100,
Sreeraj S Kurup wrote:
>
> The compat ioctl code calls the control's info callback directly
> in get_ctl_type() to get the element type and count.
>
> Unlike the normal control info path, it does not validate the
> information returned by the callback.
>
> The compat read and write handlers use the returned type and
> count to access fixed-size value buffers and calculate copy
> sizes. Invalid values could cause these handlers to access
> memory outside the expected buffer boundaries.
>
> Use __snd_ctl_elem_info() to get and validate the control
> information before using the type and count. This also applies
> the same element ID handling and access checks as the normal
> control info path.
>
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
> ---
> v3:
> - Use __snd_ctl_elem_info() instead of duplicating the
> element ID handling, access checks, and validation.
> v2:
> - Rebuild the element ID before validation
> - Set the control access flags and respect
> SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK
>
> sound/core/control_compat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
> index 87f7ad5ab739..a9ee5ef30c51 100644
> --- a/sound/core/control_compat.c
> +++ b/sound/core/control_compat.c
> @@ -181,7 +181,7 @@ static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,
> if (info == NULL)
> return -ENOMEM;
> info->id = *id;
> - err = kctl->info(kctl, info);
> + err = __snd_ctl_elem_info(card, kctl, info, NULL);
> if (err >= 0) {
> err = info->type;
> *countp = info->count;
Isn't such a sanity check done in anyway at snd_ctl_elem_write() call?
The OOB copy from/to user-space would be just -EFAULT as expected.
It's not too bad to call __snd_ctl_elem_info(), but I'd like to be
sure whether it's really needed.
thanks,
Takashi
next prev parent reply other threads:[~2026-11-10 10:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 14:12 [PATCH] ALSA: control: Validate element info in compat ioctl Sreeraj S Kurup
2026-11-08 14:32 ` sashiko-bot
2026-11-08 16:09 ` [PATCH v2] " Sreeraj S Kurup
2026-11-08 16:25 ` sashiko-bot
2026-11-08 17:25 ` [PATCH v3] " Sreeraj S Kurup
2026-11-10 10:38 ` Takashi Iwai [this message]
2026-11-10 16:05 ` Sreeraj S Kurup
2026-11-11 8:56 ` Takashi Iwai
2026-11-11 10:58 ` Sreeraj S Kurup
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=87y0b1ug39.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=sreekuttan2156239@gmail.com \
--cc=tiwai@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.