CVE-2026-99449: usb: gadget: fix refcount underflow in gadgetfs_bind() error path
From: Greg Kroah-Hartman <[email protected]>
Description
===========
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.
The Linux kernel CVE team has assigned CVE-2026-99449 to this issue.
Affected and fixed versions
===========================
Fixed in 6.12.117 with commit a28791bdb256abd0f338a9b32a95392907d1c987 Fixed in 6.18.61 with commit e7e89759445e97ccb445758c6c8d5caed4eb42f9 Fixed in 7.3.2 with commit adb693d0369cd7f08f9424588fdd1f613c22d43b Fixed in 7.4-rc1 with commit cb3b441f2698455a48e9a023d5f7f4e3fcb94c73
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2026-99449
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/usb/gadget/legacy/inode.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/a28791bdb256abd0f338a9b32a95392907d1c987 https://git.kernel.org/stable/c/e7e89759445e97ccb445758c6c8d5caed4eb42f9 https://git.kernel.org/stable/c/adb693d0369cd7f08f9424588fdd1f613c22d43b https://git.kernel.org/stable/c/cb3b441f2698455a48e9a023d5f7f4e3fcb94c73