CVE-2026-99656: mm/madvise: fix data loss from MADV_FREE on a KSM page
In the Linux kernel, the following vulnerability has been resolved:
mm/madvise: fix data loss from MADVFREE on a KSM page
MADVFREE can clear the dirty flag of a singly mapped KSM folio. The folio remains in the stable tree and can gain new mappings without being dirtied again. Once marked lazyfree, reclaim can discard data that those mappings still need.
KSM always marks a folio dirty when converting it to a KSM folio in trytomergeonepage(). Marking a folio lazyfree clears PGswapbacked but leaves PGdirty unchanged. Preserving PGdirty makes reclaim restore PGswapbacked instead of discarding the folio. This also protects folios that were already lazyfree when KSM converted them.
Skip KSM folios before clearing their dirty flag, checking under the folio lock to serialize with KSM conversion.
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.118 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.64 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.5
Frequently Asked Questions
What workload conditions can trigger the data loss?
The issue requires a KSM folio that is singly mapped and then processed with MADV_FREE. If the folio remains in KSM’s stable tree, it can acquire new mappings while its dirty state has been cleared, allowing reclaim to discard data still needed by those mappings.
What should be done if the kernel update cannot be applied immediately?
The provided information identifies MADV_FREE on KSM folios as the triggering condition. Avoid combining MADV_FREE with KSM-managed memory until an update containing the fix can be deployed.
How does the fix prevent reclamation of needed data?
It skips KSM folios before MADV_FREE clears their dirty flag, with the check performed under the folio lock to serialize against KSM conversion. Keeping the folio dirty causes reclaim to restore its swap-backed state rather than discard it.