CVE-2024-36894
Severity CVSS v4.0:
Pending analysis
Type:
CWE-362
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
Publication date:
30/05/2024
Last modified:
03/11/2025
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
usb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete<br />
<br />
FFS based applications can utilize the aio_cancel() callback to dequeue<br />
pending USB requests submitted to the UDC. There is a scenario where the<br />
FFS application issues an AIO cancel call, while the UDC is handling a<br />
soft disconnect. For a DWC3 based implementation, the callstack looks<br />
like the following:<br />
<br />
DWC3 Gadget FFS Application<br />
dwc3_gadget_soft_disconnect() ...<br />
--> dwc3_stop_active_transfers()<br />
--> dwc3_gadget_giveback(-ESHUTDOWN)<br />
--> ffs_epfile_async_io_complete() ffs_aio_cancel()<br />
--> usb_ep_free_request() --> usb_ep_dequeue()<br />
<br />
There is currently no locking implemented between the AIO completion<br />
handler and AIO cancel, so the issue occurs if the completion routine is<br />
running in parallel to an AIO cancel call coming from the FFS application.<br />
As the completion call frees the USB request (io_data->req) the FFS<br />
application is also referencing it for the usb_ep_dequeue() call. This can<br />
lead to accessing a stale/hanging pointer.<br />
<br />
commit b566d38857fc ("usb: gadget: f_fs: use io_data->status consistently")<br />
relocated the usb_ep_free_request() into ffs_epfile_async_io_complete().<br />
However, in order to properly implement locking to mitigate this issue, the<br />
spinlock can&#39;t be added to ffs_epfile_async_io_complete(), as<br />
usb_ep_dequeue() (if successfully dequeuing a USB request) will call the<br />
function driver&#39;s completion handler in the same context. Hence, leading<br />
into a deadlock.<br />
<br />
Fix this issue by moving the usb_ep_free_request() back to<br />
ffs_user_copy_worker(), and ensuring that it explicitly sets io_data->req<br />
to NULL after freeing it within the ffs->eps_lock. This resolves the race<br />
condition above, as the ffs_aio_cancel() routine will not continue<br />
attempting to dequeue a request that has already been freed, or the<br />
ffs_user_copy_work() not freeing the USB request until the AIO cancel is<br />
done referencing it.<br />
<br />
This fix depends on<br />
commit b566d38857fc ("usb: gadget: f_fs: use io_data->status<br />
consistently")
Impact
Base Score 3.x
5.60
Severity 3.x
MEDIUM
Vulnerable products and versions
| CPE | From | Up to |
|---|---|---|
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 3.15 (including) | 4.19.317 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.20 (including) | 5.4.279 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.5 (including) | 5.10.221 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.11 (including) | 5.15.162 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.16 (including) | 6.1.95 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.2 (including) | 6.6.31 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.7 (including) | 6.8.10 (excluding) |
| cpe:2.3:o:linux:linux_kernel:6.9:rc1:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.9:rc2:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.9:rc3:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.9:rc4:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.9:rc5:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.9:rc6:*:*:*:*:*:* |
To consult the complete list of CPE names with products and versions, see this page
References to Advisories, Solutions, and Tools
- https://git.kernel.org/stable/c/24729b307eefcd7c476065cd7351c1a018082c19
- https://git.kernel.org/stable/c/3613e5023f09b3308545e9d1acda86017ebd418a
- https://git.kernel.org/stable/c/73c05ad46bb4fbbdb346004651576d1c8dbcffbb
- https://git.kernel.org/stable/c/9e72ef59cbe61cd1243857a6418ca92104275867
- https://git.kernel.org/stable/c/a0fdccb1c9e027e3195f947f61aa87d6d0d2ea14
- https://git.kernel.org/stable/c/d7461830823242702f5d84084bcccb25159003f4
- https://git.kernel.org/stable/c/e500b1c4e29ad0bd1c1332a1eaea2913627a92dd
- https://git.kernel.org/stable/c/f71a53148ce34898fef099b75386a3a9f4449311
- https://git.kernel.org/stable/c/24729b307eefcd7c476065cd7351c1a018082c19
- https://git.kernel.org/stable/c/3613e5023f09b3308545e9d1acda86017ebd418a
- https://git.kernel.org/stable/c/73c05ad46bb4fbbdb346004651576d1c8dbcffbb
- https://git.kernel.org/stable/c/9e72ef59cbe61cd1243857a6418ca92104275867
- https://git.kernel.org/stable/c/a0fdccb1c9e027e3195f947f61aa87d6d0d2ea14
- https://git.kernel.org/stable/c/d7461830823242702f5d84084bcccb25159003f4
- https://git.kernel.org/stable/c/e500b1c4e29ad0bd1c1332a1eaea2913627a92dd
- https://git.kernel.org/stable/c/f71a53148ce34898fef099b75386a3a9f4449311
- https://lists.debian.org/debian-lts-announce/2025/01/msg00001.html



