CVE & CISA-KEV Catalog

CVE-2025-38242

MEDIUM
4.7
CVSS v3
NVD

Description

In the Linux kernel, the following vulnerability has been resolved: mm: userfaultfd: fix race of userfaultfd_move and swap cache This commit fixes two kinds of races, they may have different results: Barry reported a BUG_ON in commit c50f8e6053b0, we may see the same BUG_ON if the filemap lookup returned NULL and folio is added to swap cache after that. If another kind of race is triggered (folio changed after lookup) we may see RSS counter is corrupted: [ 406.893936] BUG: Bad rss-counter state mm:ffff0000c5a9ddc0 type:MM_ANONPAGES val:-1 [ 406.894071] BUG: Bad rss-counter state mm:ffff0000c5a9ddc0 type:MM_SHMEMPAGES val:1 Because the folio is being accounted to the wrong VMA. I'm not sure if there will be any data corruption though, seems no. The issues above are critical already. On seeing a swap entry PTE, userfaultfd_move does a lockless swap cache lookup, and tries to move the found folio to the faulting vma. Currently, it relies on checking the PTE value to ensure that the moved folio still belongs to the src swap entry and that no new folio has been added to the swap cache, which turns out to be unreliable. While working and reviewing the swap table series with Barry, following existing races are observed and reproduced [1]: In the example below, move_pages_pte is moving src_pte to dst_pte, where src_pte is a swap entry PTE holding swap entry S1, and S1 is not in the swap cache: CPU1 CPU2 userfaultfd_move move_pages_pte() entry = pte_to_swp_entry(orig_src_pte); // Here it got entry = S1 ... < interrupted> ... <swapin src_pte, alloc and use folio A> // folio A is a new allocated folio // and get installed into src_pte <frees swap entry S1> // src_pte now points to folio A, S1 // has swap count == 0, it can be freed // by folio_swap_swap or swap // allocator's reclaim. <try to swap out another folio B> // folio B is a folio in another VMA. <put folio B to swap cache using S1 > // S1 is freed, folio B can use it // for swap out with no problem. ... folio = filemap_get_folio(S1) // Got folio B here !!! ... < interrupted again> ... <swapin folio B and free S1> // Now S1 is free to be used again. <swapout src_pte & folio A using S1> // Now src_pte is a swap entry PTE // holding S1 again. folio_trylock(folio) move_swap_pte double_pt_lock is_pte_pages_stable // Check passed because src_pte == S1 folio_move_anon_rmap(...) // Moved invalid folio B here !!! The race window is very short and requires multiple collisions of multiple rare events, so it's very unlikely to happen, but with a deliberately constructed reproducer and increased time window, it can be reproduced easily. This can be fixed by checking if the folio returned by filemap is the valid swap cache folio after acquiring the folio lock. Another similar race is possible: filemap_get_folio may return NULL, but folio (A) could be swapped in and then swapped out again using the same swap entry after the lookup. In such a case, folio (A) may remain in the swap cache, so it must be moved too: CPU1 CPU2 userfaultfd_move move_pages_pte() entry = pte_to_swp_entry(orig_src_pte); // Here it got entry = S1, and S1 is not in swap cache folio = filemap_get ---truncated---

How to fix

