CVE-2026-99651: mm/ksm: reset the unstable trees of all nodes
In the Linux kernel, the following vulnerability has been resolved:
mm/ksm: reset the unstable trees of all nodes
Each full scan resets ksmnrnodeids unstable tree roots. Enabling mergeacrossnodes resets this count to 1, even if per-node roots were previously allocated.
So when toggling "mergeacrossnodes" 0 -> 1 -> 0, a scan that starts while the setting is 1 and continues after switching back to 0 can encounter stale unstable tree roots, resulting in UAF.
Only root is allowed to change "mergeacrossnodes", and the documented sequence is: "mergeacrossnodes setting can be changed only when there are no ksm shared pages in the system: set run 2 to unmerge pages first, then to 1 after changing mergeacrossnodes, to remerge according to the new setting."
Let's fix it by tracking in ksmnrnodeids the actual number of allocated tree roots.
removeallstablenodes() and ksmcheckstabletree() will now scan more tree roots (skipping the empty ones), which is harmless.
Affected Software
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 - Configuration
Change merge_across_nodes only when there are no KSM-shared pages: set run to 2 to unmerge pages, change merge_across_nodes, then set run to 1 to remerge pages under the new setting.
Linux kernel KSM merge_across_nodes
Frequently Asked Questions
Who can trigger the vulnerable state?
Only root can change the merge_across_nodes setting. Exploitation requires toggling it from 0 to 1 and back to 0 while a KSM full scan begins with the setting enabled and continues after it is disabled.
Is following the documented configuration-change procedure relevant?
Yes. The documented procedure requires unmerging KSM pages by setting run to 2 before changing merge_across_nodes, then setting run back to 1 afterward so pages are remerged under the new setting.
What condition indicates a system may be exposed?
A system may be exposed if merge_across_nodes was changed through the 0 -> 1 -> 0 sequence while KSM scanning was active, allowing the scan to encounter stale per-node unstable-tree roots and cause a use-after-free.