From: sashiko-bot@kernel.org
To: "Denis Benato" <denis.benato@linux.dev>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v4 06/13] HID: asus: add joysticks inner and outer range configuration
Date: Mon, 31 Aug 2026 00:05:39 +0000 [thread overview]
Message-ID: <20260831000539.BB8D51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260830234320.114356-7-denis.benato@linux.dev>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Hardware state desynchronization across suspend/resume: joystick thresholds are not restored to the MCU.
- [High] Missing sysfs group removal in `ally_config_remove()` allows concurrent hardware I/O during device unbind, leading to UAF.
Pre-existing issues:
- [High] Missing assignment of ally->config makes all sysfs attributes unconditionally fail with -ENODEV.
--
commit 6419ae2426ffa2d2dc7640592bc7176d31b6c150
Author: Denis Benato <denis.benato@linux.dev>
HID: asus: add joysticks inner and outer range configuration
ROG Ally devices supports configuring joysticks inner and outer range:
add sysfs attributes to allow userspace modifying the sensitivity
of those controllers.
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index f825d650e1b7d..7702427bde451 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
> @@ -973,6 +973,351 @@ static struct device_attribute dev_attr_right_vibration_intensity =
> static struct device_attribute dev_attr_right_vibration_intensity_range =
> __ATTR(intensity_range, 0444, right_vibration_intensity_range_show, NULL);
>
[ ... ]
> +static ssize_t left_joystick_inner_threshold_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 *const ally = drvdata->rog_ally;
> + struct ally_config *cfg;
> +
> + if (!ally)
> + return -ENODEV;
> +
> + cfg = ally_get_config(ally);
> + if (!cfg)
> + return -ENODEV;
[Severity: High]
This isn't a bug introduced by this patch, but will these new sysfs attributes
unconditionally fail with -ENODEV?
Looking at hid_asus_ally_probe(), the ally_cfg pointer allocated by
ally_config_create() is never assigned to ally_drvdata.config:
spin_lock_irqsave(&ally_data_lock, flags);
ally_drvdata.cfg_hdev = hdev;
spin_unlock_irqrestore(&ally_data_lock, flags);
Because ally_drvdata.config is missing, won't ally_get_config(ally) always
return NULL here and cause every new sysfs callback to fail immediately?
> +
> + guard(mutex)(&cfg->config_mutex);
> +
> + if (!cfg->user_cal_support)
> + return -EOPNOTSUPP;
> +
> + return sysfs_emit(buf, "%u\n", cfg->left_deadzone);
> +}
[ ... ]
> @@ -1028,6 +1411,19 @@ static struct ally_config *ally_config_create(struct hid_device *hdev, struct al
> goto ally_config_create_err;
> }
>
> + /* Skip the calibration groups when the capability is missing. */
> + if (cfg->user_cal_support) {
> + for (sysfs_i = 0; sysfs_i < ARRAY_SIZE(ally_cal_attr_groups); sysfs_i++) {
> + ret = devm_device_add_group(&hdev->dev,
> + ally_cal_attr_groups[sysfs_i]);
[Severity: High]
Can concurrent sysfs writes during device unbind cause a use-after-free by
racing with hid_hw_stop()?
The driver manually calls sysfs_remove_group() for its older attributes in
ally_config_remove() to ensure active callbacks drain completely before
hardware teardown:
for (i = 0; i < ARRAY_SIZE(ally_attr_groups); i++)
sysfs_remove_group(&hdev->dev.kobj, &ally_attr_groups[i]);
Since ally_cal_attr_groups is not added to this manual removal loop, won't the
new sysfs store callbacks fail to drain? This could allow them to call
hid_hw_raw_request() concurrently while hid_hw_stop() is dismantling the
transport.
> + if (ret < 0) {
> + hid_err(hdev, "Failed to create sysfs group '%s': %d\n",
> + ally_cal_attr_groups[sysfs_i]->name, ret);
> + goto ally_config_create_sysfs_err;
> + }
> + }
> + }
> +
> cfg->gamepad_mode = 0x01;
> cfg->left_deadzone = 10;
> cfg->left_outer_threshold = 90;
[Severity: High]
Will the hardware state for joystick thresholds become desynchronized after a
suspend/resume cycle?
The MCU loses its state upon reset/suspend, so hid_asus_ally_init() is
explicitly invoked on resume to restore the software-cached state:
/* The MCU may have just been reset: restore the cached state. */
guard(mutex)(&cfg->config_mutex);
if (cfg->xbox_controller_enabled) {
ret = ally_set_xbox_controller(hdev, ally, cfg, true);
...
}
Since hid_asus_ally_init() completely omits restoring the new joystick
threshold parameters added in this patch, won't the hardware operate with
factory defaults while sysfs falsely reports the user's customized values?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260830234320.114356-1-denis.benato@linux.dev?part=6
next prev parent reply other threads:[~2026-08-31 0:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 23:43 [PATCH v4 00/13] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-08-30 23:43 ` [PATCH v4 01/13] HID: asus: do not send keyboard init reports to touchpads Denis Benato
2026-08-30 23:43 ` [PATCH v4 02/13] HID: asus: reinitialize the device after exiting a sleep state Denis Benato
2026-08-30 23:43 ` [PATCH v4 03/13] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-08-30 23:56 ` sashiko-bot
2026-08-30 23:43 ` [PATCH v4 04/13] HID: asus: add gamepad configuration Denis Benato
2026-08-30 23:53 ` sashiko-bot
2026-08-30 23:43 ` [PATCH v4 05/13] HID: asus: add vibration strength configuration Denis Benato
2026-08-30 23:43 ` [PATCH v4 06/13] HID: asus: add joysticks inner and outer range configuration Denis Benato
2026-08-31 0:05 ` sashiko-bot [this message]
2026-08-30 23:43 ` [PATCH v4 07/13] HID: asus: add triggers " Denis Benato
2026-08-30 23:58 ` sashiko-bot
2026-08-30 23:43 ` [PATCH v4 08/13] HID: asus: add joysticks anti-deadzone configuration Denis Benato
2026-08-30 23:57 ` sashiko-bot
2026-08-30 23:43 ` [PATCH v4 09/13] HID: asus: add support for response curve Denis Benato
2026-08-31 0:03 ` sashiko-bot
2026-08-30 23:43 ` [PATCH v4 10/13] HID: asus: add support to force feedback Denis Benato
2026-08-31 0:02 ` sashiko-bot
2026-08-30 23:43 ` [PATCH v4 11/13] HID: asus: add support for gamepad mode Denis Benato
2026-08-31 0:05 ` sashiko-bot
2026-08-30 23:43 ` [PATCH v4 12/13] HID: asus: add support for turbo buttons Denis Benato
2026-08-31 0:14 ` sashiko-bot
2026-08-30 23:43 ` [PATCH v4 13/13] HID: asus: add support for btn remapping Denis Benato
2026-08-31 0:08 ` 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=20260831000539.BB8D51F000E9@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