Remediation Available
linuxDebian
Fixed in:6.12.37-1CVE-2025-38242
Fixed in:6.12.37-1CVE-2025-38242
linux-aws-6.14Ubuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-3
linux-azure-6.14Ubuntu
Fixed in:6.14.0-1014.14~24.04.1USN-7834-1
linux-azure-nvidia-6.14Ubuntu
Fixed in:6.14.0-1007.7USN-7834-1
linux-gcp-6.14Ubuntu
Fixed in:6.14.0-1018.19~24.04.1USN-7833-4
linux-hwe-6.14Ubuntu
Fixed in:6.14.0-34.34~24.04.1USN-7856-1
linux-image-6.14.0-1007-azure-nvidiaUbuntu
Fixed in:6.14.0-1007.7USN-7834-1
linux-image-6.14.0-1014-azureUbuntu
Fixed in:6.14.0-1014.14~24.04.1USN-7834-1
linux-image-6.14.0-1014-oemUbuntu
Fixed in:6.14.0-1014.14USN-7833-1
linux-image-6.14.0-1014-realtimeUbuntu
Fixed in:6.14.0-1014.14~24.04.1USN-7833-2
linux-image-6.14.0-1015-awsUbuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-3
linux-image-6.14.0-1015-aws-64kUbuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-3
linux-image-6.14.0-1015-oracleUbuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-1
linux-image-6.14.0-1015-oracle-64kUbuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-1
linux-image-6.14.0-1018-gcpUbuntu
Fixed in:6.14.0-1018.19~24.04.1USN-7833-4
linux-image-6.14.0-1018-gcp-64kUbuntu
Fixed in:6.14.0-1018.19~24.04.1USN-7833-4
linux-image-6.14.0-34-genericUbuntu
Fixed in:6.14.0-34.34~24.04.1USN-7856-1
linux-image-6.14.0-34-generic-64kUbuntu
Fixed in:6.14.0-34.34~24.04.1USN-7856-1
linux-image-awsUbuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-3
linux-image-aws-6.14Ubuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-3
linux-image-aws-64kUbuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-3
linux-image-aws-64k-6.14Ubuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-3
linux-image-azureUbuntu
Fixed in:6.14.0-1014.14~24.04.1USN-7834-1
linux-image-azure-6.14Ubuntu
Fixed in:6.14.0-1014.14~24.04.1USN-7834-1
linux-image-azure-nvidiaUbuntu
Fixed in:6.14.0-1007.7USN-7834-1
linux-image-azure-nvidia-6.14Ubuntu
Fixed in:6.14.0-1007.7USN-7834-1
linux-image-gcpUbuntu
Fixed in:6.14.0-1018.19~24.04.1USN-7833-4
linux-image-gcp-6.14Ubuntu
Fixed in:6.14.0-1018.19~24.04.1USN-7833-4
linux-image-gcp-64kUbuntu
Fixed in:6.14.0-1018.19~24.04.1USN-7833-4
linux-image-gcp-64k-6.14Ubuntu
Fixed in:6.14.0-1018.19~24.04.1USN-7833-4
linux-image-generic-6.14Ubuntu
Fixed in:6.14.0-34.34~24.04.1USN-7856-1
linux-image-generic-64k-6.14Ubuntu
Fixed in:6.14.0-34.34~24.04.1USN-7856-1
linux-image-generic-64k-hwe-24.04Ubuntu
Fixed in:6.14.0-34.34~24.04.1USN-7856-1
linux-image-generic-hwe-24.04Ubuntu
Fixed in:6.14.0-34.34~24.04.1USN-7856-1
linux-image-oem-24.04Ubuntu
Fixed in:6.14.0-1014.14USN-7833-1
linux-image-oem-24.04aUbuntu
Fixed in:6.14.0-1014.14USN-7833-1
linux-image-oem-24.04bUbuntu
Fixed in:6.14.0-1014.14USN-7833-1
linux-image-oem-24.04cUbuntu
Fixed in:6.14.0-1014.14USN-7833-1
linux-image-oem-6.14Ubuntu
Fixed in:6.14.0-1014.14USN-7833-1
linux-image-oracleUbuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-1
linux-image-oracle-6.14Ubuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-1
linux-image-oracle-64kUbuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-1
linux-image-oracle-64k-6.14Ubuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-1
linux-image-realtime-6.14Ubuntu
Fixed in:6.14.0-1014.14~24.04.1USN-7833-2
linux-image-realtime-hwe-24.04Ubuntu
Fixed in:6.14.0-1014.14~24.04.1USN-7833-2
linux-image-virtual-6.14Ubuntu
Fixed in:6.14.0-34.34~24.04.1USN-7856-1
linux-image-virtual-hwe-24.04Ubuntu
Fixed in:6.14.0-34.34~24.04.1USN-7856-1
linux-oem-6.14Ubuntu
Fixed in:6.14.0-1014.14USN-7833-1
linux-oracle-6.14Ubuntu
Fixed in:6.14.0-1015.15~24.04.1USN-7833-1
linux-realtime-6.14Ubuntu
Fixed in:6.14.0-1014.14~24.04.1USN-7833-2

Remediation is compiled from vendor and distribution security advisories. Always confirm against the linked source for your exact version and platform.

CVSS v3 Vector

Exploitability

Attack VectorLocal
Attack ComplexityHigh
Privileges RequiredLow
User InteractionNone
ScopeUnchanged

Impact

ConfidentialityNone
IntegrityNone
AvailabilityHigh

CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H

Exploit Intelligence

0.10%probability of exploitation in 30 days
1stpercentile

Low risk: more likely to be exploited than 1% of all known CVEs.

References

Related Vulnerabilities

Other CWE-362 (Race Condition) vulnerabilities, ordered by exploit likelihood. View all

CVESeverityCVSSEPSSExploitedFix
CVE-2024-6387High8.1100%-Fix
CVE-2023-36884High7.599%KEV + RansomFix
CVE-2018-15473Medium5.399%-Fix
CVE-2024-27983High8.287%-Fix
CVE-2014-0226Medium6.886%-Fix
CVE-2016-5195High7.084%KEVFix
Embed a live status badge for CVE-2025-38242
CVE-2025-38242 severity badge

Markdown

[![CVE-2025-38242](https://tridentstack.com/cve/badge/CVE-2025-38242.svg)](https://tridentstack.com/cve/CVE-2025-38242)

HTML

<a href="https://tridentstack.com/cve/CVE-2025-38242"><img src="https://tridentstack.com/cve/badge/CVE-2025-38242.svg" alt="CVE-2025-38242"></a>

Find and fix vulnerabilities across your fleet

TridentStack Control continuously scans your Windows, macOS, and Linux fleet for known vulnerabilities, prioritizes them by severity and active exploitation, and patches them automatically.

Start free

This product uses NVD data but is not endorsed or certified by the NVD. EPSS scores courtesy of FIRST.org (https://www.first.org/epss). Source: CISA KEV Catalog. Data as of 2025-11-19.