From: sashiko-bot@kernel.org
To: "Vicki Pfau" <vi@endrift.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v4 5/6] HID: steam: Clean up locking
Date: Fri, 07 Aug 2026 23:53:45 +0000 [thread overview]
Message-ID: <20260807235345.A1AEA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807232339.2799205-6-vi@endrift.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Missing `report_mutex` acquisition in `steam_register` causes concurrent HID report sequence corruption.
Pre-existing issues:
- [High] Use-After-Free of `steam->client_hdev` in `steam_raw_event` due to incorrect teardown sequence.
--
--- Patch [5]: [PATCH v4 5/6] HID: steam: Clean up locking ---
commit b7298af16f52c40e58c726cf4668c6523e3cddaf
Author: Vicki Pfau <vi@endrift.com>
Date: Fri Aug 7 23:23:36 2026 +0000
HID: steam: Clean up locking
This cleans up several issues with locking behavior, including RCU accesses
not being guarded behind a lock.
> diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
> index d95296b28f92b..95e252665351c 100644
> --- a/drivers/hid/hid-steam.c
> +++ b/drivers/hid/hid-steam.c
[ ... ]
> @@ -633,7 +634,6 @@ static int steam_exchange_report(struct steam_device *steam, u8 *cmd, int csize,
> unsigned int retries = 5;
> int ret;
>
> - guard(mutex)(&steam->report_mutex);
> do {
> ret = steam_send_report(steam, cmd, csize);
> if (ret < 0)
[ ... ]
> @@ -1380,13 +1376,16 @@ static int steam_register(struct steam_device *steam)
> {
> int ret;
>
> + mutex_lock(&steam->registration_mutex);
> /*
> * This function can be called several times in a row with the
> * wireless adaptor, without steam_unregister() between them, because
> * another client send a get_connection_status command, for example.
> */
> - if (steam->registered)
> + if (steam->registered) {
> + mutex_unlock(&steam->registration_mutex);
> return 0;
> + }
>
> /*
> * Unlikely, but getting the serial could fail, and it is not so
[Severity: High]
Does this leave the HID report sequence unprotected during device registration?
Because the patch removes the report_mutex from steam_exchange_report() and
steam_set_lizard_mode(), their callers are now expected to hold it. However,
steam_register() doesn't acquire report_mutex before it continues execution
and calls steam_get_serial() (which calls steam_exchange_report()) and
steam_set_lizard_mode().
For example, a wireless connection immediately after USB enumeration triggers
steam_raw_event() -> steam_do_connect_event(), which queues
steam_work_connect_cb to call steam_register(). At the same time, the
original steam_probe() thread continues and calls steam_get_conn_status().
Since steam_register() lacks the report_mutex, its HID transmissions could
interleave with the internally-locked steam_get_conn_status() operations.
Can this lead to corrupted replies or matching a reply to the wrong request?
[ ... ]
> @@ -2470,6 +2466,7 @@ static int steam_raw_event(struct hid_device *hdev,
> if (!steam)
> return 0;
>
> + guard(spinlock_irqsave)(&steam->lock);
> if (steam->client_opened)
> hid_input_report(steam->client_hdev, report->type, data, size, 0);
>
[Severity: High]
This is a pre-existing issue, but could this lead to a use-after-free of
steam->client_hdev if an event arrives during teardown?
In steam_remove(), hid_destroy_device(steam->client_hdev) is called to
destroy the child HID device, but hid_hw_stop(hdev) is not called until the
very end of the function. This means hardware interrupts can still deliver
raw events.
If steam_raw_event() triggers after the child device is destroyed, but
before steam->client_opened is explicitly cleared under the lock in
steam_remove(), it will dereference the freed steam->client_hdev pointer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260807232339.2799205-1-vi@endrift.com?part=5
next prev parent reply other threads:[~2026-08-07 23:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 23:23 [PATCH v4 0/6] HID: steam: Add 2026 Steam Controller support Vicki Pfau
2026-08-07 23:23 ` [PATCH v4 1/6] HID: steam: Refactor registration Vicki Pfau
2026-08-07 23:36 ` sashiko-bot
2026-08-07 23:23 ` [PATCH v4 2/6] HID: steam: Initial 2026 Steam Controller support Vicki Pfau
2026-08-07 23:59 ` sashiko-bot
2026-08-07 23:23 ` [PATCH v4 3/6] HID: steam: Fix wording of connect/disconnect logs Vicki Pfau
2026-08-07 23:23 ` [PATCH v4 4/6] HID: steam: Don't set feature reports when disconnecting Vicki Pfau
2026-08-07 23:48 ` sashiko-bot
2026-08-07 23:23 ` [PATCH v4 5/6] HID: steam: Clean up locking Vicki Pfau
2026-08-07 23:53 ` sashiko-bot [this message]
2026-08-07 23:23 ` [PATCH v4 6/6] HID: steam: Zero out inputs when disabling gamepad mode Vicki Pfau
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=20260807235345.A1AEA1F000E9@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=vi@endrift.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox