{"id":"CVE-2024-40927","aliases":["CVE-2024-40927"],"related":[],"kind":"vulnerability","state":"published","title":"xhci: Handle TD clearing for multiple streams case","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nxhci: Handle TD clearing for multiple streams case\n\nWhen multiple streams are in use, multiple TDs might be in flight when\nan endpoint is stopped. We need to issue a Set TR Dequeue Pointer for\neach, to ensure everything is reset properly and the caches cleared.\nChange the logic so that any N>1 TDs found active for different streams\nare deferred until after the first one is processed, calling\nxhci_invalidate_cancelled_tds() again from xhci_handle_cmd_set_deq() to\nqueue another command until we are done with all of them. Also change\nthe error/\"should never happen\" paths to ensure we at least clear any\naffected TDs, even if we can't issue a command to clear the hardware\ncache, and complain loudly with an xhci_warn() if this ever happens.\n\nThis problem case dates back to commit e9df17eb1408 (\"USB: xhci: Correct\nassumptions about number of rings per endpoint.\") early on in the XHCI\ndriver's life, when stream support was first added.\nIt was then identified but not fixed nor made into a warning in commit\n674f8438c121 (\"xhci: split handling halted endpoints into two steps\"),\nwhich added a FIXME comment for the problem case (without materially\nchanging the behavior as far as I can tell, though the new logic made\nthe problem more obvious).\n\nThen later, in commit 94f339147fc3 (\"xhci: Fix failure to give back some\ncached cancelled URBs.\"), it was acknowledged again.\n\n[Mathias: commit 94f339147fc3 (\"xhci: Fix failure to give back some cached\ncancelled URBs.\") was a targeted regression fix to the previously mentioned\npatch. Users reported issues with usb stuck after unmounting/disconnecting\nUAS devices. This rolled back the TD clearing of multiple streams to its\noriginal state.]\n\nApparently the commit author was aware of the problem (yet still chose\nto submit it): It was still mentioned as a FIXME, an xhci_dbg() was\nadded to log the problem condition, and the remaining issue was mentioned\nin the commit description. The choice of making the log type xhci_dbg()\nfor what is, at this point, a completely unhandled and known broken\ncondition is puzzling and unfortunate, as it guarantees that no actual\nusers would see the log in production, thereby making it nigh\nundebuggable (indeed, even if you turn on DEBUG, the message doesn't\nreally hint at there being a problem at all).\n\nIt took me *months* of random xHC crashes to finally find a reliable\nrepro and be able to do a deep dive debug session, which could all have\nbeen avoided had this unhandled, broken condition been actually reported\nwith a warning, as it should have been as a bug intentionally left in\nunfixed (never mind that it shouldn't have been left in at all).\n\n> Another fix to solve clearing the caches of all stream rings with\n> cancelled TDs is needed, but not as urgent.\n\n3 years after that statement and 14 years after the original bug was\nintroduced, I think it's finally time to fix it. And maybe next time\nlet's not leave bugs unfixed (that are actually worse than the original\nbug), and let's actually get people to review kernel commits please.\n\nFixes xHC crashes and IOMMU faults with UAS devices when handling\nerrors/faults. Easiest repro is to use `hdparm` to mark an early sector\n(e.g. 1024) on a disk as bad, then `cat /dev/sdX > /dev/null` in a loop.\nAt least in the case of JMicron controllers, the read errors end up\nhaving to cancel two TDs (for two queued requests to different streams)\nand the one that didn't get cleared properly ends up faulting the xHC\nentirely when it tries to access DMA pages that have since been unmapped,\nreferred to by the stale TDs. This normally happens quickly (after two\nor three loops). After this fix, I left the `cat` in a loop running\novernight and experienced no xHC failures, with all read errors\nrecovered properly. Repro'd and tested on an Apple M1 Mac Mini\n(dwc3 host).\n\nOn systems without an IOMMU, this bug would instead silently corrupt\nfreed memory, making this a\n---truncated---","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nxhci: Handle TD clearing for multiple streams case\n\nWhen multiple streams are in use, multiple TDs might be in flight when\nan endpoint is stopped. We need to issue a Set TR Dequeue Pointer for\neach, to ensure everything is reset properly and the caches cleared.\nChange the logic so that any N>1 TDs found active for different streams\nare deferred until after the first one is processed, calling\nxhci_invalidate_cancelled_tds() again from xhci_handle_cmd_set_deq() to\nqueue another command until we are done with all of them. Also change\nthe error/\"should never happen\" paths to ensure we at least clear any\naffected TDs, even if we can't issue a command to clear the hardware\ncache, and complain loudly with an xhci_warn() if this ever happens.\n\nThis problem case dates back to commit e9df17eb1408 (\"USB: xhci: Correct\nassumptions about number of rings per endpoint.\") early on in the XHCI\ndriver's life, when stream support was first added.\nIt was then identified but not fixed nor made into a warning in commit\n674f8438c121 (\"xhci: split handling halted endpoints into two steps\"),\nwhich added a FIXME comment for the problem case (without materially\nchanging the behavior as far as I can tell, though the new logic made\nthe problem more obvious).\n\nThen later, in commit 94f339147fc3 (\"xhci: Fix failure to give back some\ncached cancelled URBs.\"), it was acknowledged again.\n\n[Mathias: commit 94f339147fc3 (\"xhci: Fix failure to give back some cached\ncancelled URBs.\") was a targeted regression fix to the previously mentioned\npatch. Users reported issues with usb stuck after unmounting/disconnecting\nUAS devices. This rolled back the TD clearing of multiple streams to its\noriginal state.]\n\nApparently the commit author was aware of the problem (yet still chose\nto submit it): It was still mentioned as a FIXME, an xhci_dbg() was\nadded to log the problem condition, and the remaining issue was mentioned\nin the commit description. The choice of making the log type xhci_dbg()\nfor what is, at this point, a completely unhandled and known broken\ncondition is puzzling and unfortunate, as it guarantees that no actual\nusers would see the log in production, thereby making it nigh\nundebuggable (indeed, even if you turn on DEBUG, the message doesn't\nreally hint at there being a problem at all).\n\nIt took me *months* of random xHC crashes to finally find a reliable\nrepro and be able to do a deep dive debug session, which could all have\nbeen avoided had this unhandled, broken condition been actually reported\nwith a warning, as it should have been as a bug intentionally left in\nunfixed (never mind that it shouldn't have been left in at all).\n\n> Another fix to solve clearing the caches of all stream rings with\n> cancelled TDs is needed, but not as urgent.\n\n3 years after that statement and 14 years after the original bug was\nintroduced, I think it's finally time to fix it. And maybe next time\nlet's not leave bugs unfixed (that are actually worse than the original\nbug), and let's actually get people to review kernel commits please.\n\nFixes xHC crashes and IOMMU faults with UAS devices when handling\nerrors/faults. Easiest repro is to use `hdparm` to mark an early sector\n(e.g. 1024) on a disk as bad, then `cat /dev/sdX > /dev/null` in a loop.\nAt least in the case of JMicron controllers, the read errors end up\nhaving to cancel two TDs (for two queued requests to different streams)\nand the one that didn't get cleared properly ends up faulting the xHC\nentirely when it tries to access DMA pages that have since been unmapped,\nreferred to by the stale TDs. This normally happens quickly (after two\nor three loops). After this fix, I left the `cat` in a loop running\novernight and experienced no xHC failures, with all read errors\nrecovered properly. Repro'd and tested on an Apple M1 Mac Mini\n(dwc3 host).\n\nOn systems without an IOMMU, this bug would instead silently corrupt\nfreed memory, making this a\n---truncated---","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: xhci: Manejar el borrado de TD para el caso de múltiples flujos Cuando se utilizan múltiples flujos, es posible que haya múltiples TD en vuelo cuando se detiene un endpoint. Necesitamos emitir un puntero de salida de cola TR para cada uno, para garantizar que todo se restablezca correctamente y se borren los cachés. Cambie la lógica para que cualquier N&gt;1 TD que se encuentre activo para diferentes flujos se difiera hasta después de que se procese el primero, llamando a xhci_invalidate_cancelled_tds() nuevamente desde xhci_handle_cmd_set_deq() para poner en cola otro comando hasta que hayamos terminado con todos ellos. También cambie las rutas de error/\"nunca debería suceder\" para asegurarnos de que al menos borramos los TD afectados, incluso si no podemos emitir un comando para borrar el caché del hardware, y quejarnos en voz alta con un xhci_warn() si esto alguna vez sucede. Este caso de problema se remonta al commit e9df17eb1408 (\"USB: xhci: Suposiciones correctas sobre el número de anillos por endpoint.\") al principio de la vida del controlador XHCI, cuando se agregó por primera vez el soporte de transmisión. Luego se identificó, pero no se solucionó ni se convirtió en una advertencia en el commit 674f8438c121 (\"xhci: dividir el manejo de endpoints detenidos en dos pasos\"), que agregó un comentario FIXME para el caso del problema (sin cambiar materialmente el comportamiento, hasta donde yo sé). , aunque la nueva lógica hizo que el problema fuera más obvio). Luego, más tarde, en el commit 94f339147fc3 (\"xhci: Se corrigió el error al devolver algunas URB canceladas en caché\"), se reconoció nuevamente. [Mathias: commit 94f339147fc3 (\"xhci: Se corrigió el error al devolver algunas URB canceladas en caché\") fue una solución de regresión específica para el parche mencionado anteriormente. Los usuarios informaron problemas con el USB atascado después de desmontar/desconectar dispositivos UAS. Esto revirtió la limpieza de TD de múltiples transmisiones a su estado original.] Aparentemente, el autor de el commit estaba al tanto del problema (pero aún así decidió enviarlo): todavía se mencionaba como FIXME, se agregó un xhci_dbg() para registrar el condición del problema y el problema restante se mencionó en la descripción de El commit. La elección de crear el tipo de registro xhci_dbg() para lo que, en este momento, es una condición rota completamente no controlada y conocida es desconcertante y desafortunada, ya que garantiza que ningún usuario real verá el registro en producción, lo que lo hace casi no depurable ( de hecho, incluso si activa DEBUG, el mensaje realmente no indica que haya ningún problema). Me tomó *meses* de fallas aleatorias de xHC para finalmente encontrar una reproducción confiable y poder realizar una sesión de depuración profunda, que podría haberse evitado si esta condición rota y no controlada se hubiera informado con una advertencia, como debería haber sido. ha sido un error que se dejó intencionalmente sin corregir (sin importar que no debería haberse dejado en absoluto). &gt; Se necesita otra solución para solucionar el borrado de los cachés de todos los anillos de transmisión con &gt; TD cancelados, pero no es tan urgente. 3 años después de esa declaración y 14 años después de que se introdujo el error original, creo que finalmente es hora de solucionarlo. Y tal vez la próxima vez no dejemos errores sin corregir (que en realidad son peores que el error original), y hagamos que la gente revise las confirmaciones del kernel, por favor. Soluciona fallas de xHC y fallas de IOMMU con dispositivos UAS al manejar errores/fallas. La reproducción más sencilla es usar `hdparm` para marcar un sector inicial (por ejemplo, 1024) en un disco como defectuoso, luego `cat /dev/sdX &gt; /dev/null` en un bucle. ---truncado---","source":"nvd"}],"published":"2024-07-12T12:25:07.101Z","modified":"2026-06-17T07:46:53.233Z","severity":{"scorer":"NVD","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":"NVD","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"}],"cwes":["CWE-416"],"affected":[{"ranges":[{"type":"git","introduced":"e9df17eb1408cfafa3d1844bfc7f22c7237b31b8","fixed":"26460c1afa311524f588e288a4941432f0de6228","status":"affected"},{"type":"git","introduced":"e9df17eb1408cfafa3d1844bfc7f22c7237b31b8","fixed":"633f72cb6124ecda97b641fbc119340bd88d51a9","status":"affected"},{"type":"git","introduced":"e9df17eb1408cfafa3d1844bfc7f22c7237b31b8","fixed":"949be4ec5835e0ccb3e2a8ab0e46179cb5512518","status":"affected"},{"type":"git","introduced":"e9df17eb1408cfafa3d1844bfc7f22c7237b31b8","fixed":"61593dc413c3655e4328a351555235bc3089486a","status":"affected"},{"type":"git","introduced":"e9df17eb1408cfafa3d1844bfc7f22c7237b31b8","fixed":"5ceac4402f5d975e5a01c806438eb4e554771577","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"2.6.35","status":"affected"},{"type":"semver","introduced":"0","fixed":"2.6.35","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.35","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.9.6","lastAffected":"6.9.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"6.10","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"2.6.35","fixed":"5.15.162"},{"status":"affected","introduced":"5.16","fixed":"6.1.95"},{"status":"affected","introduced":"6.2","fixed":"6.6.35"},{"status":"affected","introduced":"6.7","fixed":"6.9.6"},{"status":"affected","version":"6.10"},{"status":"affected","version":"6.10"},{"status":"affected","version":"6.10"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/26460c1afa311524f588e288a4941432f0de6228","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/633f72cb6124ecda97b641fbc119340bd88d51a9","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/949be4ec5835e0ccb3e2a8ab0e46179cb5512518","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/61593dc413c3655e4328a351555235bc3089486a","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/5ceac4402f5d975e5a01c806438eb4e554771577","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://lists.debian.org/debian-lts-announce/2025/01/msg00001.html","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2024-09-10T17:05:11.586Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-40927","url":"https://www.cve.org/CVERecord?id=CVE-2024-40927","licence":"CVE Terms of Use","modified":"2026-05-11T20:22:31.574Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-40927","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-40927","licence":"Public domain","modified":"2026-06-17T07:46:53.233Z"}],"updatedAt":"2026-11-25T22:58:42.843Z","epss":{"score":0.00292,"percentile":0.23397,"date":"2026-12-01T12:00:22.000Z"}}