CVE-2026-99449 in Linux
Summary
by MITRE • 11/19/2026
In the Linux kernel, the following vulnerability has been resolved:
usb: gadget: fix refcount underflow in gadgetfs_bind() error path
gadgetfs_bind() calls get_dev() only on the success path, but gadgetfs_unbind() called from the enomem error label unconditionally calls put_dev(). When bind fails (e.g. ENOMEM), put_dev() fires without a matching get_dev(), leaving the refcount unbalanced.
A subsequent close of the ep0 file descriptor calls dev_release() -> put_dev() which hits zero and frees the object; then gadgetfs_kill_sb() calls put_dev(the_device) again on the already-freed pointer, triggering a refcount underflow and use-after-free.
Fix by calling get_dev() at the start of gadgetfs_bind(), before any error path that invokes gadgetfs_unbind(), so the reference is always balanced regardless of whether bind succeeds or fails.
If you want to get the best quality for vulnerability data then you always have to consider VulDB.
Analysis
by VulDB Data Team • 11/20/2026
The Linux kernel vulnerability identified in the usb: gadget subsystem involves a critical refcount underflow within the gadgetfs_bind function, which can lead to use-after-free conditions and potential system instability. This issue stems from an imbalance in reference counting logic during error handling paths. Specifically, the gadgetfs_bind function is responsible for binding USB gadget drivers to devices, but it only increments the device reference count via get_dev() when the operation succeeds. However, if the bind operation fails due to resource exhaustion or other errors such as ENOMEM, the code jumps to an error label that invokes gadgetfs_unbind(). This unbinding routine unconditionally calls put_dev(), which decrements the reference counter without a corresponding prior increment from get_dev(). Consequently, when binding fails, the device's refcount becomes negative or zero prematurely, creating an inconsistent state.
The operational impact of this flaw is severe because it directly compromises memory safety and system reliability. When a subsequent close operation occurs on the ep0 file descriptor associated with the gadget, the kernel invokes dev_release(), which in turn calls put_dev() again. Since the reference count was already unbalanced due to the earlier erroneous decrement during the failed bind attempt, this second call drives the refcount to zero and triggers the immediate freeing of the device object. However, the cleanup process does not stop there; gadgetfs_kill_sb is subsequently called as part of the superblock release sequence. This function attempts to put_dev on the same device pointer again. Because the memory has already been freed by the previous underflow-induced deallocation, this action constitutes a use-after-free vulnerability. An attacker or local user could potentially exploit this race condition or state inconsistency to execute arbitrary code, cause a kernel panic, or escalate privileges, depending on how the freed memory is reallocated and accessed.
From a technical standards perspective, this flaw aligns with CWE-362, which describes concurrent execution issues leading to race conditions, although in this specific case it is more accurately categorized under CWE-415: Double Free of Resource or CWE-401: Missing Release of Memory after Effective Lifetime if viewed from the initial imbalance. More precisely, the use-after-free aspect falls squarely under CWE-416: Use After Free. In terms of attack vectors and techniques, this vulnerability can be mapped to MITRE ATT&CK technique T1203: Exploitation for Defense Evasion or more directly to memory corruption exploits often associated with local privilege escalation paths where kernel objects are manipulated through file descriptor operations. The root cause is a logical error in control flow management within the USB gadget framework, specifically failing to ensure that resource acquisition and release are symmetric across all execution paths including failure modes.
To mitigate this vulnerability, the fix involves restructuring the reference counting logic within gadgetfs_bind(). By calling get_dev() at the very beginning of the function before any potential error path is taken, the code ensures that a valid reference exists regardless of whether the binding process succeeds or fails. This guarantees that when gadgetfs_unbind() subsequently calls put_dev(), it correctly balances the initial increment. This simple adjustment prevents the refcount from dropping to zero prematurely and eliminates the subsequent use-after-free scenario during device release and superblock kill operations. System administrators should apply kernel updates that include this patch immediately, particularly on systems running USB gadget configurations where dynamic binding and unbinding of devices are common practices. Regular auditing of error handling paths in kernel modules is also recommended to prevent similar reference counting discrepancies in other subsystems.