CVE-2025-21664: dm thin: make get_first_thin use rcu-safe list first function
In the Linux kernel, the following vulnerability has been resolved:
dm thin: make getfirstthin use rcu-safe list first function
The documentation in rculist.h explains the absence of listemptyrcu() and cautions programmers against relying on a listempty() -> listfirst() sequence in RCU safe code. This is because each of these functions performs its own READONCE() of the list head. This can lead to a situation where the listempty() sees a valid list entry, but the subsequent listfirst() sees a different view of list head state after a modification.
In the case of dm-thin, this author had a production box crash from a GP fault in the processdeferredbios path. This function saw a valid list head in getfirstthin() but when it subsequently dereferenced that and turned it into a thinc, it got the inside of the struct pool, since the list was now empty and referring to itself. The kernel on which this occurred printed both a warning about a refcountt being saturated, and a UBSAN error for an out-of-bounds cpuid access in the queued spinlock, prior to the fault itself. When the resulting kdump was examined, it was possible to see another thread patiently waiting in thindtr's synchronizercu.
The thindtr call managed to pull the thinc out of the active thins list (and have it be the last entry in the activethins list) at just the wrong moment which lead to this crash.
Fortunately, the fix here is straight forward. Switch getfirstthin() function to use listfirstornullrcu() which performs just a single READONCE() and returns NULL if the list is already empty.
This was run against the devicemapper test suite's thin-provisioning suites for delete and suspend and no regressions were observed.
Other sources
This CVE was automatically created from a reference found in an email or other text. If you are reading this, then this CVE entry is probably erroneous, since this text should be replaced by the official CVE description automatically.
— Launchpad
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.27-1 - Upgrade
Upgrade
debian/linux-6.1to a version that resolves this vulnerability.Fixed in 6.1.129-1~deb11u1
Event History
Frequently Asked Questions
What is the severity of CVE-2025-21664?
CVE-2025-21664 is classified as a moderate severity vulnerability in the Linux kernel.
How do I fix CVE-2025-21664?
To fix CVE-2025-21664, update the Linux kernel to the latest version that contains the security patch.
What components of the Linux kernel are affected by CVE-2025-21664?
CVE-2025-21664 affects the dm thin component of the Linux kernel.
Is CVE-2025-21664 being exploited in the wild?
As of now, there have been no confirmed reports of CVE-2025-21664 being actively exploited in the wild.
Where can I find more information about CVE-2025-21664?
Detailed technical information about CVE-2025-21664 can be found in the Linux kernel's commit history.