From: sashiko-bot@kernel.org
To: "Denis Benato" <denis.benato@linux.dev>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v6 04/13] HID: asus: add gamepad configuration
Date: Tue, 08 Sep 2026 18:01:07 +0000 [thread overview]
Message-ID: <20260908180108.17FCE1F00A3F@smtp.kernel.org> (raw)
In-Reply-To: <20260908174433.74260-5-denis.benato@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Time-of-check to time-of-use race condition in probe allows spoofed USB devices to bypass singleton checks, leading to memory corruption and UAF.
- [Medium] Sysfs attribute becomes visible before device initialization is complete, causing transient -ENODEV errors.
--
commit 40a018a18704e85c526230c53db4138c9ec858c7
Author: Denis Benato <denis.benato@linux.dev>
HID: asus: add gamepad configuration
Add the base configuration structures for the gamepad configuration,
detect capabilities and initialize the device in a known state.
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index 11dea2aec80b1..ac0c0a176857e 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
[ ... ]
> @@ -617,6 +660,274 @@ static u8 *ally_alloc_cmd(u8 cmd, const u8 *payload, u8 payload_size)
> return hidbuf;
> }
[ ... ]
> +static ssize_t xbox_controller_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct hid_device *hdev = to_hid_device(dev);
> + struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
> + struct ally_handheld *ally = drvdata->rog_ally;
> + struct ally_config *cfg;
> +
> + if (!ally)
> + return -ENODEV;
[Severity: Medium]
Will userspace configuration scripts encounter transient errors when trying
to read or configure the controller immediately upon detection?
In ally_config_create(), sysfs_create_group() is called, which immediately
exposes attributes like xbox_controller to userspace.
If a read or write occurs immediately, xbox_controller_show() retrieves
drvdata->rog_ally. However, this pointer is only assigned later in
asus_probe() after hid_asus_ally_probe() returns. During this window,
this callback will return -ENODEV.
While this race is handled later in the series for button mapping attributes
by explicitly carrying the ally pointer in a custom attribute structure,
do these base attributes need similar protection?
> +
> + cfg = ally_get_config(ally);
> + if (!cfg)
> + return -ENODEV;
[ ... ]
> @@ -1025,6 +1356,14 @@ static struct ally_handheld *hid_asus_ally_probe(struct hid_device *hdev)
> return ERR_PTR(ret);
> }
>
> + ally_cfg = ally_config_create(hdev, &ally_drvdata);
[Severity: High]
Can this code allow a time-of-check to time-of-use race if multiple USB
interfaces are probed concurrently?
The singleton check earlier in hid_asus_ally_probe() checks
ally_drvdata.cfg_hdev under ally_data_lock, but the lock is released
before reaching this point.
If two threads probe concurrently, both will pass the initial check. They
would then both execute ally_config_create() concurrently without a lock,
leading to a memory leak of the static ally_config pointer and a double
initialization of its mutex.
Finally, if both threads re-acquire the lock and overwrite
ally_drvdata.cfg_hdev, the device that loses the race would have its sysfs
groups permanently leaked. If the driver is later unloaded, ally_config is
freed, but the leaked sysfs attributes would remain, leading to a
use-after-free on subsequent accesses.
> + if (IS_ERR(ally_cfg)) {
> + hid_err(hdev, "Failed to create Ally cfg: %ld\n",
> + PTR_ERR(ally_cfg));
> + ally_put_udev_if_orphaned();
> + return ERR_PTR(PTR_ERR(ally_cfg));
> + }
> +
> ret = hid_asus_ally_init(hdev, &ally_drvdata);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908174433.74260-1-denis.benato@linux.dev?part=4
next prev parent reply other threads:[~2026-09-08 18:01 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 17:44 [PATCH v6 00/13] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-09-08 17:44 ` [PATCH v6 01/13] HID: asus: do not send keyboard init reports to touchpads Denis Benato
2026-09-08 17:44 ` [PATCH v6 02/13] HID: asus: reinitialize the device after exiting a sleep state Denis Benato
2026-09-08 18:00 ` sashiko-bot
2026-09-08 17:44 ` [PATCH v6 03/13] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-09-08 17:57 ` sashiko-bot
2026-09-08 17:44 ` [PATCH v6 04/13] HID: asus: add gamepad configuration Denis Benato
2026-09-08 18:01 ` sashiko-bot [this message]
2026-09-08 17:44 ` [PATCH v6 05/13] HID: asus: add vibration strength configuration Denis Benato
2026-09-08 17:44 ` [PATCH v6 06/13] HID: asus: add joysticks inner and outer range configuration Denis Benato
2026-09-08 17:44 ` [PATCH v6 07/13] HID: asus: add triggers " Denis Benato
2026-09-08 17:44 ` [PATCH v6 08/13] HID: asus: add joysticks anti-deadzone configuration Denis Benato
2026-09-08 17:44 ` [PATCH v6 09/13] HID: asus: add support for response curve Denis Benato
2026-09-08 18:13 ` sashiko-bot
2026-09-08 17:44 ` [PATCH v6 10/13] HID: asus: add support to force feedback Denis Benato
2026-09-08 18:01 ` sashiko-bot
2026-09-08 17:44 ` [PATCH v6 11/13] HID: asus: add support for gamepad mode Denis Benato
2026-09-08 17:44 ` [PATCH v6 12/13] HID: asus: add support for turbo buttons Denis Benato
2026-09-08 18:08 ` sashiko-bot
2026-09-08 17:44 ` [PATCH v6 13/13] HID: asus: add support for btn remapping Denis Benato
2026-09-08 18:07 ` 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=20260908180108.17FCE1F00A3F@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=denis.benato@linux.dev \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox