From: sashiko-bot@kernel.org
To: "Lee Jones" <lee@kernel.org>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH 4/5] HID: wacom: Fix Use-After-Free in wacom_bamboo_pad
Date: Tue, 25 Aug 2026 17:22:43 +0000 [thread overview]
Message-ID: <20260825172244.39AD91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825151242.576456-4-lee@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Lockless access to `shared->pen` and `shared->touch` in `wacom_mode_change_work` without RCU read lock leads to Use-After-Free.
- [High] Asynchronous resources started during probe are not cancelled if a subsequent probe step fails.
--
commit cf6bbd224806057956b357da6af1b313f006731c
Author: Lee Jones <lee@kernel.org>
HID: wacom: Fix Use-After-Free in wacom_bamboo_pad
This patch resolves a use-after-free issue in wacom_bamboo_pad_pen_event
by introducing RCU protection for the pen and touch pointers.
> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> index b88726cbbb4ec..79fd397e044af 100644
> --- a/drivers/hid/wacom_sys.c
> +++ b/drivers/hid/wacom_sys.c
[ ... ]
> @@ -2836,16 +2847,19 @@ static void wacom_mode_change_work(struct work_struct *work)
> bool is_direct = wacom->wacom_wac.is_direct_mode;
> int error = 0;
>
> - if (shared->pen) {
> - wacom1 = hid_get_drvdata(shared->pen);
> + struct hid_device *pen = rcu_access_pointer(shared->pen);
> + struct hid_device *touch = rcu_access_pointer(shared->touch);
> +
> + if (pen) {
> + wacom1 = hid_get_drvdata(pen);
> wacom_release_resources(wacom1);
> hid_hw_stop(wacom1->hdev);
[Severity: High]
This is a pre-existing issue, but does using rcu_access_pointer() here leave
the pointer unprotected?
The rcu_access_pointer() helper doesn't establish an RCU read-side critical
section. This means a concurrent removal of the sibling device could call
wacom_remove_shared_data() and nullify the shared pointer.
If the pointer is nullified, synchronize_rcu() won't wait for this work item
to finish.
Could this sequence allow the device and its driver data to be freed while
we're still executing hid_hw_stop() on it, resulting in a use-after-free?
> wacom1->wacom_wac.has_mode_change = true;
> wacom1->wacom_wac.is_direct_mode = is_direct;
> }
[ ... ]
Also, regarding a pre-existing issue in wacom_parse_and_register() not modified
by this patch:
[Severity: High]
This isn't a bug introduced by this patch, but does the error path here fail to
cancel asynchronous works?
When an initialization step fails after hid_hw_start(hdev) is called,
the cleanup goes to fail_hw_stop:
fail_hw_stop:
hid_hw_stop(hdev);
fail:
wacom_release_resources(wacom);
return error;
The call to hid_hw_start() enables interrupts, which could schedule work items
like wacom->battery_work, wacom->wireless_work, or wacom->mode_change_work.
Does failing to cancel these scheduled works before returning allow them to
execute after devres has freed the wacom structure?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260825151242.576456-1-lee@kernel.org?part=4
next prev parent reply other threads:[~2026-08-25 17:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 15:12 [PATCH 1/5] HID: wacom: Use hdev->product in wacom_setup_touch_input_capabilities Lee Jones
2026-08-25 15:12 ` [PATCH 2/5] HID: wacom: Advertise SW_MUTE_DEVICE capability prior to registration Lee Jones
2026-08-25 17:25 ` sashiko-bot
2026-08-26 8:02 ` Lee Jones
2026-08-25 15:12 ` [PATCH 3/5] HID: wacom: Fix Use-After-Free in wacom_intuos_pad Lee Jones
2026-08-25 17:26 ` sashiko-bot
2026-08-25 15:12 ` [PATCH 4/5] HID: wacom: Fix Use-After-Free in wacom_bamboo_pad Lee Jones
2026-08-25 17:22 ` sashiko-bot [this message]
2026-08-25 15:12 ` [PATCH 5/5] HID: wacom: Redesign shared sibling data lifecycle Lee Jones
2026-08-25 17:19 ` [PATCH 1/5] HID: wacom: Use hdev->product in wacom_setup_touch_input_capabilities sashiko-bot
2026-08-27 2:48 ` Ping Cheng
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=20260825172244.39AD91F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=lee@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