CVE-2026-138868: mm/hugetlb: charge folios to the target mm's memcg
In the Linux kernel, the following vulnerability has been resolved:
mm/hugetlb: charge folios to the target mm's memcg
HugeTLB folios are currently charged to the memcg of the allocating task. This gives the wrong result when a userfaultfd handler populates a HugeTLB VMA that belongs to another process. The UFFDIOCOPY ioctl operates on the userfaultfd context's mm, but getmemcgroupfromcurrent() charges the folio to the handler's memcg instead.
This can be reproduced by placing the faulting process and its userfaultfd handler in different memory cgroups. Have the target process register a HugeTLB mapping with userfaultfd, trigger a missing fault, and let the handler resolve it with UFFDIOCOPY. The hugepage usage is then reported in the handler's memory.current instead of the target's.
The generic userfaultfd population path avoids this problem by charging folios to dstvma->vmmm.
Pass the target mm through hugetlballocfolio() and charge the folio by using getmemcgroupfrommm(). This preserves the existing charge timing and error handling while making HugeTLB userfaultfd population consistent with the generic path.
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.4 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.118-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 7.3.4-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.118-1Fixed in 7.3.4-1
Event History
Frequently Asked Questions
Which environments are exposed to the incorrect accounting?
The issue requires HugeTLB memory populated through userfaultfd, with the process owning the HugeTLB mapping and the userfaultfd handler placed in different memory cgroups. Configurations where both run in the same memory cgroup would not show the described cross-cgroup accounting result.
What must an attacker or triggering workload be able to do?
It must register a HugeTLB mapping with userfaultfd in a target process, trigger a missing-page fault, and resolve that fault from a handler using the UFFDIO_COPY ioctl. The handler must run in a different memory cgroup from the target process for the charge to be assigned to the wrong cgroup.
How can administrators identify the issue in an affected setup?
In a test with the target process and userfaultfd handler in separate memory cgroups, resolve a missing fault in a HugeTLB mapping using UFFDIO_COPY. If HugeTLB usage increases in the handler's memory.current rather than the target process's memory.current, the system exhibits the described behavior.
Is the generic userfaultfd population path affected?
No. The described issue is specific to HugeTLB userfaultfd population; the generic userfaultfd population path already charges folios to the destination VMA's target memory-management context.