Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1359 CNY

100%

CVE-2025-38242— mm: userfaultfd: fix race of userfaultfd_move and swap cache

Quick assessment

Affected
Linux Linux
Exploitation
No confirmed in-the-wild exploitation; assess based on exposure
Recommended action
Check the vendor advisory and references for a fixed version. If immediate upgrade is impossible, restrict exposure and increase monitoring.

Linux kernel是美国Linux基金会的开源操作系统Linux所使用的内核。 Linux kernel存在安全漏洞,该漏洞源于userfaultfd_move和交换缓存竞争导致RSS计数器损坏。

CVSS 7.8 · High EPSS 0.13% · P3

Possible ATT&CK Techniques 1 AI

T1059 · Command and Scripting Interpreter

Affected Version Matrix 8

VendorProduct Version RangeStatus
Linux Linux adef440691bab824e39c1b17382322d195e1fab0< 4c443046d8c9ed8724a4f4c3c2457d3ac8814b2f affected
adef440691bab824e39c1b17382322d195e1fab0< db2ca8074955ca64187a4fb596dd290b9c446cd3 affected
adef440691bab824e39c1b17382322d195e1fab0< 0ea148a799198518d8ebab63ddd0bb6114a103bc affected
6.8 affected
< 6.8 unaffected
6.12.37≤ 6.12.* unaffected
6.15.5≤ 6.15.* unaffected
6.16≤ * unaffected
Get alerts for future matching vulnerabilities Log in to subscribe

I. Basic Information for CVE-2025-38242

Vulnerability Information

Have questions about the vulnerability? See if Shenlong's analysis helps!
View Shenlong Deep Dive ↗

Although we use advanced large model technology, its output may still contain inaccurate or outdated information.Shenlong tries to ensure data accuracy, but please verify and judge based on the actual situation.

Vulnerability Title
mm: userfaultfd: fix race of userfaultfd_move and swap cache
Source: CVE Program / CVE List V5
Vulnerability 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---
Source: CVE Program / CVE List V5
CVSS Information
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Source: CVE Program / CVE List V5
Vulnerability Type
N/A
Source: CVE Program / CVE List V5
Vulnerability Title
Linux kernel 安全漏洞
Source: CNNVD (China National Vulnerability Database)
Vulnerability Description
Linux kernel是美国Linux基金会的开源操作系统Linux所使用的内核。 Linux kernel存在安全漏洞,该漏洞源于userfaultfd_move和交换缓存竞争导致RSS计数器损坏。
Source: CNNVD (China National Vulnerability Database)
CVSS Information
N/A
Source: CNNVD (China National Vulnerability Database)
Vulnerability Type
N/A
Source: CNNVD (China National Vulnerability Database)

Affected Products

Vendor Product Affected Versions CPE Subscribe
Linux Linux adef440691bab824e39c1b17382322d195e1fab0 ~ 4c443046d8c9ed8724a4f4c3c2457d3ac8814b2f -
Linux Linux 6.8 -

II. Public POCs for CVE-2025-38242

# POC Description Source Link Shenlong Link
AI-Generated POC Premium

No public POC found.

Login to generate AI POC

III. Intelligence Information for CVE-2025-38242

请登录查看更多情报信息。

Same Patch Batch · Linux · 2025-07-09 · 26 CVEs total

CVE-2025-38264 9.8 CRITICAL nvme-tcp: sanitize request list handling
CVE-2025-38246 9.8 CRITICAL bnxt: properly flush XDP redirect lists
CVE-2025-38238 8.8 HIGH scsi: fnic: Fix crash in fnic_wq_cmpl_handler when FDMI times out
CVE-2025-38253 8.8 HIGH HID: wacom: fix crash in wacom_aes_battery_handler()
CVE-2025-38261 7.8 HIGH riscv: save the SR_SUM status over switches
CVE-2025-38262 7.8 HIGH tty: serial: uartlite: register uart driver in init
CVE-2025-38248 7.8 HIGH bridge: mcast: Fix use-after-free during router port configuration
CVE-2025-38250 7.8 HIGH Bluetooth: hci_core: Fix use-after-free in vhci_flush()
CVE-2025-38252 7.8 HIGH cxl/ras: Fix CPER handler device confusion
CVE-2025-38244 7.5 HIGH smb: client: fix potential deadlock when reconnecting channels
CVE-2025-38239 7.3 HIGH scsi: megaraid_sas: Fix invalid node index
CVE-2025-38257 7.3 HIGH s390/pkey: Prevent overflow in size calculation for memdup_user()
CVE-2025-38251 atm: clip: prevent NULL deref in clip_push()
CVE-2025-38249 ALSA: usb-audio: Fix out-of-bounds read in snd_usb_get_audioformat_uac3()
CVE-2025-38254 drm/amd/display: Add sanity checks for drm_edid_raw()
CVE-2025-38255 lib/group_cpus: fix NULL pointer dereference from group_cpus_evenly()
CVE-2025-38256 io_uring/rsrc: fix folio unpinning
CVE-2025-38247 userns and mnt_idmap leak in open_tree_attr(2)
CVE-2025-38258 mm/damon/sysfs-schemes: free old damon_sysfs_scheme_filter->memcg_path on write
CVE-2025-38259 ASoC: codecs: wcd9335: Fix missing free of regulator supplies

Showing top 20 of 26 CVEs. View all on vendor page &rarr; →

IV. Related Vulnerabilities

V. Comments for CVE-2025-38242

No comments yet


Leave a comment