CVE-2026-139799
published high CVSS 3.1 · 7.0mm/shmem: hold off eviction in shmem_writeout()
Package status and fixes
| Distro / vendor | Release | Package / product | Publisher status | Fixed build | Source |
|---|---|---|---|---|---|
| Linux | — | Linux6344a6d9ce13ae29e3ddf280fd8a1109a77b9996 to < d64fd1229fb1437d7c62c49eba82691bfd65d541 · 6344a6d9ce13ae29e3ddf280fd8a1109a77b9996 to < f53ee5a65460010cabd75895d83258d90923ca7a · 6344a6d9ce13ae29e3ddf280fd8a1109a77b9996 to < 8f59173b5ca358bf4d1017b44da3cbe6faa80daf · Other versions: unaffected | Affected | Not stated | Linux |
| Linux | — | Linux6.17 (affected) · 0 to < 6.17 (unaffected · semver) · 6.18.65 through 6.18.* (unaffected · semver) · 7.3.6 through 7.3.* (unaffected · semver) · 7.4-rc2 and later (unaffected · original_commit_for_fix) · Other versions: affected | Version-specific | Not stated | Linux |
| Amazon Linux | AL2 | Release evaluation | Not Affected | Not required | Amazon Linux assessment |
| Amazon Linux | AL2023 | Release evaluation | Not Affected; Pending Fix | Not stated | Amazon Linux assessment |
Description
In the Linux kernel, the following vulnerability has been resolved: mm/shmem: hold off eviction in shmem_writeout() Once shmem_writeout() has moved the folio from the page cache to the swap cache, the folio lock no longer keeps the inode alive: truncation and eviction find a swap entry, free it and do not wait for anybody. That did not matter as long as swap_writeout() was the last thing the function did. But since it puts the folio back when swap_writeout() returns AOP_WRITEPAGE_ACTIVATE, it uses the mapping and the inode afterwards: reclaim last close of an unlinked file shmem_writeout() shmem_delete_from_page_cache() swap_writeout() zswap_store() fails shmem_evict_inode() writeback is disabled shmem_truncate_range() return AOP_WRITEPAGE_ACTIVATE shmem_free_swap() destroy_inode() ... RCU grace period, freed shmem_add_to_page_cache(mapping) xas_lock_irq() <- use after free swap_writeout() behaves that way if zswap is enabled, cannot take the folio and the memcg or one of its ancestors has memory.zswap.writeback set to 0. shmem_unuse() already added infrastructure to deal with that. Reuse info->stop_eviction to protect the inode during writeout. Increment it before removing the folio from the page cache, and decrement it after swap_writeout() and any attempted reinsertion and inode accounting. In shmem_evict_inode(), wait for the counter to reach zero even if swapoff has already removed the inode from the swap list. Add some helpers to make the code easier to digest. There is a known remaining issue with two swapoffs racing, and the empty list check not being able to detect that race. That will be addressed separately later. Fix generated by an LLM and sent by Josef Bacik in private. [ david: code cleanups; improve description ]
Related advisories
Vendor advisories explicitly linked to this CVE.
No linked advisories were found for this CVE.
Assessment
CVSS risk assessment and additional context for this vulnerability.
- CVSS version
- 3.1
- Base score
- 7.0 / 10
- Severity
- high
- Provider
- Linux · cna
- Vector string
- CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H
- Scenarios
- en: AV:L - A local user creates the inode with memfd_create() (shmem file, clear_nlink) and writes data. They force reclaim via memory.reclaim, which reaches pageout()->shmem_writeout(), and close the last fd to run shmem_evict_inode(). No remote peer supplies any data. AC:H - swap_writeout() returns AOP_WRITEPAGE_ACTIVATE only if zswap is globally enabled (CONFIG_ZSWAP_DEFAULT_ON is off by default, root-only module param) and a swap device is active. The eviction must also land after folio_free_swap() and finish its RCU grace period before shmem_add_to_page_cache() runs. PR:L - memory.zswap.writeback is created owned by the mkdir caller (current_fsuid), and systemd's [email protected] has Delegate=pids memory cpu. An unprivileged user can therefore set writeback=0 in their own child memcg, fill a memfd with incompressible data, and trigger the race. UI:N - The attacker performs every step themselves: memfd write, cgroup writeback=0, memory.reclaim to drive shmem_writeout(), and close() to drive shmem_evict_inode(). No other user has to act. S:U - The use-after-free corrupts kernel memory in the same kernel security authority that the local attacker targets. No guest/host, IOMMU or other boundary is crossed. C:H - After the RCU free of the shmem_inode_info, shmem_add_to_page_cache() walks the freed inode's i_pages xarray from reclaimable slab memory. If that memory is reclaimed cross-cache and refilled by the attacker, the walk follows attacker-controlled pointers, which can be leveraged for kernel memory disclosure. I:H - shmem_add_to_page_cache() takes and releases xas_lock_irq on freed memory and can xas_store() the folio pointer and bump mapping->nrpages in the freed inode. These are writes into reused memory that are exploitable for kernel memory corruption. A:H - Locking a spinlock inside a freed and reused shmem_inode_info with IRQs disabled can hard-lock the CPU, and walking a corrupted xarray oopses. Either way the kernel crashes, and KASAN flags the access as a use-after-free.
Publisher product statements
Version ranges and default statuses as reported by each provider.
| Vendor | Product | Version status | Source |
|---|---|---|---|
| Linux | Linux | 6344a6d9ce13ae29e3ddf280fd8a1109a77b9996 to < d64fd1229fb1437d7c62c49eba82691bfd65d541 (affected · git)6344a6d9ce13ae29e3ddf280fd8a1109a77b9996 to < f53ee5a65460010cabd75895d83258d90923ca7a (affected · git)6344a6d9ce13ae29e3ddf280fd8a1109a77b9996 to < 8f59173b5ca358bf4d1017b44da3cbe6faa80daf (affected · git)Default: unaffected | Linux · cna |
| Linux | Linux | 6.17 (affected)0 to < 6.17 (unaffected · semver)6.18.65 through 6.18.* (unaffected · semver)7.3.6 through 7.3.* (unaffected · semver)7.4-rc2 and later (unaffected · original_commit_for_fix)Default: affected | Linux · cna |
Weaknesses
0No weakness assertions.
References
3Provider assertions
1Linux · cna
mm/shmem: hold off eviction in shmem_writeout()
Provenance
- Schema
- 5.2
- Searchable
- yes
- Content hash
- 36f9381c28ddc305de05c628e5e197934f2a9978b89600a9827fa7eeb2d5aa95
- Ingested
- 01 Dec 2026, 05:47:22 UTC
- Source record
- Official CVE record