Vulnerability · Published May 30, 2024 · Assigned by Linux

CVE-2024-36894usb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete

High 7.8

In plain English

A high-severity race condition in Linux from Linux. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.2% (higher than 9% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS 3.1)7.8High
Exploit odds (30 days)0.2%top 90.6% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

Official description

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")

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
Debian:12linux6.1.99-1DEBIAN-CVE-2024-36894
Debian:12linux6.1.99-1DSA-5731-1
Debian:13linux6.8.11-1DEBIAN-CVE-2024-36894
Debian:14linux6.8.11-1DEBIAN-CVE-2024-36894
Ubuntu:22.04:LTSlinux5.15.0-121.131USN-7007-1
Ubuntu:22.04:LTSlinux5.15.0-121.131UBUNTU-CVE-2024-36894
Ubuntu:24.04:LTSlinux6.8.0-40.40UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-allwinner-5.19no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-aws5.15.0-1069.75USN-7007-1
Ubuntu:22.04:LTSlinux-aws5.15.0-1069.75UBUNTU-CVE-2024-36894
Ubuntu:24.04:LTSlinux-aws6.8.0-1013.14UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-aws-5.19no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-aws-6.2no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-aws-6.5no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-aws-6.86.8.0-1013.14~22.04.1UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-azure5.15.0-1072.81USN-7009-1
Ubuntu:22.04:LTSlinux-azure5.15.0-1072.81UBUNTU-CVE-2024-36894
Ubuntu:24.04:LTSlinux-azure6.8.0-1012.14UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-azure-5.19no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-azure-6.2no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-azure-6.5no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-azure-6.86.8.0-1012.14~22.04.1UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-azure-fde5.15.0-1072.81.1USN-7009-1
Ubuntu:22.04:LTSlinux-azure-fde5.15.0-1072.81.1UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-azure-fde-5.19no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-azure-fde-6.2no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-gcp5.15.0-1068.76UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-gcp5.15.0-1068.76USN-7007-1
Ubuntu:24.04:LTSlinux-gcp6.8.0-1012.13UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-gcp-5.19no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-gcp-6.2no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-gcp-6.5no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-gcp-6.86.8.0-1012.13~22.04.1UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-gke5.15.0-1066.72UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-gke5.15.0-1066.72USN-7007-1
Ubuntu:24.04:LTSlinux-gke6.8.0-1008.11UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-gkeop5.15.0-1052.59USN-7007-1
Ubuntu:22.04:LTSlinux-gkeop5.15.0-1052.59UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-hwe-5.19no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-hwe-6.2no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-hwe-6.5no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-hwe-6.86.8.0-40.40~22.04.3UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-ibm5.15.0-1062.65UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-ibm5.15.0-1062.65USN-7007-1
Ubuntu:24.04:LTSlinux-ibm6.8.0-1010.10UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-ibm-6.86.8.0-1010.10~22.04.1UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-intel-iotg5.15.0-1064.70USN-7007-1
Ubuntu:22.04:LTSlinux-intel-iotg5.15.0-1064.70UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-kvm5.15.0-1066.71USN-7007-1
Ubuntu:22.04:LTSlinux-kvm5.15.0-1066.71UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-lowlatency5.15.0-121.131USN-7007-3
Ubuntu:22.04:LTSlinux-lowlatency5.15.0-121.131UBUNTU-CVE-2024-36894
Ubuntu:24.04:LTSlinux-lowlatency6.8.0-40.40.1UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-lowlatency-hwe-5.19no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.2no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.5no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.86.8.0-40.40.1~22.04.1UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-nvidia5.15.0-1064.65UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-nvidia5.15.0-1064.65USN-7007-1
Ubuntu:24.04:LTSlinux-nvidia6.8.0-1011.11UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-nvidia-6.2no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-nvidia-6.5no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-nvidia-6.86.8.0-1011.11~22.04.1UBUNTU-CVE-2024-36894
Ubuntu:24.04:LTSlinux-nvidia-lowlatency6.8.0-1011.11.1UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-nvidia-tegra5.15.0-1028.28UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-nvidia-tegra-igx5.15.0-1016.16UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-oem-5.17no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-oem-6.0no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-oem-6.1no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-oem-6.5no fix listedUBUNTU-CVE-2024-36894
Ubuntu:24.04:LTSlinux-oem-6.86.8.0-1010.10UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-oracle5.15.0-1067.73USN-7007-1
Ubuntu:22.04:LTSlinux-oracle5.15.0-1067.73UBUNTU-CVE-2024-36894
Ubuntu:24.04:LTSlinux-oracle6.8.0-1010.10UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-oracle-6.5no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-oracle-6.86.8.0-1010.10~22.04.1UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-raspi5.15.0-1062.65USN-7007-1
Ubuntu:22.04:LTSlinux-raspi5.15.0-1062.65UBUNTU-CVE-2024-36894
Ubuntu:24.04:LTSlinux-raspi6.8.0-1009.10UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-realtimeno fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-riscvno fix listedUBUNTU-CVE-2024-36894
Ubuntu:24.04:LTSlinux-riscv6.8.0-40.40.1UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-riscv-5.19no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-riscv-6.5no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-riscv-6.86.8.0-40.40.1~22.04.1UBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-starfive-5.19no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-starfive-6.2no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-starfive-6.5no fix listedUBUNTU-CVE-2024-36894
Ubuntu:22.04:LTSlinux-xilinx-zynqmp5.15.0-1035.39UBUNTU-CVE-2024-36894

Affected products (as reported)

VendorProductVersions
Linux Linux 2e4c7553cd6f9c68bb741582dcb614edcbeca70f – before f71a53148ce34898fef099b75386a3a9f44493112e4c7553cd6f9c68bb741582dcb614edcbeca70f – before 9e72ef59cbe61cd1243857a6418ca921042758672e4c7553cd6f9c68bb741582dcb614edcbeca70f – before e500b1c4e29ad0bd1c1332a1eaea2913627a92dd2e4c7553cd6f9c68bb741582dcb614edcbeca70f – before 3613e5023f09b3308545e9d1acda86017ebd418a2e4c7553cd6f9c68bb741582dcb614edcbeca70f – before a0fdccb1c9e027e3195f947f61aa87d6d0d2ea142e4c7553cd6f9c68bb741582dcb614edcbeca70f – before 73c05ad46bb4fbbdb346004651576d1c8dbcffbb2e4c7553cd6f9c68bb741582dcb614edcbeca70f – before d7461830823242702f5d84084bcccb25159003f42e4c7553cd6f9c68bb741582dcb614edcbeca70f – before 24729b307eefcd7c476065cd7351c1a018082c19
Linux Linux 3.15

Weakness: CWE-362 · Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

References