From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: tiwai@suse.de
Cc: linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
perex@perex.cz, sreekuttan2156239@gmail.com, tiwai@suse.com
Subject: Re: [PATCH v3] ALSA: control: Validate element info in compat ioctl
Date: Tue, 10 Nov 2026 16:05:10 +0000 [thread overview]
Message-ID: <20261110160510.2697-1-sreekuttan2156239@gmail.com> (raw)
In-Reply-To: <87y0b1ug39.wl-tiwai@suse.de>
Hi Takashi,
The validation in snd_ctl_elem_write() happens too late. Before calling
snd_ctl_elem_write(), the compat handler calls copy_ctl_value_from_user(), which
uses the type and count returned by get_ctl_type() to determine how many values to copy.
If the control's info callback returns an invalid count, the integer and boolean paths
can access beyond the fixed-size integer value array. Other paths can also calculate a
copy size larger than the available kernel buffer.
The read path has a similar issue. It uses the same type and count when copying the values
back to userspace, which can result in an out-of-bounds read from the kernel buffer.
So, validation in snd_ctl_elem_write() cannot prevent these problems because the unsafe
accesses can happen before it is called.
Using __snd_ctl_elem_info() in get_ctl_type() ensures that the type and count are validated
before they are used by the compat handlers. It also reuses the existing element ID handling
and access checks.
Therefore, I think this validation is necessary.
Best regards,
Sreeraj
prev parent reply other threads:[~2026-11-10 16:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 14:12 [PATCH] " Sreeraj S Kurup
2026-11-08 16:09 ` [PATCH v2] " Sreeraj S Kurup
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 [this message]
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=20261110160510.2697-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®