CVE-2026-138896: mm: hugetlb: return -ENOSPC on memcg charge failure
In the Linux kernel, the following vulnerability has been resolved:
mm: hugetlb: return -ENOSPC on memcg charge failure
Patch series "Fix bugs in HugeTLB allocation when memcgroupchargehugetlb() fails", v2.
In hugetlballocfolio(), when memcgroupchargehugetlb() fails, there are 2 issues:
1. freehugefolio() expects a non-refcounted folio and will VMBUGONFOLIO().
2. -ENOMEM is returned, causing an infinite loop retrying the fault.
This patch (of 2):
When memcgroupchargehugetlb() fails with -ENOMEM, allochugetlbfolio() currently propagates this error. This results in the page fault handler returning VMFAULTOOM.
Because HugeTLB allocations are high-order and use GFPRETRYMAYFAIL, they bypass the OOM killer. Returning VMFAULTOOM to the #PF handler without triggering the OOM killer (or having it make progress) leads to an infinite loop of retrying the fault.
Avoid this loop by returning -ENOSPC when charging fails, which maps to VMFAULTSIGBUS, terminating the process cleanly.
Make memcgroupchargehugetlb() fault handling use a common error handling path, the same handling used for hugetlbcgroupunchargecgroup{,rsvd}(), which also don't trigger the OOM killer and hence opt to terminate the process with a SIGBUS.
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.4 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 7.3.4-1 - Compensating control
In hugetlb_alloc_folio(), return -ENOSPC when mem_cgroup_charge_hugetlb() fails, so the fault maps to VM_FAULT_SIGBUS instead of retrying indefinitely.
Event History
Frequently Asked Questions
What conditions are required to trigger the faulty behavior?
A HugeTLB allocation must encounter a failure from mem_cgroup_charge_hugetlb() with -ENOMEM during hugetlb_alloc_folio(). The affected path occurs while handling a page fault for a HugeTLB allocation.
What is the operational impact of a failed HugeTLB memory-cgroup charge?
The page-fault handler can return VM_FAULT_OOM even though these high-order HugeTLB allocations bypass the OOM killer. Because no OOM-killer progress is made, the kernel can repeatedly retry the fault in an infinite loop rather than terminating the process.
How does the fix change behavior when the charge fails?
It returns -ENOSPC instead of -ENOMEM. This maps to VM_FAULT_SIGBUS, causing the faulting process to terminate cleanly rather than continuously retrying the fault.