CVE-2024-40927: xhci: Handle TD clearing for multiple streams case

Published Jul 12, 2024
·
Updated

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 xhciinvalidatecancelledtds() again from xhcihandlecmdsetdeq() 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 xhciwarn() 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 xhcidbg() was added to log the problem condition, and the remaining issue was mentioned in the commit description. The choice of making the log type xhcidbg() 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---

Other sources

Linux Kernel is vulnerable to a denial of service caused by a deadlock in ieee80211stapsdeliverwakeup() in xhci-ring.c . A local authenticated attacker could exploit this vulnerability to cause a denial of service.

IBM

Affected Software

18 affected componentsFixes available
redhat/kernel<5.15.162
5.15.162
redhat/kernel<6.1.95
6.1.95
redhat/kernel<6.6.35
6.6.35
redhat/kernel<6.9.6
6.9.6
redhat/kernel<6.10
6.10
IBM Security Verify Governance<=ISVG 10.0.2
IBM Security Verify Governance, Identity Manager Software Stack<=ISVG 10.0.2
IBM Security Verify Governance, Identity Manager Virtual Appliance<=ISVG 10.0.2
IBM Security Verify Governance Identity Manager Container<=ISVG 10.0.2
debian/linux<=5.10.223-1, <=5.10.234-1
6.1.129-16.1.135-16.12.25-1
debian/linux-6.1
6.1.129-1~deb11u1
Linux Linux kernel>=2.6.35<5.15.162
Linux Linux kernel>=5.16<6.1.95
Linux Linux kernel>=6.2<6.6.35
Linux Linux kernel>=6.7<6.9.6
Linux Linux kernel=6.10-rc1
Linux Linux kernel=6.10-rc2
Linux Linux kernel=6.10-rc3

Event History

Jul 12, 2024
CVE Published
via MITRE·12:25 PM
Data Sourced
via MITRE·12:25 PM
Description
Data Sourced
via NVD·01:15 PM
Description
Data Sourced
via NVD·01:15 PM
RemedySeverityWeaknessAffected Software
Apr 27, 2025
Data Sourced
via Ubuntu·05:24 PM
RemedyDescriptionSeverityAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-40927?

The severity of CVE-2024-40927 is currently unspecified, but it addresses a kernel vulnerability that could potentially affect system stability.

2

How do I fix CVE-2024-40927?

To fix CVE-2024-40927, update to the specified remedied versions of the Linux kernel: 5.15.162, 6.1.95, 6.6.35, 6.9.6, 6.10 for Red Hat, or respective updates for Debian.

3

What versions of the Linux kernel are affected by CVE-2024-40927?

CVE-2024-40927 affects specific versions of the Linux kernel including but not limited to older versions prior to 5.15.162 and specific versions found under the Red Hat and Debian kernels.

4

Is CVE-2024-40927 related to USB functionality in the Linux kernel?

Yes, CVE-2024-40927 relates to the xHCI USB host controller functionality where handling multiple streams may present vulnerabilities.

5

What is the impact of not addressing CVE-2024-40927?

Not addressing CVE-2024-40927 could lead to systems experiencing undefined behavior or stability issues when handling multiple USB streams.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203