Skip to content
Fencer Vulns
high 7.8

CVE-2024-40927 json

xhci: Handle TD clearing for multiple streams case

published 2024-07-12 2 y ago modified 2026-06-17 4 mo ago also EUVD-2024-38738

cvss
7.8
version 3.1, NVD
cisa kev
Not listed
not in CISA's catalog
epss
0.3%
EPSS 0.3% chance of exploitation in 30 days, percentile 21%
public exploits
0
none known

Summary

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

Patch / fix

  • Linux Linux 5.15.162, 6.1.95, 6.6.35, 6.9.6, 6.10
  • linux Debian 12 6.1.99-1
  • linux Debian 14, Debian 13 6.9.7-1

debian advisories DEBIAN-CVE-2024-40927

  • linux Ubuntu 22.04 LTS 5.15.0-121.131
  • linux Ubuntu 24.04 LTS 6.8.0-44.44
  • linux-aws Ubuntu 22.04 LTS 5.15.0-1069.75
  • linux-aws Ubuntu 24.04 LTS 6.8.0-1015.16
  • linux-gcp Ubuntu 22.04 LTS 5.15.0-1068.76
  • linux-gcp Ubuntu 24.04 LTS 6.8.0-1014.16
  • linux-gke Ubuntu 22.04 LTS 5.15.0-1066.72
  • linux-gke Ubuntu 24.04 LTS 6.8.0-1010.13

ubuntu advisories UBUNTU-CVE-2024-40927

Ubuntu security data © Canonical Ltd., from https://github.com/canonical/ubuntu-security-notices via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0

  • kernel-rt RHEL 8 4.18.0-553.16.1.rt7.357.el8_10
  • kernel-rt-kvm RHEL 8 4.18.0-553.16.1.rt7.357.el8_10
  • kernel-rt-core RHEL 8 4.18.0-553.16.1.rt7.357.el8_10
  • kernel-rt-modules RHEL 8 4.18.0-553.16.1.rt7.357.el8_10
  • kernel-rt-debug-kvm RHEL 8 4.18.0-553.16.1.rt7.357.el8_10
  • kernel-rt-debug-core RHEL 8 4.18.0-553.16.1.rt7.357.el8_10
  • kernel-rt-debug-modules RHEL 8 4.18.0-553.16.1.rt7.357.el8_10
  • kernel-rt-modules-extra RHEL 8 4.18.0-553.16.1.rt7.357.el8_10

red hat advisories RHSA-2024:5102RHSA-2024:6567RHSA-2024:5101

  • kernel-rt Linux Micro 6.0 6.4.0-10.1
  • kernel-source-rt Linux Micro 6.0 6.4.0-10.1
  • kernel-livepatch-MICRO-6-0-RT_Update_2 Linux Micro 6.0 1-1.1
  • kernel-source Linux Micro 6.0 6.4.0-19.1
  • kernel-default Linux Micro 6.0 6.4.0-19.1
  • kernel-kvmsmall Linux Micro 6.0 6.4.0-19.1
  • kernel-default-base Linux Micro 6.0 6.4.0-17.1.1.51
  • kernel-livepatch-MICRO-6-0_Update_2 Linux Micro 6.0 1-1.1

suse advisories SUSE-SU-2025:20047-1SUSE-SU-2025:20044-1SUSE-SU-2024:3383-1SUSE-SU-2024:3195-1SUSE-SU-2024:3194-1SUSE-SU-2024:2947-1

  • kernel AlmaLinux 9 5.14.0-427.35.1.el9_4
  • rv AlmaLinux 9 5.14.0-427.35.1.el9_4
  • perf AlmaLinux 9 5.14.0-427.35.1.el9_4
  • rtla AlmaLinux 9 5.14.0-427.35.1.el9_4
  • bpftool AlmaLinux 9 7.3.0-427.35.1.el9_4
  • libperf AlmaLinux 9 5.14.0-427.35.1.el9_4
  • kernel-rt AlmaLinux 9 5.14.0-427.35.1.el9_4
  • kernel-64k AlmaLinux 9 5.14.0-427.35.1.el9_4

almalinux advisories ALSA-2024:6567ALSA-2024:5101ALSA-2024:5102

  • kernel Rocky Linux 9 5.14.0-427.35.1.el9_4.cloud.1.0
  • kernel Rocky Linux 8 4.18.0-553.16.1.el8_10.cloud.0.1
  • kernel Rocky Linux 9 5.14.0-427.35.1.el9_4
  • kernel-rt Rocky Linux 8 4.18.0-553.16.1.rt7.357.el8_10
  • kernel Rocky Linux 8 4.18.0-553.16.1.el8_10

rocky linux advisories RXSA-2024:6567RXSA-2024:5101RLSA-2024:6567RLSA-2024:5102RLSA-2024:5101

Vendor advisories

What the vendors themselves say about their products: affected, fixed or not affected, and what to do.

red hat product security vex CVE-2024-40927 updated cvss 6.1

