From: sashiko-bot@kernel.org
To: "Lee Jones" <lee@kernel.org>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH 3/4] HID: wacom: Fix Use-After-Free in wacom_bamboo_pad
Date: Tue, 04 Aug 2026 10:40:56 +0000 [thread overview]
Message-ID: <20260804104056.8DFF01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804103030.1491356-3-lee@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Lockless and unprotected dereference of RCU pointers `shared->pen` and `shared->touch` in `wacom_mode_change_work()` leading to Use-After-Free.
--
--- Patch [3]: [PATCH 3/4] HID: wacom: Fix Use-After-Free in wacom_bamboo_pad ---
commit 767b68ab7301c7003f61a85491f11aed0373e519
Author: Lee Jones <lee@kernel.org>
HID: wacom: Fix Use-After-Free in wacom_bamboo_pad
This commit resolves a lockless access to wacom->shared->pen by introducing
RCU protection for pen and touch pointers. It also updates writers to use
rcu_assign_pointer() and updates mode change workers to use
rcu_access_pointer().
> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> index cf9c12f3cff53..05d27fcd311f8 100644
> --- a/drivers/hid/wacom_sys.c
> +++ b/drivers/hid/wacom_sys.c
[ ... ]
> @@ -2810,16 +2821,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 could this lockless access to the RCU
pointers still lead to a use-after-free if the sibling device is removed
concurrently?
Because pen and touch are fetched using rcu_access_pointer() and
dereferenced without rcu_read_lock(), synchronize_rcu() in
wacom_remove_shared_data() won't block this worker thread.
If the sibling device is removed and freed right after rcu_access_pointer()
returns a non-NULL pointer, won't hid_get_drvdata(pen), hid_hw_stop(), and
wacom_release_resources() operate on freed memory?
> wacom1->wacom_wac.has_mode_change = true;
> wacom1->wacom_wac.is_direct_mode = is_direct;
> }
>
> - if (shared->touch) {
> - wacom2 = hid_get_drvdata(shared->touch);
> + if (touch) {
> + wacom2 = hid_get_drvdata(touch);
> wacom_release_resources(wacom2);
> hid_hw_stop(wacom2->hdev);
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260804103030.1491356-1-lee@kernel.org?part=3
next prev parent reply other threads:[~2026-08-04 10:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 10:30 [PATCH 1/4] HID: wacom: Advertise SW_MUTE_DEVICE capability prior to registration Lee Jones
2026-08-04 10:30 ` [PATCH 2/4] HID: wacom: Fix Use-After-Free in wacom_intuos_pad Lee Jones
2026-08-04 10:54 ` sashiko-bot
2026-08-04 10:30 ` [PATCH 3/4] HID: wacom: Fix Use-After-Free in wacom_bamboo_pad Lee Jones
2026-08-04 10:40 ` sashiko-bot [this message]
2026-08-04 10:30 ` [PATCH 4/4] HID: wacom: Redesign shared sibling data lifecycle Lee Jones
2026-08-04 10:33 ` [PATCH 1/4] HID: wacom: Advertise SW_MUTE_DEVICE capability prior to registration Lee Jones
-- strict thread matches above, loose matches on Subject: below --
2026-07-07 12:10 Lee Jones
2026-07-07 12:10 ` [PATCH 3/4] HID: wacom: Fix Use-After-Free in wacom_bamboo_pad Lee Jones
2026-07-07 12:27 ` 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=20260804104056.8DFF01F000E9@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