Re: [PATCH v2 22/33] HID: logitech-hidpp: shut down G920 force feedback on input unregister

From: Wei Jie Law

Date: Thu Nov 19 2026 - 01:43:38 EST


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