CVE-2024-36894: usb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete
In the Linux kernel, the following vulnerability has been resolved:
usb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete
FFS based applications can utilize the aio_cancel() callback to dequeue
pending USB requests submitted to the UDC. There is a scenario where the
FFS application issues an AIO cancel call, while the UDC is handling a
soft disconnect. For a DWC3 based implementation, the callstack looks
like the following:
DWC3 Gadget FFS Application
dwc3_gadget_soft_disconnect() ...
--> dwc3_stop_active_transfers()
--> dwc3_gadget_giveback(-ESHUTDOWN)
--> ffs_epfile_async_io_complete() ffs_aio_cancel()
--> usb_ep_free_request() --> usb_ep_dequeue()
There is currently no locking implemented between the AIO completion
handler and AIO cancel, so the issue occurs if the completion routine is
running in parallel to an AIO cancel call coming from the FFS application.
As the completion call frees the USB request (io_data->req) the FFS
application is also referencing it for the usb_ep_dequeue() call. This can
lead to accessing a stale/hanging pointer.
commit b566d38857fc ("usb: gadget: f_fs: use io_data->status consistently")
relocated the usb_ep_free_request() into ffs_epfile_async_io_complete().
However, in order to properly implement locking to mitigate this issue, the
spinlock can't be added to ffs_epfile_async_io_complete(), as
usb_ep_dequeue() (if successfully dequeuing a USB request) will call the
function driver's completion handler in the same context. Hence, leading
into a deadlock.
Fix this issue by moving the usb_ep_free_request() back to
ffs_user_copy_worker(), and ensuring that it explicitly sets io_data->req
to NULL after freeing it within the ffs->eps_lock. This resolves the race
condition above, as the ffs_aio_cancel() routine will not continue
attempting to dequeue a request that has already been freed, or the
ffs_user_copy_work() not freeing the USB request until the AIO cancel is
done referencing it.
This fix depends on
commit b566d38857fc ("usb: gadget: f_fs: use io_data->status
consistently")
Security readout for executives and security teams
Plain-English summary
CVE-2024-36894 is a Linux kernel race condition in USB gadget FunctionFS. Under specific timing, a USB request can be freed while another path still references it. Business urgency is moderate: exploitation requires physical access, low privileges, and high complexity, but successful abuse could affect confidentiality or availability.
Executive priority
Treat as a scheduled remediation item unless you operate exposed USB gadget or embedded Linux devices. Prioritize vendor patching for products that can be physically accessed by untrusted users.
Technical view
The flaw is CWE-362 in usb/gadget/f_fs. A race between ffs_aio_cancel() and asynchronous I/O completion during USB gadget soft disconnect can leave io_data->req stale. The kernel fix moves usb_ep_free_request() handling and clears the request pointer under ffs->eps_lock to prevent dequeueing or freeing already-released requests.
Likely exposure
Systems running affected Linux kernels with USB gadget FunctionFS support are most relevant. Exposure is more likely in embedded, appliance, mobile, or USB-device-mode systems than standard servers. Confirm by kernel branch, backported fixes, and vendor advisories.
Exploitation context
No KEV listing or provided source indicates active exploitation. CVSS is 5.6 with physical attack vector, low privileges, no user interaction, and high attack complexity. The bug is timing-sensitive and tied to USB gadget behavior.
Researcher notes
The source describes a use-after-free-style stale pointer risk caused by missing synchronization, not a broadly remote issue. Version exposure needs careful branch and backport review because downstream vendors may ship fixes without matching upstream version numbers.
Mitigation direction
Apply Linux kernel updates containing the referenced stable fixes.
Check Debian, Siemens, and other vendor advisories for product-specific guidance.
Prioritize exposed USB gadget or embedded systems over ordinary servers.
If no vendor fix is available, follow vendor-recommended compensating controls.
Validation and detection
Inventory Linux kernel versions and vendor patch levels.
Identify systems using USB gadget FunctionFS or device-mode USB.
Verify whether the relevant stable commits are present or backported.
Review vendor advisories for affected product mappings.
Document systems where USB gadget functionality is disabled or absent.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-362: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.