From: Denis Benato <denis.benato@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
connorbelli2003@gmail.com, Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>
Subject: Re: [PATCH v2 4/4] HID: asus: add i2c entry for FA808UM and other TUFs
Date: Sat, 13 Jun 2026 15:22:44 +0200 [thread overview]
Message-ID: <4f46e056-cf67-499b-9143-03f56037eb81@linux.dev> (raw)
In-Reply-To: <20260612143750.26B531F000E9@smtp.kernel.org>
On 6/12/26 16:37, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
>
> Pre-existing issues:
> - [Critical] Improper Workqueue Initialization / Memory Corruption via Re-initialization
> - [High] Use-After-Free due to Race Condition in `asus_remove()`
> - [High] Missing NULL check for `devm_kasprintf` allocation leading to Kernel Oops
> --
>
> commit ee67627a03893a0ccf0a7653ac62191a687b7821
> Author: Denis Benato <denis.benato@linux.dev>
>
> HID: asus: add i2c entry for FA808UM and other TUFs
>
> On newer TUF laptops the keyboard HID device uses the same PID/VID of a
> USB device that was found in ROG laptops: add it to hid-asus as i2c too.
>
>> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
>> index 0f78242b6a1db..7964fc96196e5 100644
>> --- a/drivers/hid/hid-asus.c
>> +++ b/drivers/hid/hid-asus.c
>> @@ -1565,6 +1565,9 @@ static const struct hid_device_id asus_devices[] = {
>> { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
>> USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD2),
>> QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_HID_FN_LOCK },
>> + { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
>> + USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD2),
>> + QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_HID_FN_LOCK },
> [Severity: Critical]
> This is a pre-existing issue, but since this patch enables QUIRK_HID_FN_LOCK
> for a new device, could the fn_lock_sync_work initialization cause workqueue
> corruption?
>
> In asus_input_configured(), INIT_WORK(&drvdata->fn_lock_sync_work, ...) is
> called per-input. For devices with multiple inputs, if hid_hw_start() enables
> interrupts before all inputs are configured, an early KEY_FN_ESC event could
> schedule the work before the next input is configured.
>
> The next call to asus_input_configured() would then re-execute INIT_WORK() on
> the already queued work item, clearing its list pointers and causing a panic.
>
> Additionally, for devices with 0 inputs, it is never initialized, causing a
> warning in cancel_work_sync().
This is implemented in f631011e36b87b173b71c7592b558ad05d791228
("HID: hid-asus: Implement fn lock for Asus ProArt P16") and I see a
asus_kbd_set_fn_lock(hdev, true);
things
asus_kbd_set_fn_lock(hdev, true);
Shouldn't one of the two (probably the latest) be:
asus_kbd_set_fn_lock(hdev, false);
Moreover I see from the commit message that this implementation has
been copied from hid-lenovo, so does hid-lenovo suffers from the same issue?
Since I don't have the affected hardware and I'm much confused by this double true
I won't try to fix it in this patchset unless absolutely necessary or I have more info,
but ideally I would like the patch to come from who can actually test the fix.
> [Severity: High]
> This is a pre-existing issue, but is there a potential use-after-free during
> device removal when QUIRK_HID_FN_LOCK is enabled?
>
> In asus_remove(), cancel_work_sync(&drvdata->fn_lock_sync_work) is called
> before hid_hw_stop(hdev). Since the hardware is still active, a late
> KEY_FN_ESC event can trigger asus_event() and unconditionally call
> schedule_work() after the work was supposedly canceled.
>
> Once the driver is removed and drvdata is freed by devres, could the
> workqueue execute asus_sync_fn_lock() and dereference the freed drvdata?
>
> [Severity: High]
> This is a pre-existing issue, but does the XGM LED name allocation need a
> NULL check?
>
> In asus_probe(), devm_kasprintf() is used to allocate the name for
> drvdata->xgm_led->cdev.name:
>
> drvdata->xgm_led->cdev.name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
> "asus:xgm-%s:led",
> strlen(hdev->uniq) ?
> hdev->uniq : dev_name(&hdev->dev));
> drvdata->xgm_led->cdev.brightness = 1;
>
> If devm_kasprintf() fails under memory pressure, it returns NULL. This NULL
> pointer is then passed to led_classdev_register(), which passes it to
> led_classdev_next_name() and eventually to strscpy() as the source string.
> Since strscpy() does not check for a NULL source, this would cause an
> immediate NULL pointer dereference.
>
>> { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
>> USB_DEVICE_ID_ASUSTEK_ROG_Z13_LIGHTBAR),
>> QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
prev parent reply other threads:[~2026-06-13 13:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 14:23 [PATCH v2 0/4] HID: asus: security fixes and more hardware support Denis Benato
2026-06-12 14:23 ` [PATCH v2 1/4] HID: asus: mitigate possible use-after-free Denis Benato
2026-06-12 14:44 ` Antheas Kapenekakis
2026-06-12 14:23 ` [PATCH v2 2/4] HID: asus: prevent wrong pointer cast Denis Benato
2026-06-12 14:38 ` sashiko-bot
2026-06-12 14:48 ` Antheas Kapenekakis
2026-06-12 14:23 ` [PATCH v2 3/4] HID: asus: add support for xgm led Denis Benato
2026-06-12 14:37 ` sashiko-bot
2026-06-12 14:39 ` Antheas Kapenekakis
2026-06-12 15:56 ` Denis Benato
2026-06-13 0:30 ` Antheas Kapenekakis
2026-06-13 14:01 ` Denis Benato
2026-06-12 14:23 ` [PATCH v2 4/4] HID: asus: add i2c entry for FA808UM and other TUFs Denis Benato
2026-06-12 14:37 ` sashiko-bot
2026-06-13 13:22 ` Denis Benato [this message]
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=4f46e056-cf67-499b-9143-03f56037eb81@linux.dev \
--to=denis.benato@linux.dev \
--cc=bentiss@kernel.org \
--cc=connorbelli2003@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jikos@kernel.org \
--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