CVE-2026-99656: mm/madvise: fix data loss from MADV_FREE on a KSM page
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
mm/madvise: fix data loss from MADV_FREE on a KSM page
MADV_FREE 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 try_to_merge_one_page(). Marking a folio lazyfree clears PG_swapbacked but leaves PG_dirty unchanged. Preserving PG_dirty makes reclaim restore PG_swapbacked 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.
The Linux kernel CVE team has assigned CVE-2026-99656 to this issue.
Affected and fixed versions
===========================
Issue introduced in 4.5 with commit 854e9ed09dedf0c19ac8640e91bcc74bc3f9e5c9 and fixed in 6.12.118 with commit af2feafb0437fab5ed9d02eeb1c06ef66e05c55a Issue introduced in 4.5 with commit 854e9ed09dedf0c19ac8640e91bcc74bc3f9e5c9 and fixed in 6.18.64 with commit 8b6860f17b4de23a0b19045c066dc0679e50f0ba Issue introduced in 4.5 with commit 854e9ed09dedf0c19ac8640e91bcc74bc3f9e5c9 and fixed in 7.3.5 with commit 64f273b71bf714dd22b803a87d65bb40faaffcad Issue introduced in 4.5 with commit 854e9ed09dedf0c19ac8640e91bcc74bc3f9e5c9 and fixed in 7.4-rc2 with commit 22d043c1da48d6c7274f9dd900714b6d58b7b9c6
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2026-99656
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
mm/madvise.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/af2feafb0437fab5ed9d02eeb1c06ef66e05c55a https://git.kernel.org/stable/c/8b6860f17b4de23a0b19045c066dc0679e50f0ba https://git.kernel.org/stable/c/64f273b71bf714dd22b803a87d65bb40faaffcad https://git.kernel.org/stable/c/22d043c1da48d6c7274f9dd900714b6d58b7b9c6