All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andrei Aldea" <andrei1998@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-leds@vger.kernel.org,
	linux-input@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH 14/15] HID: hid-oxp: add Gen3 joystick ring RGB support
Date: Thu, 10 Sep 2026 03:43:30 +0000	[thread overview]
Message-ID: <20260910034331.272C11F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910032115.28669-15-andrei1998@gmail.com>

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

Pre-existing issues:
- [High] Invalid cast to usb_interface when bound to non-USB parent.
--

commit 6855a3cf4aaf330705ad5f598a86f86db5c13fc3
Author: Andrei Aldea <andrei1998@gmail.com>

    HID: hid-oxp: add Gen3 joystick ring RGB support
    
    Select the X2/Gen3 RGB protocol early for the ONEXPLAYER 3 and X2 Mini Pro.
    These controllers share the Gen2 HID usage page but require a 59-byte
    color payload and writes to ring zones 1, 2 and 7. Keep the Gen1 55-byte
    and legacy Gen2 57-byte color builders separate and unchanged.

> diff --git a/drivers/hid/hid-oxp.c b/drivers/hid/hid-oxp.c
> index 55f8b4773e334..9a46602238aa3 100644
> --- a/drivers/hid/hid-oxp.c
> +++ b/drivers/hid/hid-oxp.c

[ ... ]

> @@ -1868,6 +2199,7 @@ static int oxp_cfg_probe(struct hid_device *hdev, u16 up,
>  		return -ENOMEM;
>  
>  	cfg->hdev = hdev;
> +	cfg->x2_rgb = quirks && quirks->x2_rgb;

[Severity: High]
This is a pre-existing issue, but does oxp_is_cfg_interface() perform an
unsafe cast of the parent device?

During probe, before oxp_cfg_probe() is called, the driver checks:

	if (!oxp_is_cfg_interface(hdev, quirks))
		return 0;

Looking at oxp_is_cfg_interface(), it uses:

	if (hdev->bus != BUS_USB)
		return false;

	intf = to_usb_interface(hdev->dev.parent);
	return intf->cur_altsetting->desc.bInterfaceNumber ==
	       quirks->cfg_interface_num;

Could a userspace program create a UHID device spoofing the BUS_USB bus type
and target device IDs? If so, the hdev->bus != BUS_USB check would pass, but
the parent device would be a UHID device rather than a USB interface. 

Does unconditionally casting a non-USB parent device to struct
usb_interface lead to an out-of-bounds memory read or kernel panic when
accessing intf->cur_altsetting->desc.bInterfaceNumber? Should this code use
hid_is_usb(hdev) to safely guard the cast?

>  	mutex_init(&cfg->cfg_mutex);
>  	mutex_init(&cfg->rgb_mutex);
>  	spin_lock_init(&cfg->rgb_reply_lock);

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

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

Thread overview: 30+ 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 01/15] HID: hid-oxp: fix default M1 and M2 key mappings 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
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  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  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  3:21 ` [PATCH 06/15] HID: hid-oxp: serialize complete RGB updates Andrei Aldea
2026-09-10  3:32   ` sashiko-bot
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  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  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  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  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  3:21 ` [PATCH 12/15] HID: hid-oxp: support three-page button maps on X2 controllers Andrei Aldea
2026-09-10  3:40   ` sashiko-bot
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  3:21 ` [PATCH 14/15] HID: hid-oxp: add Gen3 joystick ring RGB support Andrei Aldea
2026-09-10  3:43   ` sashiko-bot [this message]
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

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=20260910034331.272C11F000FF@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 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.