CVE-2026-138866: mm/execmem: free ROX cache chunks only when they span an entire vm area
In the Linux kernel, the following vulnerability has been resolved:
mm/execmem: free ROX cache chunks only when they span an entire vm area
Patch series "mm/execmem: fixes and cleanups for the ROX cache".
Sashiko review of the ROX cache refill path asked what happens when the PMDSIZE allocation fails there. Pulling that thread uncovered a bit more than the fallback.
Patch 1 fixes a real bug, although rare bug: execmemcacheclean() can free a chunk that is still partially in use, because a PMD sized and PMD aligned free range in the middle of a larger chunk looks exactly like a chunk that nobody uses.
Patch 2 handles maple tree allocation failures in the cache. They are unlikely, but silently dropping an area from the tree is not a great way to deal with them.
Patch 3 deals with the fallback that started all this. The cache exists to keep the direct map free of unnecessary splits, and the fallback happily filled it with base page mapped areas that could never be freed from the cache again. Ask vmalloc for a huge mapping or nothing, and serve whatever does not fit outside the cache.
Patches 4 and 5 convert the ROX cache to scope based cleanup.
The series was tested on x86 with module load/unload cycles, with PTDUMP confirming that the cache is using 2M mappings, and with nohugevmalloc to exercise the uncached fallback.
This patch (of 5):
When execmem refills the ROX cache, it vmalloc()s multiples of PMDSIZE aligned to PMDSIZE. For every such allocation vmalloc creates a vm area.
The first part of the vmalloc()ed chunk is returned to the allocation that triggered the cache refill and the remaining part is added to the cache and handed out for subsequent allocations with execmemalloc().
When only the first part is freed, the entire vm area remains in the ROX cache and can be handed out again.
In the case when the first allocation is larger than PMDSIZE and the second allocation from the freed first part of the chunk is exactly PMDSIZE, execmemcacheclean() will free the entire chunk while part of it is still in use.
For example:
/ vmalloc(4M), return p0 to the caller add [p0 + 3M, p0 + 4M) to the cache / p0 = execmemalloc(3M);
/ return p0 + 3M from the cache to the caller / p1 = execmemalloc(1M);
/ put [p0, p0 + 3M) back into the cache / execmemfree(p0);
/ return p0 from the cache to the caller / p2 = execmemalloc(2M);
/ return p0 + 2M from the cache to the caller / p3 = execmemalloc(1M);
/ bah! execmemcacheclean() frees the entire 4M chunk / execmemfree(p2);
Make sure that the ranges that execmemcacheclean() frees cover the entire vm area.
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.63 - 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 - Upgrade
Upgrade
Linux kernelto a version that resolves this vulnerability.Patch mm/execmem: free ROX cache chunks only when they span an entire vm area
Event History
Frequently Asked Questions
What allocation pattern can trigger the incorrect free?
The problem occurs when a PMD-sized, PMD-aligned free range lies in the middle of a larger ROX cache chunk. The cleanup logic can mistake that range for an entirely unused chunk and free it while part of the chunk remains in use.
Is this limited to the PMD-size allocation failure fallback?
No. Investigation of the PMD-size allocation failure fallback uncovered the issue, but the described incorrect-free condition is a separate, rare bug. The patch series also addresses maple tree allocation failures and prevents caching base-page-mapped fallback areas that cannot later be freed from the cache.
Which fixed Linux kernel versions contain the remediation?
The provided information does not identify affected or fixed kernel version numbers. It provides stable-tree commit references for the changes.