From: sashiko-bot@kernel.org
To: "Andreas Claesson" <andreas@aclaesson.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH] HID: corsair: cancel LED work again after unregistering the LED
Date: Tue, 10 Nov 2026 23:27:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-207904@kernel.org> (raw)
In-Reply-To: <20261109-hid-corsair-k90-uaf-v1-1-0621c2c5c451@aclaesson.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Medium] HID: corsair: use-after-free in k90_init_macro_functions()
error path [1]
--
commit 3a201ad222c1beccee0e1120afae987d661371db
Author: Andreas Claesson <andreas@aclaesson.com>
HID: corsair: cancel LED work again after unregistering the LED
This commit adds a second cancel_work_sync() call after
led_classdev_unregister() in k90_cleanup_backlight() and
k90_cleanup_macro_functions() to cancel work re-queued when
led_classdev_unregister() turns the LED off.
> diff --git a/drivers/hid/hid-corsair.c b/drivers/hid/hid-corsair.c
> index 278c6efb565df..75c862f5f783f 100644
> --- a/drivers/hid/hid-corsair.c
> +++ b/drivers/hid/hid-corsair.c
[ ... ]
> @@ -542,6 +544,8 @@ static void k90_cleanup_macro_functions(struct hid_device *dev)
> k90->record_led.removed = true;
> cancel_work_sync(&k90->record_led.work);
> led_classdev_unregister(&k90->record_led.cdev);
> + /* unregister turns the LED off, which re-queues the work */
> + cancel_work_sync(&k90->record_led.work);
> kfree(k90->record_led.cdev.name);
>
> kfree(k90);
[Severity: Medium]
This problem wasn't introduced by this patch, but can the fail_sysfs error
path in k90_init_macro_functions() still cause a use-after-free on
led->cdev.dev [1]?
drivers/hid/hid-corsair.c:k90_init_macro_functions() {
...
fail_sysfs:
k90->record_led.removed = true;
led_classdev_unregister(&k90->record_led.cdev);
cancel_work_sync(&k90->record_led.work);
...
}
When sysfs_create_group() fails after led_classdev_register() has exposed
the record LED, fail_sysfs calls led_classdev_unregister() without calling
cancel_work_sync() first:
CPU0 CPU1
k90_init_macro_functions()
led_classdev_register(...)
k90_brightness_set()
schedule_work(&led->work)
k90_record_led_work()
if (led->removed)
sysfs_create_group(...)
k90->record_led.removed = true;
led_classdev_unregister(...)
led->cdev.dev->parent
<-- use-after-free
cancel_work_sync(...)
Calling cancel_work_sync(&k90->record_led.work) before
led_classdev_unregister() in fail_sysfs as well would match
k90_cleanup_macro_functions().
[1] https://sashiko.dev/#/bug/linux-2f786541-d064-428e-a1ab-d203d4112002
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261109-hid-corsair-k90-uaf-v1-1-0621c2c5c451@aclaesson.com?part=1
prev parent reply other threads:[~2026-11-10 23:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 19:55 [PATCH] HID: corsair: cancel LED work again after unregistering the LED Andreas Claesson via B4 Relay
2026-11-10 23:27 ` sashiko-bot [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=sashiko-outbox-207904@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=andreas@aclaesson.com \
--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