* Re: [PATCH v2 22/33] HID: logitech-hidpp: shut down G920 force feedback on input unregister
[not found] <20261110-hid-logitech-hidpp-v2-22-30743e91d83b@gmail.com>
@ 2026-11-19 6:43 ` Wei Jie Law
2026-11-23 18:54 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Wei Jie Law @ 2026-11-19 6:43 UTC (permalink / raw)
To: dmitry.torokhov
Cc: andrew.smirnov, bentiss, e.velds, gideonheinz02, hadess, hansg,
jikos, lains, linux-input, linux-kernel, stuart.a.hayhurst,
stable
On Tue, 10 Nov 2026 22:48:20 -0800, Dmitry Torokhov wrote:
> Force-feedback teardown currently runs only in the force-feedback
> destroy callback, which is deferred until the last open event handle
> is closed. If userspace holds an open handle across USB disconnect or
> driver unbind, device removal frees driver state and destroys the
> command mutex while queued force-feedback work is still active, causing
> use-after-free errors.
Hi Dmitry,
I was auditing some HID drivers and found this exact same use-after-free.
My analysis agrees with yours, but I am replying as I think there is
a stable-tree gap -- this patch does not have Cc: stable and your cover
letter also only explicitly mentions the "first 14 patches". This UAF is
worse than a crash and can lead to LPE if exploited.
I realised this patch cannot be applied to any released stable tree as-is,
which explains the stable-tree gap. It needs ff->stop, added by
ef166ce08801 ("Input: stop force-feedback timer when unregistering input
devices") in v7.2-rc1, and it also needs context from earlier patches in
this series: g920_input_open() from 03/33, hidpp_dev_groups from 20/33 and
the reshaped hidpp_ff_destroy() from 18/33. So the UAF fix cannot reach
stable as this patch, and each tree would need a hand-written backport.
Every LTS kernel is affected: 6.18.y, 6.12.y, 6.6.y, 6.1.y, 5.15.y and
5.10.y. In all of them hidpp_ff_destroy() still destroys the workqueue
while hidpp_remove() never drains it, g920_get_config() still runs from
hidpp_probe() so FF init succeeds and the workqueue exists, and none of
them has ff->stop.
Note that I only mention LTS kernels as 7.2.y is EOL. 7.3.y is a special
case and only needs the driver-side context from 03/33, 18/33 and 20/33
since it has the necessary commits brought over from 7.2-rc1. To resolve
the LTS kernel gap, I would suggest writing a minimal stable-only fix to
resolve the UAF in the remaining LTS kernels.
The alternative is a hand-written backport of 22/33 plus its necessary
context (ef166ce08801, 03/33, 18/33 and 20/33) -- which seems like a mess
to do.
If you'd like, I already have a patch for stable trees that I can
contribute. Let me know your thoughts, thanks!
Cheers,
Wei Jie
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2 22/33] HID: logitech-hidpp: shut down G920 force feedback on input unregister
2026-11-19 6:43 ` [PATCH v2 22/33] HID: logitech-hidpp: shut down G920 force feedback on input unregister Wei Jie Law
@ 2026-11-23 18:54 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-11-23 18:54 UTC (permalink / raw)
To: Wei Jie Law
Cc: andrew.smirnov, bentiss, e.velds, gideonheinz02, hadess, hansg,
jikos, lains, linux-input, linux-kernel, stuart.a.hayhurst,
stable
Hi Wei Jie,
On Thu, Nov 19, 2026 at 02:43:02PM +0800, Wei Jie Law wrote:
...
> I was auditing some HID drivers and found this exact same use-after-free.
> My analysis agrees with yours, but I am replying as I think there is
> a stable-tree gap -- this patch does not have Cc: stable and your cover
> letter also only explicitly mentions the "first 14 patches". This UAF is
> worse than a crash and can lead to LPE if exploited.
...
> If you'd like, I already have a patch for stable trees that I can
> contribute. Let me know your thoughts, thanks!
I actually dropped this patch in v3 in favor of fixing the lifetime in
input core across all force-feedback drivers: see commit 2ae35f090d02
("Input: destroy force-feedback device on input unregistration") in
v7.4-rc4, which is marked for stable.
With input_ff_destroy() called from __input_unregister_device(),
hidpp_ff_destroy() runs synchronously during hidinput_disconnect() while
the driver and HID device state are still alive, so no G920-specific
stable workaround is needed.
2ae35f090d02 will apply cleanly to 7.3.y, and for 6.18.y and older LTS
trees (which do not have ef166ce08801 and ff->stop) it will just need a
trivial backport dropping the ff->stop removal hunks.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-23 18:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261110-hid-logitech-hidpp-v2-22-30743e91d83b@gmail.com>
2026-11-19 6:43 ` [PATCH v2 22/33] HID: logitech-hidpp: shut down G920 force feedback on input unregister Wei Jie Law
2026-11-23 18:54 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox