All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sriman Achanta" <srimanachanta@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v6 2/9] HID: steelseries: Split Arctis headset driver into separate module
Date: Thu, 09 Jul 2026 03:34:36 +0000	[thread overview]
Message-ID: <20260709033437.216F41F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709032316.1908460-3-68172138+srimanachanta@users.noreply.github.com>

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

Pre-existing issues:
- [High] If `steelseries_headset_battery_register()` fails, the probe function ignores the error and continues. This leaves `sd->battery` as an `ERR_PTR` and `sd->battery_work` uninitialized. Later, incoming events in `steelseries_arctis_raw_event()` call `power_supply_changed(sd->battery)` and `schedule_delayed_work(&sd->battery_work, ...)`, which will dereference the error pointer and operate on an uninitialized work structure, causing a kernel panic. Similarly, `steelseries_arctis_remove()` calls `cancel_delayed_work_sync(&sd->battery_work)` which will also crash.
- [High] The driver calls `hid_hw_start()` and `hid_hw_open()` before calling `steelseries_headset_battery_register()`. `hid_hw_open()` starts the URB polling, enabling asynchronous hardware events to trigger `steelseries_arctis_raw_event()` immediately. At this point, `sd->battery` is still `NULL` and `sd->battery_work` is uninitialized. If a report is received during this race window, the event handler will pass a `NULL` pointer to `power_supply_changed()` and call `schedule_delayed_work()` on uninitialized work, resulting in an immediate kernel panic.
- [High] Missing length check on the report descriptor before accessing payload offsets in `steelseries_is_vendor_usage_page()`. The function unconditionally accesses `hdev->rdesc[0]`, `hdev->rdesc[1]`, and `hdev->rdesc[2]`. Although `usbhid_parse()` guarantees `rsize > 0`, it does not guarantee `rsize >= 3`. If a malformed USB device presents a 1- or 2-byte descriptor, this reads out of bounds of the kmalloc'd `rdesc` buffer.
--

--- Patch [2]: [PATCH v6 2/9] HID: steelseries: Split Arctis headset driver into separate module ---
commit 5114a40b6cbe9d3f2ea95a54f76bb50da5fb5d42
Author: Sriman Achanta <srimanachanta@gmail.com>

HID: steelseries: Split Arctis headset driver into separate module

This patch moves the Arctis headset code from hid-steelseries.c into a
new hid-steelseries-arctis.c module. It separates the headset handling
from the SRWS1 racing wheel code.

> diff --git a/drivers/hid/hid-steelseries-arctis.c b/drivers/hid/hid-steelseries-arctis.c
> new file mode 100644
> index 0000000000000..079504e6932a1
> --- /dev/null
> +++ b/drivers/hid/hid-steelseries-arctis.c

[ ... ]

> +static bool steelseries_is_vendor_usage_page(struct hid_device *hdev, uint8_t usage_page)
> +{
> +	return hdev->rdesc[0] == 0x06 &&
> +		hdev->rdesc[1] == usage_page &&
> +		hdev->rdesc[2] == 0xff;
> +}

[Severity: High]
This is a pre-existing issue, but does this function properly validate
the size of the report descriptor before accessing it?

The function unconditionally accesses the first 3 bytes of hdev->rdesc.
Although hid_parse() guarantees rsize > 0, if a malformed USB device
presents a 1- or 2-byte descriptor, wouldn't this read out of bounds
of the allocated rdesc buffer?

[ ... ]

> +static int steelseries_arctis_probe(struct hid_device *hdev, const struct hid_device_id *id)
> +{

[ ... ]

> +	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
> +	if (ret)
> +		return ret;
> +
> +	ret = hid_hw_open(hdev);
> +	if (ret)
> +		return ret;

[Severity: High]
This isn't a bug introduced by this patch, but does calling hid_hw_open()
before steelseries_headset_battery_register() introduce a race condition?

Calling hid_hw_open() starts the hardware polling, which enables
asynchronous events to immediately trigger steelseries_arctis_raw_event().
At this point, sd->battery is still NULL and sd->battery_work is
uninitialized.

If a report is received during this race window, would the event handler
pass a NULL pointer to power_supply_changed() and schedule uninitialized
work, resulting in a crash?

> +
> +	if (steelseries_headset_battery_register(sd) < 0)
> +		hid_err(sd->hdev,
> +			"Failed to register battery for headset\n");
> +
> +	return ret;
> +}

[Severity: High]
This is a pre-existing issue, but is it safe to ignore the return value
of steelseries_headset_battery_register() here?

If registration fails (for example, due to a duplicate name), the probe
function prints an error but still succeeds. This leaves sd->battery as
an ERR_PTR and sd->battery_work uninitialized.

If a subsequent event is processed by steelseries_arctis_raw_event(),
it will call power_supply_changed() and dereference the error pointer.
Furthermore, steelseries_arctis_remove() will call
cancel_delayed_work_sync() on an uninitialized structure, which can
crash the workqueue.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260709032316.1908460-1-68172138+srimanachanta@users.noreply.github.com?part=2

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

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09  3:23 [PATCH v6 0/9] HID: steelseries: split out Arctis driver and add Nova 5X/Nova 7 support Sriman Achanta
2026-07-09  3:23 ` [PATCH v6 1/9] HID: steelseries: Fix ARCTIS_1_X device mislabeling Sriman Achanta
2026-07-09  3:36   ` sashiko-bot
2026-07-09  3:23 ` [PATCH v6 2/9] HID: steelseries: Split Arctis headset driver into separate module Sriman Achanta
2026-07-09  3:34   ` sashiko-bot [this message]
2026-07-09  3:23 ` [PATCH v6 3/9] HID: steelseries: Inline and simplify SRWS1 wheel driver Sriman Achanta
2026-07-09  3:23 ` [PATCH v6 4/9] HID: steelseries: Refactor Arctis driver to use device_info framework Sriman Achanta
2026-07-09  3:33   ` sashiko-bot
2026-07-09  3:23 ` [PATCH v6 5/9] HID: steelseries: Report POWER_SUPPLY_STATUS_FULL when full Sriman Achanta
2026-07-09  3:23 ` [PATCH v6 6/9] HID: steelseries: Correct Arctis 9 battery calibration range Sriman Achanta
2026-07-09  3:23 ` [PATCH v6 7/9] HID: steelseries: Manage battery lifetime with refcounting Sriman Achanta
2026-07-09  3:38   ` sashiko-bot
2026-07-09  3:23 ` [PATCH v6 8/9] HID: steelseries: Add async status interface support Sriman Achanta
2026-07-09  3:37   ` sashiko-bot
2026-07-09  3:23 ` [PATCH v6 9/9] HID: steelseries: Add support for Arctis Nova 5X and Nova 7 families Sriman Achanta
2026-07-10 12:02 ` [PATCH v6 0/9] HID: steelseries: split out Arctis driver and add Nova 5X/Nova 7 support Bastien Nocera

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=20260709033437.216F41F000E9@smtp.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=srimanachanta@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.