CVE-2022-50568

usb: gadget: f_hid: fix f_hidg lifetime vs cdev

State
Published
Severity
Not scored
Published
Oct 22, 2025
Updated
May 11, 2026
Reserved
Oct 22, 2025

Read the record on cve.org

Description

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.

Scores

The record has no CVSS score.

Weaknesses

The record names no weakness.

Affected Products

ProductVersions
LinuxLinux
  • 71adf118946957839a13aa4d1094183e05c6c094 to before 1cd7f156f6389918f760687fbbf133c86da93162Affected
  • 71adf118946957839a13aa4d1094183e05c6c094 to before c78c87c4e389b62f8892af7f59857447aa6d9797Affected
  • 71adf118946957839a13aa4d1094183e05c6c094 to before 1b6a53e447ec3d81623610c8c7ec5082b47dfdceAffected
  • 71adf118946957839a13aa4d1094183e05c6c094 to before d3136b79705c2e3bba9c76adc5628af0215d798eAffected
  • 71adf118946957839a13aa4d1094183e05c6c094 to before 9e4b85d815b14bd4db2deea2a54264a23de8b896Affected
  • 71adf118946957839a13aa4d1094183e05c6c094 to before 9e08b7f5fa00e9d550851352bd0d1ba74ccffef2Affected
  • 71adf118946957839a13aa4d1094183e05c6c094 to before 89ff3dfac604614287ad5aad9370c3f984ea3f4bAffected
LinuxLinux
  • 2.6.35Affected
  • before 2.6.35Not affected
  • 4.19.270 through 4.19.*Not affected
  • 5.4.229 through 5.4.*Not affected
  • 5.10.163 through 5.10.*Not affected
  • 5.15.86 through 5.15.*Not affected
  • 6.0.16 through 6.0.*Not affected
  • 6.1.2 through 6.1.*Not affected
  • 6.2 and laterNot affected

References

Every record here comes from the CVE Program’s CVE List. © 1999–2026 The MITRE Corporation. CVE is a registered trademark of The MITRE Corporation. The records are reproduced under the CVE Program terms of use.