From: sashiko-bot@kernel.org
To: "Vicki Pfau" <vi@endrift.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v5 02/11] HID: steam: Refactor and clean up report parsing
Date: Thu, 30 Jul 2026 04:52:36 +0000 [thread overview]
Message-ID: <20260730045237.2E7961F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260730041251.1659029-3-vi@endrift.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Works (`work_connect` and `rumble_work`) can be re-armed after they are cancelled during device removal, leading to a Use-After-Free.
--
--- Patch [2]: [PATCH v5 02/11] HID: steam: Refactor and clean up report parsing ---
commit b341becd37dc80cfee5384e2c463afc0e1624d32
Author: Vicki Pfau <vi@endrift.com>
HID: steam: Refactor and clean up report parsing
This switches from a parsing style where each button or axis is parsed
individually out of a report using !!(byte & BIT(x)) style. This commit
switches it to a mostly unified approach of defining a list of individual
mappings in an array and passing it to a function that handles all of the
extraction. Theoretically this is more lines, but in practice it results in
(subjectively) cleaner code. Some exceptions still need to be made for
things like handling the lizard mode toggle key, but in general there's a
lot less manual code.
> diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
> index a854d6360a0e3..75d6be0be0a29 100644
> --- a/drivers/hid/hid-steam.c
> +++ b/drivers/hid/hid-steam.c
> @@ -43,6 +43,7 @@
> #include <linux/rcupdate.h>
> #include <linux/delay.h>
> #include <linux/power_supply.h>
> +#include <linux/unaligned.h>
> #include "hid-ids.h"
>
> MODULE_DESCRIPTION("HID driver for Valve Steam Controller");
[ ... ]
[Severity: High]
This is a pre-existing issue, but while reviewing the driver's event handling
I noticed a potential use-after-free during device removal.
In steam_remove(), work_connect is cancelled before the hardware event
source is stopped:
steam_remove() {
...
cancel_work_sync(&steam->work_connect);
if (steam->quirks & STEAM_QUIRK_WIRELESS) {
hid_info(hdev, "Steam wireless receiver disconnected");
}
steam_unregister(steam);
hid_hw_stop(hdev);
}
If a wireless connect or disconnect report arrives after cancel_work_sync()
but before hid_hw_stop(), steam_do_connect_event() could process it:
steam_do_connect_event() {
...
if (changed && schedule_work(&steam->work_connect) == 0)
...
}
Could this re-arm the cancelled work, leading to it executing after the
devm-managed steam_device is freed? Would it be safer to call hid_hw_stop()
earlier in the function?
[Severity: High]
This is also a pre-existing issue, but I noticed a similar work queue ordering
issue in steam_unregister().
The rumble_work is cancelled before its producer, coalesce_rumble_work:
steam_unregister() {
...
cancel_work_sync(&steam->rumble_work);
cancel_delayed_work_sync(&steam->mode_switch);
cancel_delayed_work_sync(&steam->coalesce_rumble_work);
...
}
If coalesce_rumble_work fires during this window, its callback
steam_coalesce_rumble_cb() unconditionally calls
schedule_work(&steam->rumble_work).
Could this cause the rumble_work to be re-armed and subsequently execute on
freed memory? Would reversing the cancellation order prevent this race?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260730041251.1659029-1-vi@endrift.com?part=2
next prev parent reply other threads:[~2026-07-30 4:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 4:12 [PATCH v5 00/10] HID: steam: General cleanup and improvements Vicki Pfau
2026-07-30 4:12 ` [PATCH v5 01/11] HID: steam: Update documentation Vicki Pfau
2026-07-30 4:12 ` [PATCH v5 02/11] HID: steam: Refactor and clean up report parsing Vicki Pfau
2026-07-30 4:52 ` sashiko-bot [this message]
2026-07-30 4:12 ` [PATCH v5 03/11] HID: steam: Rename some constants that got renamed upstream Vicki Pfau
2026-07-30 4:12 ` [PATCH v5 04/11] HID: steam: Add support for sensor events on the Steam Controller (2015) Vicki Pfau
2026-07-30 4:37 ` sashiko-bot
2026-07-30 4:12 ` [PATCH v5 05/11] HID: steam: Coalesce rumble packets Vicki Pfau
2026-07-30 4:33 ` sashiko-bot
2026-07-30 4:12 ` [PATCH v5 06/11] HID: steam: Fully unregister controller when hidraw is opened Vicki Pfau
2026-07-30 4:34 ` sashiko-bot
2026-07-30 4:12 ` [PATCH v5 07/11] HID: steam: Rearrange teardown sequence Vicki Pfau
2026-07-30 4:39 ` sashiko-bot
2026-07-30 4:12 ` [PATCH v5 08/11] HID: steam: Improve logging and other cleanup Vicki Pfau
2026-07-30 4:34 ` sashiko-bot
2026-07-30 4:12 ` [PATCH v5 09/11] HID: steam: Zero-initialize reply in serial lookup Vicki Pfau
2026-07-30 4:12 ` [PATCH v5 10/11] HID: steam: Reject short reads Vicki Pfau
2026-07-30 4:12 ` [PATCH v5 11/11] HID: steam: Retry send/recv reports if stale 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=20260730045237.2E7961F000E9@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 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.