CVE-2026-99920: mm/mlock: use a long for the page count in mlock_fixup()
In the Linux kernel, the following vulnerability has been resolved:
mm/mlock: use a long for the page count in mlockfixup()
mlockfixup() adjusts mm->lockedvm, an unsigned long, by the number of pages whose VMLOCKED state it changes, but computes that number in an int:
int nrpages; ... nrpages = (end - start) >> PAGESHIFT; ... mm->lockedvm += nrpages;
When a single VMA range of 2^31 pages (8 TiB with 4 KiB pages) or more is locked or unlocked, the count is truncated to 32 bits and then sign-extended, so lockedvm is changed by the wrong amount, while munmap(), mremap() and the other paths that maintain lockedvm use the full unsigned long page count.
Such a range is reachable on 64-bit architectures with a 47-bit or larger user address space (x8664, arm64 with 48-bit VA, riscv64 Sv48) by a task with CAPIPCLOCK or a raised RLIMITMEMLOCK, which domlock() checks against the full untruncated length. It costs nothing with MAPNORESERVE and MLOCKONFAULT/MCLONFAULT, since then no page is populated. On x8664, after
p = mmap(NULL, 8UL << 40, PROTREAD | PROTWRITE, MAPPRIVATE | MAPANONYMOUS | MAPNORESERVE, -1, 0); mlock2(p, 8UL << 40, MLOCKONFAULT);
VmLck in /proc/self/status reads 18446744065119617024 kB instead of 8589934592 kB; munmap() of the region then subtracts the true size and leaves VmLck at 18446744056529682432 kB instead of 0. With 16 TiB, lockedvm is not changed at all, VmLck stays 0 kB, and after the task drops CAPIPCLOCK or lowers RLIMITMEMLOCK, mlock(), mmap(MAPLOCKED) and the other mlockfutureok() and accountlockedvm() users enforce RLIMITMEMLOCK against that count, so they let the task lock memory beyond its limit (or, in the 8 TiB case, refuse every further lock). The error persists for the life of the mm; unlocking the range in pieces skews it further. The wrong count is per-mm accounting only: it does not change which pages are locked.
The int has been there since before git history (the variable was named "pages" until it was renamed in 2.6.28); every other updater of lockedvm uses an unsigned long or long count. Make nrpages a long, which holds the page count of any user range and its negation, so the existing sign handling is unchanged.
Found by formal verification of mm/mlock.c against the kernel binary.