CVE-2026-99649: mm/ksm: check large swap-cache folios before mapping them
In the Linux kernel, the following vulnerability has been resolved:
mm/ksm: check large swap-cache folios before mapping them
KSM folios are always small, but their shared swap slots can be read back as part of a large folio in the swap cache. ksmmightneedtocopy() skips large folios, so another process can map a page with an incompatible anonvma or page index. Reverse mapping then cannot find the new mapping, preventing migration or reclaim.
Apply the same compatibility checks to large folios as to small ones. Pass the page corresponding to the swap entry and copy only that page when necessary. In doswappage()'s copy path, decrement only that slot's swap count, because the source swap-cache folio can now be large.
Fix generated by an LLM and sent by Chris Mason in private.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.5 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.1.176-1Fixed in 6.1.192-2Fixed in 6.12.107-1Fixed in 6.12.117-1Fixed in 7.3.5-1 - Compensating control
In KSM's do_swap_page() copy path, apply the same compatibility checks to large swap-cache folios as to small ones. Pass the page corresponding to the swap entry to ksm_might_need_to_copy(), copy only that page when necessary, and decrement only that swap slot's count.
Event History
Frequently Asked Questions
What conditions are required for this issue to occur?
The issue requires KSM-managed pages whose shared swap slots are later read back as part of a large folio in the swap cache. A process must then map a page whose anonymous-VMA association or page index is incompatible with the existing mapping.
What is the operational impact if the system is affected?
Reverse mapping may be unable to locate the new mapping. This can prevent memory migration or reclaim for the affected pages.
Are systems using KSM but not large swap-cache folios affected?
The described failure depends on shared KSM swap slots being read back within a large swap-cache folio. The provided information does not indicate the same issue when the relevant swap-cache folio remains small.
What does the fix change?
The fix applies compatibility checks to large swap-cache folios as well as small ones. When copying is needed, it copies only the page for the relevant swap entry and decrements the swap count only for that slot.