From: sashiko-bot@kernel.org
To: "Doruk Tan Ozturk" <doruk@0sec.ai>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH] HID: sony: fix UAF of ghl_poke_timer / ghl_urb at driver unbind
Date: Fri, 24 Jul 2026 14:01:08 +0000 [thread overview]
Message-ID: <20260724140109.2DCC11F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260724134236.34304-1-doruk@0sec.ai>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] This problem wasn't introduced by this patch, but the patch fails to correctly fix the use-after-free race condition because it uses `usb_kill_urb()` instead of `usb_poison_urb()` or a reversed teardown sequence. `usb_kill_urb()` does not permanently prevent URB submissions; it allows the pending timer to submit the URB immediately after it returns.
--
--- Patch [1]: [PATCH] HID: sony: fix UAF of ghl_poke_timer / ghl_urb at driver unbind ---
commit 922f81b4c171a572e240262070ec65197e21cd83
Author: Doruk Tan Ozturk <doruk@0sec.ai>
HID: sony: fix UAF of ghl_poke_timer / ghl_urb at driver unbind
This commit changes the driver teardown sequence for Guitar Hero Live
dongles to fix a use-after-free during driver unbind. It attempts to kill
the in-flight URB before shutting down the timer to prevent the URB
completion from re-arming the timer on freed memory.
Fixes: cc894ac55360 ("HID: sony: support for ghlive ps3/wii u dongles")
Cc: stable@vger.kernel.org
> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index e75246d29e16d..b7b9b705b9e1c 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
> @@ -2424,7 +2424,19 @@ static void sony_remove(struct hid_device *hdev)
> struct sony_sc *sc = hid_get_drvdata(hdev);
>
> if (sc->quirks & (GHL_GUITAR_PS3WIIU | GHL_GUITAR_PS4)) {
> - timer_delete_sync(&sc->ghl_poke_timer);
> + /*
> + * ghl_magic_poke() resubmits sc->ghl_urb from the poke timer
> + * and its completion ghl_magic_poke_cb() re-arms the timer, so
> + * an in-flight URB can re-arm the timer after a plain
> + * timer_delete_sync() (a no-op while the URB is in flight and
> + * the timer is not pending). sc is devm-allocated and freed
> + * once sony_remove() returns, so the re-armed timer would fire
> + * on freed memory. Kill the URB first so no completion can
> + * re-arm the timer, then timer_shutdown_sync() to drain it and
> + * permanently block further re-arming.
> + */
> + usb_kill_urb(sc->ghl_urb);
> + timer_shutdown_sync(&sc->ghl_poke_timer);
> + usb_free_urb(sc->ghl_urb);
[Severity: Critical]
This is a pre-existing issue, but does this teardown order still allow a
use-after-free race condition?
Because usb_kill_urb() does not permanently prevent URB submissions, it allows
the pending timer to submit the URB immediately after it returns.
Could this sequence occur if a user unbinds the driver while the URB is not
in flight and the ghl_poke_timer is pending:
1. usb_kill_urb() executes and returns immediately, decrementing urb->reject
back to 0.
2. Before timer_shutdown_sync() executes, the timer expires and its callback
ghl_magic_poke() successfully submits the URB.
3. timer_shutdown_sync() then waits for the timer callback to finish and marks
the timer as shutdown, but the URB is now in flight.
4. The driver teardown finishes and frees sc.
5. Later, the URB completes and triggers the use-after-free by accessing the
freed sc.
Would it be safer to use usb_poison_urb() instead to permanently block
submissions?
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724134236.34304-1-doruk@0sec.ai?part=1
prev parent reply other threads:[~2026-07-24 14:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 13:42 [PATCH] HID: sony: fix UAF of ghl_poke_timer / ghl_urb at driver unbind Doruk Tan Ozturk
2026-07-24 14:01 ` 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=20260724140109.2DCC11F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=doruk@0sec.ai \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.