usb: gadget: fix refcount underflow in gadgetfs_bind() error path
No exploitation in the wild has been reported. EPSS puts the chance of exploitation in the next 30 days at 0%. Fixed in Kernel e7e89759445e97ccb445758c6c8d5caed4eb42f9, Kernel a28791bdb256abd0f338a9b32a95392907d1c987, Kernel adb693d0369cd7f08f9424588fdd1f613c22d43b and 4 more.
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.
Affected
Vendors, products and packages with version ranges
| Vendor | Product | Versions | Fixed |
|---|---|---|---|
| Linux | Kernel | >=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 <e7e89759445e97ccb445758c6c8d5caed4eb42f9, >=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 <a28791bdb256abd0f338a9b32a95392907d1c987, >=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 <adb693d0369cd7f08f9424588fdd1f613c22d43b, >=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 <cb3b441f2698455a48e9a023d5f7f4e3fcb94c73, =2.6.12 | e7e89759445e97ccb445758c6c8d5caed4eb42f9, a28791bdb256abd0f338a9b32a95392907d1c987, adb693d0369cd7f08f9424588fdd1f613c22d43b, cb3b441f2698455a48e9a023d5f7f4e3fcb94c73 |
| linux-kernel: Kernel | >=6.13.0 <6.18.61, >=6.19.0 <7.3.2, >=2.6.12 <6.12.117 | 6.18.61, 7.3.2, 6.12.117 |
Timeline
Every event on this vulnerability
Related
Other vulnerabilities in Kernel, strongest first
Embed
A live severity badge for an advisory, README or ticket