From: Benjamin Tissoires <bentiss@kernel.org>
To: Lee Jones <lee@kernel.org>
Cc: David Rheinsberg <david@readahead.eu>,
Jiri Kosina <jikos@kernel.org>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 1/1] HID: uhid: Fix out-of-bounds write caused by raw events mismanagement
Date: Sat, 21 Feb 2026 14:03:02 +0100 [thread overview]
Message-ID: <aZmsTQeeGf26FqvY@plouf> (raw)
In-Reply-To: <20260211164025.171242-1-lee@kernel.org>
On Feb 11 2026, Lee Jones wrote:
> Since the report ID is located within the data buffer, overwriting it
> would mean that any subsequent matching could cause a disparity in
> assumed allocated buffer size. This in turn could trivially result in
> an out-of-bounds condition. To mitigate this issue, let's refuse to
> overwrite a given report's data area if the ID in get_report_reply
> doesn't match.
That's a strong assumption and a breakage of the userspace FWIW. The CI
is now full of errors:
https://gitlab.freedesktop.org/bentiss/hid/-/commits/for-7.0/upstream-fixes
It is pretty common to allocate the buffer and not initialize it in
get_report operations.
It was a bad API choice to have rnum and data[0] for all HID requests
(internally, externally), but we should stick to it. The CI breakage in
itself is not a big issue TBH, but if it breaks here, it will probably
break existing users.
Cheers,
Benjamin
>
> Cc: stable@vger.kernel.org
> Fixes: fcfcf0deb89ec ("HID: uhid: implement feature requests")
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
> drivers/hid/uhid.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
> index 21a70420151e..a0ee4e86656f 100644
> --- a/drivers/hid/uhid.c
> +++ b/drivers/hid/uhid.c
> @@ -262,6 +262,10 @@ static int uhid_hid_get_report(struct hid_device *hid, unsigned char rnum,
> req = &uhid->report_buf.u.get_report_reply;
> if (req->err) {
> ret = -EIO;
> + } else if (rnum != req->data[0]) {
> + hid_err(hid, "Report ID mismatch - refusing to overwrite the data buffer\n");
> + ret = -EINVAL;
> + goto unlock;
> } else {
> ret = min3(count, (size_t)req->size, (size_t)UHID_DATA_MAX);
> memcpy(buf, req->data, ret);
> --
> 2.53.0.273.g2a3d683680-goog
>
next prev parent reply other threads:[~2026-02-21 13:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-11 16:40 [PATCH 1/1] HID: uhid: Fix out-of-bounds write caused by raw events mismanagement Lee Jones
2026-02-21 9:49 ` Jiri Kosina
2026-02-21 13:03 ` Benjamin Tissoires [this message]
2026-02-21 19:46 ` Jiri Kosina
2026-02-24 8:42 ` Jiri Kosina
2026-02-24 15:57 ` Benjamin Tissoires
2026-02-24 16:12 ` Jiri Kosina
2026-02-26 11:18 ` Lee Jones
2026-02-26 12:22 ` Benjamin Tissoires
2026-02-26 14:08 ` Lee Jones
2026-02-26 15:51 ` Benjamin Tissoires
2026-02-26 16:23 ` Lee Jones
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=aZmsTQeeGf26FqvY@plouf \
--to=bentiss@kernel.org \
--cc=david@readahead.eu \
--cc=jikos@kernel.org \
--cc=lee@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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