CVE-2022-50568

usb: gadget: f_hid: fix f_hidg lifetime vs cdev

published October 22, 2025

CVSS
—
EPSS
0%
Percentile
11.8
In the wild
Unconfirmed
What it is

In the Linux kernel, the following vulnerability has been resolved:

usb: gadget: f_hid: fix f_hidg lifetime vs cdev

The embedded struct cdev does not have its lifetime correctly tied to

the enclosing struct f_hidg, so there is a use-after-free if /dev/hidgN

is held open while the gadget is deleted.

This can readily be replicated with libusbgx's example programs (for

conciseness - operating directly via configfs is equivalent):

gadget-hid

exec 3<> /dev/hidg0

gadget-vid-pid-remove

exec 3<&-

Pull the existing device up in to struct f_hidg and make use of the

cdev_device_{add,del}() helpers. This changes the lifetime of the

device object to match struct f_hidg, but note that it is still added

and deleted at the same time.

The record
Technical detail
CVSS
Not scored
CVSS v4.0
Not supplied
EPSS
0.00220 · 11.8th percentile
Published
2025-10-22T13:23Z
EPSS history
Timeline
  • 22 OCT 13:23Z
    usb: gadget: f_hid: fix f_hidg lifetime vs cdev
    cvelistv5