From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: tiwai@suse.de, perex@perex.cz, tiwai@suse.com
Cc: linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Subject: [PATCH] ALSA: control: Validate element info in compat ioctl
Date: Sun, 8 Nov 2026 14:12:19 +0000 [thread overview]
Message-ID: <20261108141219.7655-1-sreekuttan2156239@gmail.com> (raw)
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, this code 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.
An invalid type or an element count larger than the supported
limit can cause these handlers to access memory outside the
expected buffer boundaries.
Call snd_ctl_check_elem_info() after the info callback to
validate the returned type and count before using them.
This keeps the compat ioctl path from using invalid control
metadata when accessing its value buffers.
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
sound/core/control_compat.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index 87f7ad5ab739..cad00d4aa204 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -183,6 +183,10 @@ 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) {
+ err = snd_ctl_check_elem_info(card, info);
+ if (err < 0)
+ return err;
+
err = info->type;
*countp = info->count;
}
--
2.55.0
next reply other threads:[~2026-11-08 14:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 14:12 Sreeraj S Kurup [this message]
2026-11-08 16:09 ` [PATCH v2] " Sreeraj S Kurup
2026-11-08 17:25 ` [PATCH v3] " 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=20261108141219.7655-1-sreekuttan2156239@gmail.com \
--to=sreekuttan2156239@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--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
all inboxes | Powered by JetHome®