All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [PATCH 2/9] HID: core: Fix GET_REPORT input processing for unnumbered reports
Date: Tue, 13 Oct 2026 04:00:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-168952@kernel.org> (raw)
In-Reply-To: <20261012-hid-core-report-validation-v1-2-e0dd5cb60b2e@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hid: core: uhid unnumbered GET_REPORT payload truncation
--

commit c28ca1033fab3989e7f3d67f52364f0621a32b6d
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>

HID: core: Fix GET_REPORT input processing for unnumbered reports

This commit offsets the buffer and deducts the dummy report ID from the length
when forwarding unnumbered reports to the input layer in __hid_request.

> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index ec7c2860c93ef..a33e864a25f92 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -2033,8 +2033,13 @@ int __hid_request(struct hid_device *hid, struct hid_report *report,
>  		return ret;
>  	}
>  
> -	if (reqtype == HID_REQ_GET_REPORT)
> -		hid_input_report(hid, report->type, buf, ret, 0);
> +	if (reqtype == HID_REQ_GET_REPORT) {
> +		if (report->id == 0)
> +			ret--;
> +
> +		if (ret > 0)
> +			hid_input_report(hid, report->type, data_buf, ret, 0);

[Severity: High]
Does this unconditional stripping of the first byte truncate the payload for
unnumbered reports on uhid devices?

The commit message notes that low-level transport drivers store a dummy
report ID of 0 for unnumbered reports. While true for drivers like usbhid
and i2c-hid, uhid handles this differently.

According to the uhid ABI, userspace replies to UHID_GET_REPORT via
UHID_GET_REPORT_REPLY and places the exact raw payload in req->data without
a dummy report ID.

In drivers/hid/uhid.c:uhid_hid_get_report(), the payload is copied exactly
as provided by userspace:

	ret = min3(count, (size_t)req->size, (size_t)UHID_DATA_MAX);
	memcpy(buf, req->data, ret);

Since uhid does not prepend a dummy 0 byte, decrementing ret and passing
data_buf (which was advanced by one earlier in __hid_request) to
hid_input_report() appears to strip the first byte of the actual payload,
corrupting the data.

> +	}
>  
>  	return 0;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012-hid-core-report-validation-v1-0-e0dd5cb60b2e@gmail.com?part=2

  reply	other threads:[~2026-10-13  4:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  3:42 [PATCH 0/9] HID: Hardening report validation and unnumbered report handling Dmitry Torokhov
2026-10-13  3:42 ` [PATCH 1/9] Bluetooth: HIDP: Fix GET_REPORT and SET_REPORT for unnumbered reports Dmitry Torokhov
2026-10-13  3:56   ` HID: Hardening report validation and unnumbered report handling bluez.test.bot
2026-10-13  3:57   ` [PATCH 1/9] Bluetooth: HIDP: Fix GET_REPORT and SET_REPORT for unnumbered reports sashiko-bot
2026-10-13  3:42 ` [PATCH 2/9] HID: core: Fix GET_REPORT input processing " Dmitry Torokhov
2026-10-13  4:00   ` sashiko-bot [this message]
2026-10-13  3:42 ` [PATCH 3/9] HID: core: Reject mixing numbered and " Dmitry Torokhov
2026-10-13  3:42 ` [PATCH 4/9] HID: core: Validate GET_REPORT report ID centrally Dmitry Torokhov
2026-10-13  4:00   ` sashiko-bot
2026-10-13  3:42 ` [PATCH 5/9] HID: i2c-hid: Drop redundant report ID validation Dmitry Torokhov
2026-10-13  3:42 ` [PATCH 6/9] HID: goodix-spi: " Dmitry Torokhov
2026-10-13  3:42 ` [PATCH 7/9] HID: intel-thc-hid: Drop redundant report ID validation in quicki2c Dmitry Torokhov
2026-10-13  3:57   ` sashiko-bot
2026-10-13  3:42 ` [PATCH 8/9] HID: multitouch: Drop redundant report ID validation in mt_get_feature Dmitry Torokhov
2026-10-13  3:42 ` [PATCH 9/9] HID: playstation: Drop redundant report ID validation in ps_get_report Dmitry Torokhov

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-168952@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.