CVE-2026-99701: mm/ksm: fix userfaultfd protection during merge and unmerge
In the Linux kernel, the following vulnerability has been resolved:
mm/ksm: fix userfaultfd protection during merge and unmerge
KSM loses userfaultfd protection when replacepage() builds a new PTE from vma->vmpageprot. Dropping its uffd bit lets a subsequent write go through ordinary COW instead of userfaultfd write protection handling. For RWP, a merged page also becomes readable without faulting.
Keeping the uffd bit and restoring PAGENONE fixes merging, but we also have to handle unmerging. An existing KSM page can be protected with RWP before MADVUNMERGEABLE, so unmerging already needs fixing independently of preserving RWP during merging.
Unsharing replaces a shared page with a private one and should leave userfaultfd protection in place, as dowppage() already does for write protection. Currently, an unshare fault reaches douffdrwp() before it can proceed to dowppage().
- With synchronous RWP, handleuserfault() returns VMFAULTSIGBUS. breakksm() then reports success with a KSM page still merged.
- With asynchronous RWP, protection is cleared before unsharing.
Preserve the uffd bit when merging, and restore PAGENONE for RWP. Let FAULTFLAGUNSHARE skip RWP fault handling and keep PAGENONE on each private copy as well. Unsharing can then complete with RWP still armed for a subsequent access.
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 7.3.5-1
Event History
Frequently Asked Questions
Which systems are exposed to this issue?
Linux kernel systems that use Kernel Samepage Merging (KSM) together with userfaultfd write protection, including RWP, are affected. The described failure paths involve merging or unmerging KSM pages that have userfaultfd protection.
What conditions are needed to trigger the problem?
The issue requires interaction between KSM page sharing or unsharing and userfaultfd protection. Relevant operations include merging a page, applying RWP to an existing KSM page before MADV_UNMERGEABLE, or unsharing a protected shared page.
What can happen when the issue is triggered?
Userfaultfd protection can be lost, allowing a write to take the ordinary copy-on-write path rather than userfaultfd write-protection handling. For RWP, a merged page may become readable without faulting; synchronous RWP unsharing can also report success while the page remains KSM-merged.
Is there a workaround if the kernel update cannot be applied immediately?
The provided information identifies the affected interaction as KSM with userfaultfd write protection. Avoiding that combination, including applying RWP to KSM pages before MADV_UNMERGEABLE, avoids the described paths.