VYPR
Unrated severityNVD Advisory· Published Oct 22, 2025· Updated Apr 15, 2026

CVE-2022-50568

CVE-2022-50568

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.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

In the Linux kernel's USB f_hid gadget driver, the cdev lifetime is not tied to the f_hidg struct, causing a use-after-free when the gadget is removed while /dev/hidgN is open.

Vulnerability

The Linux kernel's USB gadget function driver for HID (f_hid) contains a lifetime management flaw. The embedded struct cdev (character device) does not have its lifetime correctly tied to the enclosing struct f_hidg. This leads to a use-after-free condition if /dev/hidgN is held open while the USB gadget is deleted [1][2][3].

Exploitation

An attacker with local access to the system can exploit this by opening the /dev/hidgN device file (e.g., via exec 3<> /dev/hidg0) and then triggering the removal of the USB gadget (e.g., via gadget-vid-pid-remove). No special privileges beyond the ability to open the device file and trigger gadget removal are required, though the attacker must be able to interact with the USB gadget subsystem [1][2][3].

Impact

Successful exploitation results in a use-after-free, which can lead to memory corruption, system crash (denial of service), or potentially arbitrary code execution in kernel context. The vulnerability is rated with a CVSS score of 7.8 (High) [1][2][3].

Mitigation

The fix involves pulling the existing device object into struct f_hidg and using the cdev_device_{add,del}() helpers to properly tie the character device's lifetime to the gadget function. This ensures that the device object's lifetime matches struct f_hidg, preventing the use-after-free. The patch has been applied to the stable kernel tree [1][2][3].

AI Insight generated on May 19, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

1

Patches

7

Vulnerability mechanics

Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

7

News mentions

0

No linked articles in our index yet.