CVE-2026-99666: mm/khugepaged: fix PMD table lock leak in try_collapse_pte_mapped_thp()
In the Linux kernel, the following vulnerability has been resolved:
mm/khugepaged: fix PMD table lock leak in trycollapseptemappedthp()
For a private mapping with userfaultfd, trycollapseptemappedthp() takes the PMD table lock before it maps the page table for the second time. If that (pteoffsetmaprwnolock) fails, because the page table vanished in the meantime due to concurrent page table reclaim, it leaves through the abort label, where the PMD table lock is unlocked if it differs from PTE table lock.
In case the PMD table lock and the PTE table lock match, which is the case without CONFIGSPLITPTEPTLOCKS after pteoffsetmaprwnolock() failed, we miss to unlock the PMD table.
To fix it, forget the PTE table lock when we unmap+unlock the PTE table.
Fix generated by an LLM and sent by Josef Bacik in private.
[ david: move the ptl = NULL handling; rewrite description, drop wrong comments ]
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.18.64 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.5 - Compensating control
In mm/khugepaged, clear/forget the PTE table lock when unmapping and unlocking the PTE table in try_collapse_pte_mapped_thp(), so the abort path does not incorrectly treat it as a distinct lock.
Event History
Frequently Asked Questions
Which systems are exposed to the missed-unlock path?
The path applies to private mappings that use userfaultfd. The missed unlock occurs when CONFIG_SPLIT_PTE_PTLOCKS is not enabled, because the PMD and PTE table locks then match.
What timing condition is required to trigger it?
After the PMD table lock is acquired, the second page-table mapping attempt must fail because concurrent page-table reclaim removed the page table. In that failure path, the PMD table lock can be left held when it is the same lock as the PTE table lock.