kernel: xhci: Handle TD clearing for multiple streams case

  • Red Hat Enterprise Linux 6 perf, kernel, python-perf, kernel-kdump, kernel-firmware, kernel-bootwrapper, +1 more Red Hat Enterprise Linux 7 perf, kernel, bpftool, kernel-rt, python-perf, kernel-kdump, +8 more
    affected: workaround, no fix planned “Out of support scope”
  • Red Hat Enterprise Linux 9 kernel-rt, kernel-rt-kvm, kernel-rt-core, kernel-rt-modules, kernel-rt-debug-kvm, kernel-rt-debug-core, +12 more
    affected: workaround, no fix planned “Will not fix”
  • Red Hat Enterprise Linux AppStream (v. 9) rv 5.14.0-427.35.1.el9_4, perf 5.14.0-427.35.1.el9_4, rtla 5.14.0-427.35.1.el9_4, kernel-devel-matched 5.14.0-427.35.1.el9_4, kernel-64k-devel-matched 5.14.0-427.35.1.el9_4, kernel-debug-devel-matched 5.14.0-427.35.1.el9_4, +6 more
    fixed: vendor fix RHSA-2024:6567
  • Red Hat Enterprise Linux BaseOS (v. 8) perf 4.18.0-553.16.1.el8_10, kernel 4.18.0-553.16.1.el8_10, bpftool 4.18.0-553.16.1.el8_10, kernel-core 4.18.0-553.16.1.el8_10, kernel-tools 4.18.0-553.16.1.el8_10, python3-perf 4.18.0-553.16.1.el8_10, +15 more
    fixed: vendor fix RHSA-2024:5101
  • Red Hat Enterprise Linux BaseOS (v. 9) bpftool 7.3.0-427.35.1.el9_4, kernel 5.14.0-427.35.1.el9_4, kernel-64k 5.14.0-427.35.1.el9_4, kernel-core 5.14.0-427.35.1.el9_4, kernel-tools 5.14.0-427.35.1.el9_4, python3-perf 5.14.0-427.35.1.el9_4, +28 more
    fixed: vendor fix RHSA-2024:6567
  • Red Hat Enterprise Linux CRB (v. 8) kernel-debuginfo-common-x86_64 4.18.0-553.16.1.el8_10, kernel-debuginfo-common-aarch64 4.18.0-553.16.1.el8_10, kernel-debuginfo-common-ppc64le 4.18.0-553.16.1.el8_10
    fixed: vendor fix RHSA-2024:5101
  • Red Hat Enterprise Linux CRB (v. 9) libperf 5.14.0-427.35.1.el9_4, kernel-debuginfo-common-s390x 5.14.0-427.35.1.el9_4, kernel-debuginfo-common-x86_64 5.14.0-427.35.1.el9_4, kernel-debuginfo-common-aarch64 5.14.0-427.35.1.el9_4, kernel-debuginfo-common-ppc64le 5.14.0-427.35.1.el9_4
    fixed: vendor fix RHSA-2024:6567
  • Red Hat Enterprise Linux NFV (v. 8) kernel-rt 4.18.0-553.16.1.rt7.357.el8_10, kernel-rt-kvm 4.18.0-553.16.1.rt7.357.el8_10, kernel-rt-core 4.18.0-553.16.1.rt7.357.el8_10, kernel-rt-modules 4.18.0-553.16.1.rt7.357.el8_10, kernel-rt-debug-kvm 4.18.0-553.16.1.rt7.357.el8_10, kernel-rt-debug-core 4.18.0-553.16.1.rt7.357.el8_10, +4 more
    fixed: vendor fix RHSA-2024:5102
show 3 more
  • Red Hat Enterprise Linux NFV (v. 9) kernel-rt 5.14.0-427.35.1.el9_4, kernel-rt-kvm 5.14.0-427.35.1.el9_4, kernel-rt-core 5.14.0-427.35.1.el9_4, kernel-rt-modules 5.14.0-427.35.1.el9_4, kernel-rt-debug-kvm 5.14.0-427.35.1.el9_4, kernel-rt-debug-core 5.14.0-427.35.1.el9_4, +6 more
    fixed: vendor fix RHSA-2024:6567
  • Red Hat Enterprise Linux RT (v. 8) kernel-rt 4.18.0-553.16.1.rt7.357.el8_10, kernel-rt-core 4.18.0-553.16.1.rt7.357.el8_10, kernel-rt-modules 4.18.0-553.16.1.rt7.357.el8_10, kernel-rt-debug-core 4.18.0-553.16.1.rt7.357.el8_10, kernel-rt-debug-modules 4.18.0-553.16.1.rt7.357.el8_10, kernel-rt-modules-extra 4.18.0-553.16.1.rt7.357.el8_10, +2 more
    fixed: vendor fix RHSA-2024:5102
  • Red Hat Enterprise Linux RT (v. 9) kernel-rt 5.14.0-427.35.1.el9_4, kernel-rt-core 5.14.0-427.35.1.el9_4, kernel-rt-modules 5.14.0-427.35.1.el9_4, kernel-rt-debug-core 5.14.0-427.35.1.el9_4, kernel-rt-modules-core 5.14.0-427.35.1.el9_4, kernel-rt-debug-modules 5.14.0-427.35.1.el9_4, +4 more
    fixed: vendor fix RHSA-2024:6567

Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf

CISA SSVC

Exploitation
none
Automatable
no
Technical impact
partial
Assessed
2 y ago

Exploit prediction

0.29% chance of exploitation in the next 30 days, higher than 21% of all scored CVEs (FIRST EPSS, 2026-11-08).

CVSS scores

assigned by version score vector
NVD 3.1 7.8 CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Affected products

  • Linux Linux

Classification

Weakness
Technology feeds

References

Sources

Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.