Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vicki Pfau" <vi@endrift.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v4 07/11] HID: steam: Fully unregister controller when hidraw is opened
Date: Wed, 29 Jul 2026 02:12:09 +0000	[thread overview]
Message-ID: <20260729021210.4B4861F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729015243.1170573-8-vi@endrift.com>

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

New issues:
- [Medium] Unifying connect and unregister logic causes log spam and unnecessary I/O on hidraw open/close.

Pre-existing issues:
- [High] Dangling pointer in the global `steam_devices` list on probe failure.
--

--- Patch [7]: [PATCH v4 07/11] HID: steam: Fully unregister controller when hidraw is opened ---
commit d6b711a20faba4cc20306f07e01853b79872c545
Author: Vicki Pfau <vi@endrift.com>

HID: steam: Fully unregister controller when hidraw is opened

To avoid conflicts between anything touching the hidraw and the driver, this
patch fully unregisters the controller internally when hidraw is opened,
leaving only the hidraw active until it's closed. It also unifies the
unregister and connect callbacks.

> diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
> index a200878db8ac7..ff112aa1b0e91 100644
> --- a/drivers/hid/hid-steam.c
> +++ b/drivers/hid/hid-steam.c
[ ... ]
> @@ -1141,38 +1142,41 @@ static int steam_register(struct steam_device *steam)
[ ... ]
>  static void steam_work_connect_cb(struct work_struct *work)
>  {
>  	struct steam_device *steam = container_of(work, struct steam_device,
>  							work_connect);
> +
>  	unsigned long flags;
>  	bool connected;
> +	bool opened;
>  	int ret;
>  
>  	spin_lock_irqsave(&steam->lock, flags);
> +	opened = steam->client_opened;
>  	connected = steam->connected;
>  	spin_unlock_irqrestore(&steam->lock, flags);
>  
> -	if (connected) {
> +	if (connected && !opened) {
>  		ret = steam_register(steam);

[Severity: High]
This is a pre-existing issue, but does steam_register() leak the list
entry if it fails?

If steam_register() fails (e.g., if input_allocate_device() fails inside
steam_input_register()), the device is added to the global steam_devices
list but not removed.

Also, in steam_probe(), if a wired Steam controller is probed but an error
occurs later, the error path jumps to err_hw_stop, bypassing
err_steam_unregister. Devres will free the steam_device structure, leaving a
dangling pointer in steam_devices. Could this lead to a use-after-free if the
list is later traversed (e.g., when a user modifies lizard_mode)?

> -		if (ret) {
> +		if (ret)
>  			hid_err(steam->hdev,
>  				"%s:steam_register failed with error %d\n",
>  				__func__, ret);
> -		}
>  	} else {
>  		steam_unregister(steam);
>  	}

[Severity: Medium]
By unifying the connect and unregister logic here, will this cause log spam
and unnecessary synchronous USB I/O when hidraw is opened and closed?

steam_unregister() clears the serial number and logs a disconnect message.
When hidraw is closed, steam_register() logs a connect message and performs
synchronous USB I/O to re-fetch the serial number and device attributes.

Could an unprivileged userspace application rapidly open and close the
hidraw node (which is typical for gamepads managed by udev), flooding the
kernel log and triggering localized DoS via USB I/O?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260729015243.1170573-1-vi@endrift.com?part=7

  reply	other threads:[~2026-07-29  2:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29  1:52 [PATCH v4 00/10] HID: steam: General cleanup and improvements Vicki Pfau
2026-07-29  1:52 ` [PATCH v4 01/11] HID: steam: Update documentation Vicki Pfau
2026-07-29  1:52 ` [PATCH v4 02/11] HID: steam: Refactor and clean up report parsing Vicki Pfau
2026-07-29  1:52 ` [PATCH v4 03/11] HID: steam: Rename some constants that got renamed upstream Vicki Pfau
2026-07-29  1:52 ` [PATCH v4 04/11] HID: steam: Zero-initialize reply in serial lookup Vicki Pfau
2026-07-29  2:10   ` sashiko-bot
2026-07-29  1:52 ` [PATCH v4 05/11] HID: steam: Add support for sensor events on the Steam Controller (2015) Vicki Pfau
2026-07-29  2:09   ` sashiko-bot
2026-07-29  1:52 ` [PATCH v4 06/11] HID: steam: Coalesce rumble packets Vicki Pfau
2026-07-29  2:13   ` sashiko-bot
2026-07-29  1:52 ` [PATCH v4 07/11] HID: steam: Fully unregister controller when hidraw is opened Vicki Pfau
2026-07-29  2:12   ` sashiko-bot [this message]
2026-07-29  1:52 ` [PATCH v4 08/11] HID: steam: Rearrange teardown sequence Vicki Pfau
2026-07-29  2:15   ` sashiko-bot
2026-07-29  1:52 ` [PATCH v4 09/11] HID: steam: Improve logging and other cleanup Vicki Pfau
2026-07-29  2:11   ` sashiko-bot
2026-07-29  1:52 ` [PATCH v4 10/11] HID: steam: Reject short reads Vicki Pfau
2026-07-29  1:52 ` [PATCH v4 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=20260729021210.4B4861F000E9@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