From: sashiko-bot@kernel.org
To: "Lee Jones" <lee@kernel.org>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v9 5/5] HID: wacom: Redesign shared sibling data lifecycle
Date: Wed, 02 Sep 2026 14:05:05 +0000 [thread overview]
Message-ID: <20260902140505.851581F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260902134417.1270552-5-lee@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-After-Free in wacom_mode_change_work due to unsafe RCU access and lack of sibling synchronization.
--
commit 144702a97dac139acf4377ec2bc37fa17f37b11a
Author: Lee Jones <lee@kernel.org>
HID: wacom: Redesign shared sibling data lifecycle
The Wacom driver coordinates state between sibling interfaces of
the same physical device using a shared structure 'wacom_shared'.
This redesigns the sibling data lifecycle by eliminating a volatile
representative pointer and storing stable static copies of the required
attributes for sibling matching. It also switches to kref_put_mutex()
to secure the lifecycle against concurrent probe/disconnect races.
> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> index 12f6a32cbc5fc..9b991078a36d8 100644
> --- a/drivers/hid/wacom_sys.c
> +++ b/drivers/hid/wacom_sys.c
[ ... ]
> @@ -883,17 +900,19 @@ static void wacom_remove_shared_data(void *res)
> rcu_dereference_protected(wacom_wac->shared->pen,
> lockdep_is_held(&wacom_udev_list_lock));
>
> - if (touch == wacom->hdev) {
> + if (touch == res_wacom->hdev) {
> rcu_assign_pointer(wacom_wac->shared->touch, NULL);
> rcu_assign_pointer(wacom_wac->shared->touch_input, NULL);
> - } else if (pen == wacom->hdev) {
> + } else if (pen == res_wacom->hdev) {
> rcu_assign_pointer(wacom_wac->shared->pen, NULL);
> }
> }
>
> synchronize_rcu();
[Severity: High]
This is a pre-existing issue, but does synchronize_rcu() properly protect
against concurrent access in wacom_mode_change_work()?
When a sibling device is removed, this devres cleanup clears the sibling
pointers and calls synchronize_rcu(). However, wacom_mode_change_work()
retrieves the sibling pointer outside of an RCU critical section:
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);
Since wacom_mode_change_work() executes in a sleepable workqueue context and
uses rcu_access_pointer() instead of rcu_dereference() inside an
rcu_read_lock(), does synchronize_rcu() actually wait for the workqueue to
finish?
If wacom_mode_change_work() is executing concurrently with sibling removal,
could it dereference a dangling sibling pointer leading to a use-after-free
when the sibling's devres cleanup frees the memory?
>
> - kref_put(&data->kref, wacom_release_shared_data);
> + if (kref_put_mutex(&data->kref, wacom_release_shared_data, &wacom_udev_list_lock))
> + mutex_unlock(&wacom_udev_list_lock);
> +
> wacom_wac->shared = NULL;
> }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260902134417.1270552-1-lee@kernel.org?part=5
prev parent reply other threads:[~2026-09-02 14:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 13:44 [PATCH v9 1/5] HID: wacom: Use hdev->product in wacom_setup_touch_input_capabilities Lee Jones
2026-09-02 13:44 ` [PATCH v9 2/5] HID: wacom: Advertise SW_MUTE_DEVICE capability prior to registration Lee Jones
2026-09-02 14:03 ` sashiko-bot
2026-09-02 13:44 ` [PATCH v9 3/5] HID: wacom: Fix Use-After-Free in wacom_intuos_pad Lee Jones
2026-09-02 14:04 ` sashiko-bot
2026-09-02 13:44 ` [PATCH v9 4/5] HID: wacom: Fix Use-After-Free in wacom_bamboo_pad Lee Jones
2026-09-02 14:02 ` sashiko-bot
2026-09-02 13:44 ` [PATCH v9 5/5] HID: wacom: Redesign shared sibling data lifecycle Lee Jones
2026-09-02 14:05 ` 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=20260902140505.851581F000E9@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