From: "David Rheinsberg" <david@readahead.eu>
To: "Rafael Passos" <rafael@rcpassos.me>,
"Jiri Kosina" <jikos@kernel.org>,
"Benjamin Tissoires" <bentiss@kernel.org>
Cc: "Shuah Khan" <skhan@linuxfoundation.org>,
"Brigham Campbell" <me@brighamcampbell.com>,
"Jori Koolstra" <jkoolstra@xs4all.nl>,
linux-input@vger.kernel.org
Subject: Re: [PATCH v3 4/4] HID: wiimote: fix uaf when hid events are handled during destroy
Date: Fri, 31 Jul 2026 13:17:41 +0200 [thread overview]
Message-ID: <f1accf74-c527-4c53-9321-84dbcd8fd729@app.fastmail.com> (raw)
In-Reply-To: <20260729164928.1138468-5-rafael@rcpassos.me>
Hi
On Wed, Jul 29, 2026, at 6:49 PM, Rafael Passos wrote:
> In wiimote_destroy, in the time between setting WIIPROTO_FLAG_EXITING
> and hid_hw_stop, new events could be handled.
> The new behaviour mirrors hid-playstation's output_worker_initialized
> flag-gate (source of inspiration).
>
> This issue was reported as a pre-existign race condition by sashiko.
> I confirmed it is possible, but very unlikely. It could only happen if
> shutdown is initiated by Linux, and the controller is being used.
`hdev->driver_input_lock` serializes all probe/remove/event callbacks. Can you elaborate how this is triggered?
I can see that external APIs like debugfs and other sysfs registrations can trigger this, but they are deinitialized before cancelling the work, aren't they?
Thanks
David
> Signed-off-by: Rafael Passos <rafael@rcpassos.me>
> ---
> drivers/hid/hid-wiimote-core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/hid/hid-wiimote-core.c
> b/drivers/hid/hid-wiimote-core.c
> index 31ee86affc553..067db8b8a56d1 100644
> --- a/drivers/hid/hid-wiimote-core.c
> +++ b/drivers/hid/hid-wiimote-core.c
> @@ -92,6 +92,9 @@ static void wiimote_queue(struct wiimote_data *wdata,
> const __u8 *buffer,
> */
>
> spin_lock_irqsave(&wdata->queue.lock, flags);
> + /* Do not schedule work if controller is exiting */
> + if ((wdata->state.flags & WIIPROTO_FLAG_EXITING))
> + goto out_unlock;
>
> memcpy(wdata->queue.outq[wdata->queue.head].data, buffer, count);
> wdata->queue.outq[wdata->queue.head].size = count;
> --
> 2.53.0
prev parent reply other threads:[~2026-07-31 11:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 16:49 [PATCH v3 0/4] HID: wiimote: new LED behavior on connect, scoped guards, uaf Rafael Passos
2026-07-29 16:49 ` [PATCH v3 1/4] HID: wiimote: turn on the LEDs indicating the controller id Rafael Passos
2026-07-29 17:07 ` sashiko-bot
2026-07-31 9:02 ` David Rheinsberg
2026-07-29 16:49 ` [PATCH v3 2/4] HID: wiimote: replace spinlock pairs with scoped_guard Rafael Passos
2026-07-29 17:07 ` sashiko-bot
2026-07-31 9:08 ` David Rheinsberg
2026-07-29 16:49 ` [PATCH v3 3/4] HID: wiimote: use scoped cleanup in wiimote and led probes Rafael Passos
2026-07-29 17:14 ` sashiko-bot
2026-07-31 11:18 ` David Rheinsberg
2026-07-29 16:49 ` [PATCH v3 4/4] HID: wiimote: fix uaf when hid events are handled during destroy Rafael Passos
2026-07-29 17:14 ` sashiko-bot
2026-07-31 11:17 ` David Rheinsberg [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=f1accf74-c527-4c53-9321-84dbcd8fd729@app.fastmail.com \
--to=david@readahead.eu \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=jkoolstra@xs4all.nl \
--cc=linux-input@vger.kernel.org \
--cc=me@brighamcampbell.com \
--cc=rafael@rcpassos.me \
--cc=skhan@linuxfoundation.org \
/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