CVE-2026-142895: maple_tree: fix maple_range_64 crashes in RCU mode
In the Linux kernel, the following vulnerability has been resolved:
mapletree: fix maplerange64 crashes in RCU mode
Patch series "mapletree: fix maplerange64 crashes in RCU mode", v3.
The patch series fixes two RCU destroy path issues on maplerange64 nodes. Both arising from the fact that a maplerange64 node repurposes the last slot to hold metadata when the node is not full. Patch 1 addresses the issues, and patch 2 adds a test used to catch them.
Currently there is no in-tree user of maplerange64 nodes in RCU mode. All in-tree users of MTFLAGSUSERCU also set MTFLAGSALLOCRANGE which makes the internal nodes maplearange64.
Below is the minimal reproducer used during debugging:
static DEFINEMTREE(tree); static int init maplefixinit(void) { unsigned long i, j;
for (i = 10; i < 4000; i++) { mtinitflags(&tree, MTFLAGSUSERCU);
for (j = 0; j < i; j++) { mtreeinsertrange(&tree, j 10, j 10 + 9, xamkvalue(j), GFPKERNEL); }
mtreedestroy(&tree); rcubarrier(); } return 0; }
The splat for the first issue addressed by the first patch is shown below. mtclearmeta() runs after the slots have been rewritten with raw pointers by mtedeadleaves(), so it cannot recognize a valid last pointer because the type information is stripped. On my 64-bit LE machine, it clears bytes 248 and 249 of the maplerange64 which are the two least significant bytes of the last pointer. The lowest byte is already zero, since nodes are 256-byte aligned, but zeroing byte 249 corrupts the pointer.
KASAN catches it as a double-free, because that corrupted pointer happens to land on a node that was freed previously. The splat appears at 226 insertions in the reproducer. This is when the tree has a full root node on a 64-bit build.
================================================================== BUG: KASAN: double-free in mtfreewalk+0x138/0x3a0 Free of addr ffff0000f3d40000 by task swapper/2/0 [...] Call trace: [...] kmemcachefreebulk+0x5b8/0xc18 mtfreewalk+0x138/0x3a0 rcucore+0x5d0/0x1638 rcucoresi+0x18/0x30 [...]
Allocated by task 1218: [...] kmemcacheallocfromsheafnoprof+0xa8/0x2f0 dstsetup+0x210/0x630 maswrsplit+0x568/0x26e0 maswrstoreentry+0x98c/0x1de0 masinsert.isra.0+0x3d0/0x5d8 mtreeinsertrange+0xec/0x1c8 maplefixinit+0x94/0xff8 [maplefixobj] [...]
Freed by task 0: [...] kasanslabfree+0x88/0xb8 rcufreesheafprepare+0x94/0x360 rcufreesheaf+0x30/0x138 rcucore+0x5d0/0x1638 rcucoresi+0x18/0x30 [...]
The buggy address belongs to the object at ffff0000f3d40000 which belongs to the cache maplenode of size 256 The buggy address is located 0 bytes inside of 256-byte region [ffff0000f3d40000, ffff0000f3d40100)
[...] Memory state around the buggy address: ffff0000f3d3ff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff0000f3d3ff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff0000f3d40000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff0000f3d40080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff0000f3d40100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================
The second issue fixed in the first patch is in the mtfreewalk(). mtfreewalk() descends by checking if the corresponding slot[offset] entry is non-zero. In a maplerange64 node that has MAPLERANGE64SLOTS-1 valid pointers to child nodes, all slots will be non-zero, since the last slot holds the metadata. Thus, mtedeadwalk() dereferences the metadata as if it were a node and hits the null-ptr-deref as shown in the splat below.
After fixing the first issue, the reproducer reaches this case at 316 ---truncated---
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.119 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.65 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.6