CVE-2024-40927

In the Linux kernel, the following vulnerability has been resolved: xhci: Handle TD clearing for multiple streams case When multiple streams are in use, multiple TDs might be in flight when an endpoint is stopped. We need to issue a Set TR Dequeue Pointer for each, to ensure everything is reset properly and the caches cleared. Change the logic so that any N>1 TDs found active for different streams are deferred until after the first one is processed, calling xhci_invalidate_cancelled_tds() again from xhci_handle_cmd_set_deq() to queue another command until we are done with all of them. Also change the error/"should never happen" paths to ensure we at least clear any affected TDs, even if we can't issue a command to clear the hardware cache, and complain loudly with an xhci_warn() if this ever happens. This problem case dates back to commit e9df17eb1408 ("USB: xhci: Correct assumptions about number of rings per endpoint.") early on in the XHCI driver's life, when stream support was first added. It was then identified but not fixed nor made into a warning in commit 674f8438c121 ("xhci: split handling halted endpoints into two steps"), which added a FIXME comment for the problem case (without materially changing the behavior as far as I can tell, though the new logic made the problem more obvious). Then later, in commit 94f339147fc3 ("xhci: Fix failure to give back some cached cancelled URBs."), it was acknowledged again. [Mathias: commit 94f339147fc3 ("xhci: Fix failure to give back some cached cancelled URBs.") was a targeted regression fix to the previously mentioned patch. Users reported issues with usb stuck after unmounting/disconnecting UAS devices. This rolled back the TD clearing of multiple streams to its original state.] Apparently the commit author was aware of the problem (yet still chose to submit it): It was still mentioned as a FIXME, an xhci_dbg() was added to log the problem condition, and the remaining issue was mentioned in the commit description. The choice of making the log type xhci_dbg() for what is, at this point, a completely unhandled and known broken condition is puzzling and unfortunate, as it guarantees that no actual users would see the log in production, thereby making it nigh undebuggable (indeed, even if you turn on DEBUG, the message doesn't really hint at there being a problem at all). It took me *months* of random xHC crashes to finally find a reliable repro and be able to do a deep dive debug session, which could all have been avoided had this unhandled, broken condition been actually reported with a warning, as it should have been as a bug intentionally left in unfixed (never mind that it shouldn't have been left in at all). > Another fix to solve clearing the caches of all stream rings with > cancelled TDs is needed, but not as urgent. 3 years after that statement and 14 years after the original bug was introduced, I think it's finally time to fix it. And maybe next time let's not leave bugs unfixed (that are actually worse than the original bug), and let's actually get people to review kernel commits please. Fixes xHC crashes and IOMMU faults with UAS devices when handling errors/faults. Easiest repro is to use `hdparm` to mark an early sector (e.g. 1024) on a disk as bad, then `cat /dev/sdX > /dev/null` in a loop. At least in the case of JMicron controllers, the read errors end up having to cancel two TDs (for two queued requests to different streams) and the one that didn't get cleared properly ends up faulting the xHC entirely when it tries to access DMA pages that have since been unmapped, referred to by the stale TDs. This normally happens quickly (after two or three loops). After this fix, I left the `cat` in a loop running overnight and experienced no xHC failures, with all read errors recovered properly. Repro'd and tested on an Apple M1 Mac Mini (dwc3 host). On systems without an IOMMU, this bug would instead silently corrupt freed memory, making this a ---truncated---
Configurations

Configuration 1 (hide)

OR cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.10:rc1:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.10:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.10:rc3:*:*:*:*:*:*

History

17 Sep 2025, 15:17

Type Values Removed Values Added
CWE CWE-416
First Time Linux linux Kernel
Linux
CVSS v2 : unknown
v3 : unknown
v2 : unknown
v3 : 7.8
CPE cpe:2.3:o:linux:linux_kernel:6.10:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.10:rc3:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.10:rc1:*:*:*:*:*:*
References () https://git.kernel.org/stable/c/26460c1afa311524f588e288a4941432f0de6228 - () https://git.kernel.org/stable/c/26460c1afa311524f588e288a4941432f0de6228 - Patch
References () https://git.kernel.org/stable/c/5ceac4402f5d975e5a01c806438eb4e554771577 - () https://git.kernel.org/stable/c/5ceac4402f5d975e5a01c806438eb4e554771577 - Patch
References () https://git.kernel.org/stable/c/61593dc413c3655e4328a351555235bc3089486a - () https://git.kernel.org/stable/c/61593dc413c3655e4328a351555235bc3089486a - Patch
References () https://git.kernel.org/stable/c/633f72cb6124ecda97b641fbc119340bd88d51a9 - () https://git.kernel.org/stable/c/633f72cb6124ecda97b641fbc119340bd88d51a9 - Patch
References () https://git.kernel.org/stable/c/949be4ec5835e0ccb3e2a8ab0e46179cb5512518 - () https://git.kernel.org/stable/c/949be4ec5835e0ccb3e2a8ab0e46179cb5512518 - Patch

21 Nov 2024, 09:31

Type Values Removed Values Added
References () https://git.kernel.org/stable/c/26460c1afa311524f588e288a4941432f0de6228 - () https://git.kernel.org/stable/c/26460c1afa311524f588e288a4941432f0de6228 -
References () https://git.kernel.org/stable/c/5ceac4402f5d975e5a01c806438eb4e554771577 - () https://git.kernel.org/stable/c/5ceac4402f5d975e5a01c806438eb4e554771577 -
References () https://git.kernel.org/stable/c/61593dc413c3655e4328a351555235bc3089486a - () https://git.kernel.org/stable/c/61593dc413c3655e4328a351555235bc3089486a -
References () https://git.kernel.org/stable/c/633f72cb6124ecda97b641fbc119340bd88d51a9 - () https://git.kernel.org/stable/c/633f72cb6124ecda97b641fbc119340bd88d51a9 -
References () https://git.kernel.org/stable/c/949be4ec5835e0ccb3e2a8ab0e46179cb5512518 - () https://git.kernel.org/stable/c/949be4ec5835e0ccb3e2a8ab0e46179cb5512518 -
Summary
  • (es) 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>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). > Se necesita otra solución para solucionar el borrado de los cachés de todos los anillos de transmisión con > 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 > /dev/null` en un bucle. ---truncado---

12 Jul 2024, 13:15

Type Values Removed Values Added
New CVE

Information

Published : 2024-07-12 13:15

Updated : 2025-09-17 15:17


NVD link : CVE-2024-40927

Mitre link : CVE-2024-40927

CVE.ORG link : CVE-2024-40927


JSON object : View

Products Affected

linux

  • linux_kernel
CWE
CWE-416

Use After Free