{"id":"CVE-2024-36894","aliases":["CVE-2024-36894"],"related":[],"kind":"vulnerability","state":"published","title":"usb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nusb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete\n\nFFS based applications can utilize the aio_cancel() callback to dequeue\npending USB requests submitted to the UDC.  There is a scenario where the\nFFS application issues an AIO cancel call, while the UDC is handling a\nsoft disconnect.  For a DWC3 based implementation, the callstack looks\nlike the following:\n\n    DWC3 Gadget                               FFS Application\ndwc3_gadget_soft_disconnect()              ...\n  --> dwc3_stop_active_transfers()\n    --> dwc3_gadget_giveback(-ESHUTDOWN)\n      --> ffs_epfile_async_io_complete()   ffs_aio_cancel()\n        --> usb_ep_free_request()            --> usb_ep_dequeue()\n\nThere is currently no locking implemented between the AIO completion\nhandler and AIO cancel, so the issue occurs if the completion routine is\nrunning in parallel to an AIO cancel call coming from the FFS application.\nAs the completion call frees the USB request (io_data->req) the FFS\napplication is also referencing it for the usb_ep_dequeue() call.  This can\nlead to accessing a stale/hanging pointer.\n\ncommit b566d38857fc (\"usb: gadget: f_fs: use io_data->status consistently\")\nrelocated the usb_ep_free_request() into ffs_epfile_async_io_complete().\nHowever, in order to properly implement locking to mitigate this issue, the\nspinlock can't be added to ffs_epfile_async_io_complete(), as\nusb_ep_dequeue() (if successfully dequeuing a USB request) will call the\nfunction driver's completion handler in the same context.  Hence, leading\ninto a deadlock.\n\nFix this issue by moving the usb_ep_free_request() back to\nffs_user_copy_worker(), and ensuring that it explicitly sets io_data->req\nto NULL after freeing it within the ffs->eps_lock.  This resolves the race\ncondition above, as the ffs_aio_cancel() routine will not continue\nattempting to dequeue a request that has already been freed, or the\nffs_user_copy_work() not freeing the USB request until the AIO cancel is\ndone referencing it.\n\nThis fix depends on\n  commit b566d38857fc (\"usb: gadget: f_fs: use io_data->status\n  consistently\")","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nusb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete\n\nFFS based applications can utilize the aio_cancel() callback to dequeue\npending USB requests submitted to the UDC.  There is a scenario where the\nFFS application issues an AIO cancel call, while the UDC is handling a\nsoft disconnect.  For a DWC3 based implementation, the callstack looks\nlike the following:\n\n    DWC3 Gadget                               FFS Application\ndwc3_gadget_soft_disconnect()              ...\n  --> dwc3_stop_active_transfers()\n    --> dwc3_gadget_giveback(-ESHUTDOWN)\n      --> ffs_epfile_async_io_complete()   ffs_aio_cancel()\n        --> usb_ep_free_request()            --> usb_ep_dequeue()\n\nThere is currently no locking implemented between the AIO completion\nhandler and AIO cancel, so the issue occurs if the completion routine is\nrunning in parallel to an AIO cancel call coming from the FFS application.\nAs the completion call frees the USB request (io_data->req) the FFS\napplication is also referencing it for the usb_ep_dequeue() call.  This can\nlead to accessing a stale/hanging pointer.\n\ncommit b566d38857fc (\"usb: gadget: f_fs: use io_data->status consistently\")\nrelocated the usb_ep_free_request() into ffs_epfile_async_io_complete().\nHowever, in order to properly implement locking to mitigate this issue, the\nspinlock can't be added to ffs_epfile_async_io_complete(), as\nusb_ep_dequeue() (if successfully dequeuing a USB request) will call the\nfunction driver's completion handler in the same context.  Hence, leading\ninto a deadlock.\n\nFix this issue by moving the usb_ep_free_request() back to\nffs_user_copy_worker(), and ensuring that it explicitly sets io_data->req\nto NULL after freeing it within the ffs->eps_lock.  This resolves the race\ncondition above, as the ffs_aio_cancel() routine will not continue\nattempting to dequeue a request that has already been freed, or the\nffs_user_copy_work() not freeing the USB request until the AIO cancel is\ndone referencing it.\n\nThis fix depends on\n  commit b566d38857fc (\"usb: gadget: f_fs: use io_data->status\n  consistently\")","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: usb: gadget: f_fs: corrige la ejecución entre aio_cancel() y la solicitud AIO. Las aplicaciones basadas en FFS completas pueden utilizar la devolución de llamada aio_cancel() para quitar de la cola las solicitudes USB pendientes enviadas al UDC. Existe un escenario en el que la aplicación FFS emite una llamada de cancelación de AIO, mientras el UDC maneja una desconexión suave. Para una implementación basada en DWC3, la pila de llamadas se parece a la siguiente: Aplicación DWC3 Gadget FFS dwc3_gadget_soft_disconnect() ... --&gt; dwc3_stop_active_transfers() --&gt; dwc3_gadget_giveback(-ESHUTDOWN) --&gt; ffs_epfile_async_io_complete() ffs_aio_cancel() --&gt; usb_ep_free_request () --&gt; usb_ep_dequeue() Actualmente no hay ningún bloqueo implementado entre el controlador de finalización de AIO y la cancelación de AIO, por lo que el problema ocurre si la rutina de finalización se ejecuta en paralelo a una llamada de cancelación de AIO proveniente de la aplicación FFS. A medida que la llamada de finalización libera la solicitud USB (io_data-&gt;req), la aplicación FFS también hace referencia a ella para la llamada usb_ep_dequeue(). Esto puede llevar a acceder a un puntero obsoleto/colgado. commit b566d38857fc (\"usb: gadget: f_fs: use io_data-&gt;status consistentemente\") reubicó usb_ep_free_request() en ffs_epfile_async_io_complete(). Sin embargo, para implementar correctamente el bloqueo para mitigar este problema, el spinlock no se puede agregar a ffs_epfile_async_io_complete(), ya que usb_ep_dequeue() (si se elimina con éxito una solicitud USB) llamará al controlador de finalización del controlador de función en el mismo contexto. De ahí que se llegue a un punto muerto. Solucione este problema moviendo usb_ep_free_request() de nuevo a ffs_user_copy_worker() y asegurándose de que establezca explícitamente io_data-&gt;req en NULL después de liberarlo dentro de ffs-&gt;eps_lock. Esto resuelve la condición de ejecución anterior, ya que la rutina ffs_aio_cancel() no continuará intentando sacar de la cola una solicitud que ya ha sido liberada, o ffs_user_copy_work() no liberará la solicitud USB hasta que la cancelación de AIO termine de hacer referencia a ella. Esta solución depende de el commit b566d38857fc (\"usb: gadget: f_fs: use io_data-&gt;status consistentemente\")","source":"nvd"}],"published":"2024-05-30T15:28:59.689Z","modified":"2026-10-15T01:18:23.303Z","severity":{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},"severities":[{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:P/AC:H/PR:L/UI:N/S:U/C:H/I:N/A:H","score":5.6,"rating":"MEDIUM"}],"cwes":["CWE-362"],"affected":[{"ranges":[{"type":"git","introduced":"2e4c7553cd6f9c68bb741582dcb614edcbeca70f","fixed":"f71a53148ce34898fef099b75386a3a9f4449311","status":"affected"},{"type":"git","introduced":"2e4c7553cd6f9c68bb741582dcb614edcbeca70f","fixed":"9e72ef59cbe61cd1243857a6418ca92104275867","status":"affected"},{"type":"git","introduced":"2e4c7553cd6f9c68bb741582dcb614edcbeca70f","fixed":"e500b1c4e29ad0bd1c1332a1eaea2913627a92dd","status":"affected"},{"type":"git","introduced":"2e4c7553cd6f9c68bb741582dcb614edcbeca70f","fixed":"3613e5023f09b3308545e9d1acda86017ebd418a","status":"affected"},{"type":"git","introduced":"2e4c7553cd6f9c68bb741582dcb614edcbeca70f","fixed":"a0fdccb1c9e027e3195f947f61aa87d6d0d2ea14","status":"affected"},{"type":"git","introduced":"2e4c7553cd6f9c68bb741582dcb614edcbeca70f","fixed":"73c05ad46bb4fbbdb346004651576d1c8dbcffbb","status":"affected"},{"type":"git","introduced":"2e4c7553cd6f9c68bb741582dcb614edcbeca70f","fixed":"d7461830823242702f5d84084bcccb25159003f4","status":"affected"},{"type":"git","introduced":"2e4c7553cd6f9c68bb741582dcb614edcbeca70f","fixed":"24729b307eefcd7c476065cd7351c1a018082c19","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"3.15","status":"affected"},{"type":"semver","introduced":"0","fixed":"3.15","status":"unaffected"},{"type":"semver","introduced":"4.19.317","lastAffected":"4.19.*","status":"unaffected"},{"type":"semver","introduced":"5.4.279","lastAffected":"5.4.*","status":"unaffected"},{"type":"semver","introduced":"5.10.221","lastAffected":"5.10.*","status":"unaffected"},{"type":"semver","introduced":"5.15.162","lastAffected":"5.15.*","status":"unaffected"},{"type":"semver","introduced":"6.1.95","lastAffected":"6.1.*","status":"unaffected"},{"type":"semver","introduced":"6.6.31","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.8.10","lastAffected":"6.8.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"6.9","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"2e4c7553cd6f","fixed":"73c05ad46bb4","status":"affected"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:-:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"2e4c7553cd6f","fixed":"d74618308232","status":"affected"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:-:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"2e4c7553cd6f","fixed":"24729b307eef","status":"affected"},{"type":"custom","introduced":"2e4c7553cd6f","fixed":"f71a53148ce3","status":"affected"},{"type":"custom","introduced":"2e4c7553cd6f","fixed":"9e72ef59cbe6","status":"affected"},{"type":"custom","introduced":"2e4c7553cd6f","fixed":"e500b1c4e29a","status":"affected"},{"type":"custom","introduced":"2e4c7553cd6f","fixed":"3613e5023f09","status":"affected"},{"type":"custom","introduced":"2e4c7553cd6f","fixed":"a0fdccb1c9e0","status":"affected"},{"version":"3.15","status":"affected"},{"type":"custom","introduced":"0","fixed":"3.15","status":"unaffected"},{"type":"custom","introduced":"4.19.317","lastAffected":"4.20","status":"unaffected"},{"type":"custom","introduced":"5.4.279","lastAffected":"5.5","status":"unaffected"},{"type":"custom","introduced":"5.10.221","lastAffected":"5.11","status":"unaffected"},{"type":"custom","introduced":"5.15.162","lastAffected":"5.16","status":"unaffected"},{"type":"custom","introduced":"6.1.95","lastAffected":"6.2","status":"unaffected"},{"type":"custom","introduced":"6.6.31","lastAffected":"6.7","status":"unaffected"},{"type":"custom","introduced":"6.8.10","lastAffected":"6.9","status":"unaffected"},{"type":"custom","introduced":"6.9","lastAffected":"*","status":"unaffected"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:-:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"3.15","fixed":"4.19.317"},{"status":"affected","introduced":"4.20","fixed":"5.4.279"},{"status":"affected","introduced":"5.5","fixed":"5.10.221"},{"status":"affected","introduced":"5.11","fixed":"5.15.162"},{"status":"affected","introduced":"5.16","fixed":"6.1.95"},{"status":"affected","introduced":"6.2","fixed":"6.6.31"},{"status":"affected","introduced":"6.7","fixed":"6.8.10"},{"status":"affected","version":"6.9"},{"status":"affected","version":"6.9"},{"status":"affected","version":"6.9"},{"status":"affected","version":"6.9"},{"status":"affected","version":"6.9"},{"status":"affected","version":"6.9"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/f71a53148ce34898fef099b75386a3a9f4449311","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/9e72ef59cbe61cd1243857a6418ca92104275867","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/e500b1c4e29ad0bd1c1332a1eaea2913627a92dd","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/3613e5023f09b3308545e9d1acda86017ebd418a","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/a0fdccb1c9e027e3195f947f61aa87d6d0d2ea14","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/73c05ad46bb4fbbdb346004651576d1c8dbcffbb","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/d7461830823242702f5d84084bcccb25159003f4","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/24729b307eefcd7c476065cd7351c1a018082c19","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://lists.debian.org/debian-lts-announce/2025/01/msg00001.html","tags":[],"sources":["cvelist","nvd"]},{"url":"https://cert-portal.siemens.com/productcert/html/ssa-265688.html","tags":[],"sources":["cvelist","nvd"]},{"url":"https://cert-portal.siemens.com/productcert/html/ssa-355557.html","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2024-06-03T15:53:00.949Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-36894","url":"https://www.cve.org/CVERecord?id=CVE-2024-36894","licence":"CVE Terms of Use","modified":"2026-10-15T00:42:38.622Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-36894","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-36894","licence":"Public domain","modified":"2026-10-15T01:18:23.303Z"}],"updatedAt":"2026-11-25T22:58:41.148Z","epss":{"score":0.00196,"percentile":0.09771,"date":"2026-12-01T12:00:22.000Z"}}