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 v4 10/13] HID: asus: add support to force feedback
Date: Mon, 31 Aug 2026 00:02:12 +0000 [thread overview]
Message-ID: <20260831000212.6425B1F00ACA@smtp.kernel.org> (raw)
In-Reply-To: <20260830234320.114356-11-denis.benato@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Concurrent execution of the config interface probe/resume and gamepad interface unbind causes a use-after-free on HID hardware resources.
--
commit b62ad34c16f335dc9dd774f0d7548d234839ba8d
Author: Denis Benato <denis.benato@linux.dev>
HID: asus: add support to force feedback
Unlike ROG ally the X version and following ones uses DInput protocol
and the force feedback needs to be implemented as its protocol is
vendor-specific, therefore add support for FF_RUMBLE with magnitude
scaling on a work-queue based approach to avoid using possibly
sleeping calls in atomic context.
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index bd488acdb5d49..61330ae082b16 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
[ ... ]
> @@ -2756,19 +2912,43 @@ static int ally_x_setup_input(struct hid_device *hdev, struct ally_handheld *all
>
> return 0;
> ally_x_setup_input_err:
> + spin_lock_irqsave(&ally_data_lock, flags);
> + if (ally->ally_x_hdev == hdev)
> + ally->ally_x_hdev = NULL;
> + spin_unlock_irqrestore(&ally_data_lock, flags);
> return ret;
> }
>
> static int hid_asus_ally_init(struct hid_device *hdev, struct ally_handheld *ally)
> {
> + struct hid_device *x_hdev;
> struct ally_config *cfg;
> + unsigned long flags;
> int ret;
>
> - /* Failure at this point is non-critical */
> - ret = ally_gamepad_send_packet(ally, hdev, ALLY_FORCE_FEEDBACK_OFF,
> - sizeof(ALLY_FORCE_FEEDBACK_OFF));
> - if (ret < 0)
> - hid_err(hdev, "Ally failed to init force-feedback off: %d\n", ret);
> + /*
> + * The force-feedback "off" packet belongs to the gamepad interface,
> + * which consumes it as an output report: the config interface probed
> + * here would reject it. The gamepad probe path sends the packet itself,
> + * so this only matters when the gamepad interface is already bound,
> + * e.g. after a reset resume that re-initialized the MCU.
> + */
> + spin_lock_irqsave(&ally_data_lock, flags);
> + x_hdev = ally->ally_x_hdev;
> + if (x_hdev)
> + get_device(&x_hdev->dev);
> + spin_unlock_irqrestore(&ally_data_lock, flags);
> +
> + if (x_hdev) {
> + /* Failure at this point is non-critical */
> + ret = ally_x_send_ff_off(ally, x_hdev);
[Severity: High]
Can this cross-device call cause a use-after-free on transport data structures?
While taking a reference to x_hdev->dev with get_device() prevents the
struct hid_device memory from being freed, does it stop the peer's
transport resources from being torn down?
If the configuration interface probes or resumes concurrently with the
gamepad interface being unbound (e.g., via sysfs or a reset/disconnect cycle),
it appears the transport driver could destroy the transport driver data once
hid_destroy_device() returns, while we are still holding the device reference.
Would the subsequent call to hid_hw_output_report() via ally_x_send_ff_off()
then dereference that freed memory?
> +
> + if (ret < 0)
> + hid_err(hdev, "Ally failed to init force-feedback off: %d\n",
> + ret);
> +
> + put_device(&x_hdev->dev);
> + }
>
> cfg = ally_get_config(ally);
> if (!cfg)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260830234320.114356-1-denis.benato@linux.dev?part=10
next prev parent reply other threads:[~2026-08-31 0:02 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
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 [this message]
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=20260831000212.6425B1F00ACA@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