From: sashiko-bot@kernel.org
To: "Tristan Madani" <tristmd@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH 6/8] HID: oxp: validate report size in raw_event callbacks
Date: Sun, 18 Oct 2026 21:48:24 +0000 [thread overview]
Message-ID: <sashiko-outbox-176413@kernel.org> (raw)
In-Reply-To: <20261018213754.1951187-7-tristmd@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] HID: oxp: unvalidated 64-byte read in oxp_hid_raw_event() dev_dbg()
--
commit 1f763db8177cf3b395303a0f7956ff3e6b99d798
Author: Tristan Madani <tristan@talencesecurity.com>
HID: oxp: validate report size in raw_event callbacks
This commit adds report size checks to oxp_hid_raw_event_gen_1() and
oxp_hid_raw_event_gen_2() before casting the report buffer to
struct oxp_gen_1_rgb_report and struct oxp_gen_2_rgb_report.
> diff --git a/drivers/hid/hid-oxp.c b/drivers/hid/hid-oxp.c
> index 1e691ebc1199e..af9f60d45bf29 100644
> --- a/drivers/hid/hid-oxp.c
> +++ b/drivers/hid/hid-oxp.c
> @@ -318,6 +318,9 @@ static int oxp_hid_raw_event_gen_1(struct hid_device *hdev,
> struct led_classdev_mc *led_mc = drvdata.led_mc;
> struct oxp_gen_1_rgb_report *rgb_rep;
>
> + if (size < sizeof(struct oxp_gen_1_rgb_report))
> + return 0;
> +
> if (data[1] != OXP_FID_GEN1_RGB_REPLY)
> return 0;
>
> @@ -391,6 +394,9 @@ static int oxp_hid_raw_event_gen_2(struct hid_device *hdev,
> struct led_classdev_mc *led_mc = drvdata.led_mc;
> struct oxp_gen_2_rgb_report *rgb_rep;
>
> + if (size < sizeof(struct oxp_gen_2_rgb_report))
> + return 0;
> +
> if (data[0] != OXP_FID_GEN2_STATUS_EVENT)
> return 0;
>
[Severity: Medium]
Can a short report still trigger an out-of-bounds read in the caller
oxp_hid_raw_event() before reaching these checks?
In drivers/hid/hid-oxp.c, __hid_input_report() invokes the driver's
raw_event callback oxp_hid_raw_event(), which runs dev_dbg() with
OXP_PACKET_SIZE (64) before dispatching to oxp_hid_raw_event_gen_1() or
oxp_hid_raw_event_gen_2():
drivers/hid/hid-oxp.c:oxp_hid_raw_event() {
u16 up = get_usage_page(hdev);
dev_dbg(&hdev->dev, "raw event data: [%*ph]\n", OXP_PACKET_SIZE, data);
switch (up) {
case GEN1_USAGE_PAGE:
return oxp_hid_raw_event_gen_1(hdev, report, data, size);
case GEN2_USAGE_PAGE:
return oxp_hid_raw_event_gen_2(hdev, report, data, size);
...
}
When a report with size < OXP_PACKET_SIZE is delivered (for example via a
short transfer, hid_bpf_input_report(), or __hid_request() where
hid_alloc_report_buf() allocates hid_report_len(report) + 7 +
(report->id == 0) bytes) and dynamic debugging or DEBUG is enabled, the
dev_dbg() call reads 64 bytes from data regardless of size.
Should the dev_dbg() call in oxp_hid_raw_event() pass size instead of
OXP_PACKET_SIZE (or validate size beforehand)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261018213754.1951187-1-tristmd@gmail.com?part=6
next prev parent reply other threads:[~2026-10-18 21:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 21:37 [PATCH 0/8] HID: validate report size in raw_event callbacks Tristan Madani
2026-10-18 21:37 ` [PATCH 1/8] HID: pxrc: validate report size in raw_event callback Tristan Madani
2026-10-18 21:37 ` [PATCH 2/8] HID: alps: validate report size in raw_event callbacks Tristan Madani
2026-10-18 21:45 ` sashiko-bot
2026-10-18 21:37 ` [PATCH 3/8] HID: mcp2200: validate report size in raw_event callback Tristan Madani
2026-10-18 21:37 ` [PATCH 4/8] HID: cougar: " Tristan Madani
2026-10-18 21:37 ` [PATCH 5/8] HID: zydacron: " Tristan Madani
2026-10-18 21:37 ` [PATCH 6/8] HID: oxp: validate report size in raw_event callbacks Tristan Madani
2026-10-18 21:48 ` sashiko-bot [this message]
2026-10-18 21:37 ` [PATCH 7/8] HID: cp2112: validate report size in raw_event callback Tristan Madani
2026-10-18 21:37 ` [PATCH 8/8] HID: prodikeys: " Tristan Madani
2026-10-18 21:44 ` sashiko-bot
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-176413@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tristmd@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.