Linux LED subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andrei Aldea" <andrei1998@gmail.com>
Cc: lee@kernel.org, dmitry.torokhov@gmail.com,
	linux-input@vger.kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH 02/15] HID: hid-oxp: validate input report lengths before decoding
Date: Thu, 10 Sep 2026 03:34:14 +0000	[thread overview]
Message-ID: <20260910033414.C167D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910032115.28669-3-andrei1998@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Shared driver state variables are concurrently modified from atomic context and read from process context without protection, enabling a TOCTOU out-of-bounds read.
--

commit c83e5978640f43b909fcea30940f12727c190fcd
Author: Andrei Aldea <andrei1998@gmail.com>
Subject: HID: hid-oxp: validate input report lengths before decoding

This commit adds length checks to ensure short USB reports do not result in
out-of-bounds reads when decoding RGB status and printing debug information.

> diff --git a/drivers/hid/hid-oxp.c b/drivers/hid/hid-oxp.c
> index 3f2be8059ddb1..0c895bd778bbf 100644
> --- a/drivers/hid/hid-oxp.c
> +++ b/drivers/hid/hid-oxp.c
[ ... ]
> @@ -404,6 +411,8 @@ static int oxp_hid_raw_event_gen_2(struct hid_device *hdev,
>  
>  	if (data[3] != OXP_GET_PROPERTY)
>  		return 0;
> +	if (size < sizeof(*rgb_rep))
> +		return 0;
>  
>  	rgb_rep = (struct oxp_gen_2_rgb_report *)data;
>  	/* Ensure we save monocolor as the list value */

[Severity: High]
This isn't a bug introduced by this patch, but can the lockless assignment of
drvdata.rgb_effect here cause a Time-Of-Check to Time-Of-Use (TOCTOU)
out-of-bounds read in effect_show()?

In drivers/hid/hid-oxp.c, oxp_hid_raw_event_gen_2() updates the effect
locklessly from the raw event handler:

	drvdata.rgb_effect = rgb_rep->effect == OXP_EFFECT_MONO_TRUE ?
			     OXP_EFFECT_MONO_LIST :
			     rgb_rep->effect;

Concurrently, a userspace process reading the effect sysfs attribute calls
effect_show(), which performs two separate lockless reads of
drvdata.rgb_effect:

static ssize_t effect_show(...)
{
    ...
	if (drvdata.rgb_effect >= ARRAY_SIZE(oxp_rgb_effect_text))
		return -EINVAL;

	return sysfs_emit(buf, "%s\n", oxp_rgb_effect_text[drvdata.rgb_effect]);
}

If a malicious device sends continuous status event reports, can the value of
drvdata.rgb_effect change to an out-of-bounds value immediately after the
bounds check but before the array access? This would cause sysfs_emit() to
dereference a garbage pointer.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910032115.28669-1-andrei1998@gmail.com?part=2

  reply	other threads:[~2026-09-10  3:34 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  3:21 [PATCH 00/15] HID: hid-oxp: fix and extend X2-family controller support Andrei Aldea
2026-09-10  3:21 ` [PATCH 02/15] HID: hid-oxp: validate input report lengths before decoding Andrei Aldea
2026-09-10  3:34   ` sashiko-bot [this message]
2026-09-10 20:04   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 03/15] HID: hid-oxp: retain fractional brightness when reading RGB status Andrei Aldea
2026-09-10  3:29   ` sashiko-bot
2026-09-10 20:05   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 04/15] HID: hid-oxp: reject invalid Gen2 RGB status values Andrei Aldea
2026-09-10  3:32   ` sashiko-bot
2026-09-10 20:06   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 05/15] HID: hid-oxp: fix multicolor LED intensity scaling Andrei Aldea
2026-09-10  3:33   ` sashiko-bot
2026-09-10 20:07   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 06/15] HID: hid-oxp: serialize complete RGB updates Andrei Aldea
2026-09-10  3:32   ` sashiko-bot
2026-09-10 20:07   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 07/15] HID: hid-oxp: select brightness policy for the new RGB effect Andrei Aldea
2026-09-10  3:33   ` sashiko-bot
2026-09-10 20:11   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 08/15] HID: hid-oxp: stop configuration work during teardown Andrei Aldea
2026-09-10  3:32   ` sashiko-bot
2026-09-10 20:12   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 09/15] HID: hid-oxp: keep configuration state per HID interface Andrei Aldea
2026-09-10  3:35   ` sashiko-bot
2026-09-10 20:13   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 10/15] HID: hid-oxp: handle controller reinitialization across suspend Andrei Aldea
2026-09-10  3:34   ` sashiko-bot
2026-09-10 20:14   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 11/15] HID: hid-oxp: group declarations and protocol definitions Andrei Aldea
2026-09-10  3:40   ` sashiko-bot
2026-09-10 20:15   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 13/15] HID: hid-oxp: represent RGB LEDs with a common array Andrei Aldea
2026-09-10  3:44   ` sashiko-bot
2026-09-10 20:17   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 14/15] HID: hid-oxp: add Gen3 joystick ring RGB support Andrei Aldea
2026-09-10  3:43   ` sashiko-bot
2026-09-10 20:19   ` Derek J. Clark
2026-09-10  3:21 ` [PATCH 15/15] HID: hid-oxp: add X2 auxiliary RGB zones Andrei Aldea
2026-09-10  3:44   ` sashiko-bot
2026-09-10 20:20   ` Derek J. Clark
2026-09-10 20:24 ` [PATCH 00/15] HID: hid-oxp: fix and extend X2-family controller support Derek J. Clark

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=20260910033414.C167D1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=andrei1998@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-leds@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox