All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sreeraj S Kurup" <sreekuttan2156239@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v2] ALSA: control: Validate element info in compat ioctl
Date: Sun, 08 Nov 2026 16:25:36 +0000	[thread overview]
Message-ID: <sashiko-outbox-203877@kernel.org> (raw)
In-Reply-To: <20261108160925.8774-1-sreekuttan2156239@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ALSA: control: get_ctl_type() duplicates __snd_ctl_elem_info()
--

commit e7c5b72d570147881e5fc3076a50929183e5bf55
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

ALSA: control: Validate element info in compat ioctl

This commit validates control element info in get_ctl_type() for compat
ioctls by rebuilding the element ID, setting the control access flags,
and calling snd_ctl_check_elem_info() when validation is not skipped.

> diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
> index 87f7ad5ab7391..0c1b80c856f26 100644
> --- a/sound/core/control_compat.c
> +++ b/sound/core/control_compat.c
> @@ -169,6 +169,8 @@ static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,
>  			int *countp)
>  {
>  	struct snd_kcontrol *kctl;
> +	struct snd_kcontrol_volatile *vd;
> +	unsigned int index_offset;
>  	int err;
>  
>  	guard(rwsem_read)(&card->controls_rwsem);
> @@ -183,6 +185,17 @@ static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,
>  	info->id = *id;
>  	err = kctl->info(kctl, info);
>  	if (err >= 0) {
> +		index_offset = snd_ctl_get_ioff(kctl, &info->id);
> +		vd = &kctl->vd[index_offset];
> +		snd_ctl_build_ioff(&info->id, kctl, index_offset);
> +		info->access = vd->access;
> +
> +		if (!snd_ctl_skip_validation(info)) {
> +			err = snd_ctl_check_elem_info(card, info);
> +			if (err < 0)
> +				return err;
> +		}
> +
>  		err = info->type;
>  		*countp = info->count;
>  	}

[Severity: Low]
Could get_ctl_type() call __snd_ctl_elem_info(card, kctl, info, NULL)
instead of open-coding this sequence?

sound/core/control_compat.c is included directly by sound/core/control.c,
where __snd_ctl_elem_info() already invokes kctl->info(), rebuilds
info->id, sets info->access, and runs snd_ctl_check_elem_info(), just as
snd_ctl_elem_read() and snd_ctl_elem_write() do when passing a NULL
snd_ctl_file pointer.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261108160925.8774-1-sreekuttan2156239@gmail.com?part=1

  reply	other threads:[~2026-11-08 16:25 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 [this message]
2026-11-08 17:25 ` [PATCH v3] " Sreeraj S Kurup
2026-11-10 10:38   ` Takashi Iwai
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=sashiko-outbox-203877@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sreekuttan2156239@gmail.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.