CVE-2024-53111: mm/mremap: fix address wraparound in move_page_tables()
In the Linux kernel, the following vulnerability has been resolved:
mm/mremap: fix address wraparound in movepagetables()
On 32-bit platforms, it is possible for the expression len + oldaddr < oldend to be false-positive if len + oldaddr wraps around. oldaddr is the cursor in the old range up to which page table entries have been moved; so if the operation succeeded, oldaddr is the end of the old region, and adding len to it can wrap.
The overflow causes mremap() to mistakenly believe that PTEs have been copied; the consequence is that mremap() bails out, but doesn't move the PTEs back before the new VMA is unmapped, causing anonymous pages in the region to be lost. So basically if userspace tries to mremap() a private-anon region and hits this bug, mremap() will return an error and the private-anon region's contents appear to have been zeroed.
The idea of this check is that oldend - len is the original start address, and writing the check that way also makes it easier to read; so fix the check by rearranging the comparison accordingly.
(An alternate fix would be to refactor this function by introducing an "origoldstart" variable or such.)
Tested in a VM with a 32-bit X86 kernel; without the patch:
user@horn:~/bigmremap$ cat test.c #define GNUSOURCE #include <stdlib.h> #include <stdio.h> #include <err.h> #include <sys/mman.h>
#define ADDR1 ((void)0x60000000) #define ADDR2 ((void)0x10000000) #define SIZE 0x50000000uL
int main(void) { unsigned char p1 = mmap(ADDR1, SIZE, PROTREAD|PROTWRITE, MAPANONYMOUS|MAPPRIVATE|MAPFIXEDNOREPLACE, -1, 0); if (p1 == MAPFAILED) err(1, "mmap 1"); unsigned char p2 = mmap(ADDR2, SIZE, PROTNONE, MAPANONYMOUS|MAPPRIVATE|MAPFIXEDNOREPLACE, -1, 0); if (p2 == MAPFAILED) err(1, "mmap 2"); p1 = 0x41; printf("first char is 0x%02hhx\n", p1); unsigned char p3 = mremap(p1, SIZE, SIZE, MREMAPMAYMOVE|MREMAPFIXED, p2); if (p3 == MAPFAILED) { printf("mremap() failed; first char is 0x%02hhx\n", p1); } else { printf("mremap() succeeded; first char is 0x%02hhx\n", p3); } } user@horn:~/bigmremap$ gcc -static -o test test.c user@horn:~/bigmremap$ setarch -R ./test first char is 0x41 mremap() failed; first char is 0x00
With the patch:
user@horn:~/bigmremap$ setarch -R ./test first char is 0x41 mremap() succeeded; first char is 0x41
Other sources
This CVE was automatically created from a reference found in an email or other text. If you are reading this, then this CVE entry is probably erroneous, since this text should be replaced by the official CVE description automatically.
— Launchpad
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 5.10.223-1Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.25-1
Event History
Frequently Asked Questions
What is the severity of CVE-2024-53111?
CVE-2024-53111 is classified as a moderate severity vulnerability in the Linux kernel.
How do I fix CVE-2024-53111?
To fix CVE-2024-53111, update to the latest version of the Linux kernel beyond 6.11.10 or any impacted 6.12 release candidate.
What platforms are affected by CVE-2024-53111?
CVE-2024-53111 affects 32-bit platforms running the specified versions of the Linux kernel.
What impact does CVE-2024-53111 have?
The vulnerability could lead to incorrect memory handling due to address wraparound, potentially causing instability.
Is CVE-2024-53111 a remote vulnerability?
CVE-2024-53111 is not classified as a remote vulnerability; it requires local access to exploit.