CVE-2024-50066: mm/mremap: fix move_normal_pmd/retract_page_tables race

Published Oct 23, 2024
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

mm/mremap: fix movenormalpmd/retractpagetables race

In mremap(), movepagetables() looks at the type of the PMD entry and the specified address range to figure out by which method the next chunk of page table entries should be moved.

At that point, the mmaplock is held in write mode, but no rmap locks are held yet. For PMD entries that point to page tables and are fully covered by the source address range, movepgtentry(NORMALPMD, ...) is called, which first takes rmap locks, then does movenormalpmd(). movenormalpmd() takes the necessary page table locks at source and destination, then moves an entire page table from the source to the destination.

The problem is: The rmap locks, which protect against concurrent page table removal by retractpagetables() in the THP code, are only taken after the PMD entry has been read and it has been decided how to move it. So we can race as follows (with two processes that have mappings of the same tmpfs file that is stored on a tmpfs mount with huge=advise); note that process A accesses page tables through the MM while process B does it through the file rmap:

process A process B ========= ========= mremap mremapto movevma movepagetables getoldpmd allocnewpmd PREEMPT madvise(MADVCOLLAPSE) domadvise madvisewalkvmas madvisevmabehavior madvisecollapse hpagecollapsescanfile collapsefile retractpagetables immaplockread(mapping) pmdpcollapseflush immapunlockread(mapping) movepgtentry(NORMALPMD, ...) takermaplocks movenormalpmd droprmaplocks

When this happens, movenormalpmd() can end up creating bogus PMD entries in the line pmdpopulate(mm, newpmd, pmdpgtable(pmd)). The effect depends on arch-specific and machine-specific details; on x86, you can end up with physical page 0 mapped as a page table, which is likely exploitable for user->kernel privilege escalation.

Fix the race by letting process B recheck that the PMD still points to a page table after the rmap locks have been taken. Otherwise, we bail and let the caller fall back to the PTE-level copying path, which will then bail immediately at the pmdnone() check.

Bug reachability: Reaching this bug requires that you can create shmem/file THP mappings - anonymous THP uses different code that doesn't zap stuff under rmap locks. File THP is gated on an experimental config flag (CONFIGREADONLYTHPFORFS), so on normal distro kernels you need shmem THP to hit this bug. As far as I know, getting shmem THP normally requires that you can mount your own tmpfs with the right mount flags, which would require creating your own user+mount namespace; though I don't know if some distros maybe enable shmem THP by default or something like that.

Bug impact: This issue can likely be used for user->kernel privilege escalation when it is reachable.

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

8 affected componentsFixes available
Linux Linux kernel>=6.6<6.6.58
Linux Linux kernel>=6.7<6.11.5
Linux Linux kernel=6.12-rc1
Linux Linux kernel=6.12-rc2
Linux Linux kernel=6.12-rc3
debian/linux
5.10.223-15.10.234-16.1.129-16.1.135-16.12.25-16.12.27-1
Microsoft azl3 kernel 6.6.57.1-7
Microsoft azl3 kernel 6.6.64.2-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/linux to 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-1Fixed in 6.12.27-1

Event History

Oct 23, 2024
CVE Published
via MITRE·05:20 AM
Data Sourced
via MITRE·05:20 AM
DescriptionSeverity
Data Sourced
via NVD·06:15 AM
RemedyDescriptionSeverityWeaknessAffected Software
Jan 29, 2025
Data Sourced
via Microsoft·08:00 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·08:00 AM
Affected Software
Updated
via Microsoft·08:00 AM
DescriptionSeverity
Feb 20, 2025
Data Sourced
via Launchpad·12:47 AM
Description
Apr 29, 2025
Data Sourced
12:00 AM
SeverityWeakness
May 3, 2025
Data Sourced
via Ubuntu·01:06 AM
RemedyDescriptionSeverityAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Peer vulnerabilities

Found alongside the following vulnerabilities.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-50066?

CVE-2024-50066 has a medium severity rating due to the potential race condition in the Linux kernel.

2

How do I fix CVE-2024-50066?

To fix CVE-2024-50066, update your Linux kernel to a version that includes the patch addressing the vulnerability.

3

Which versions of Linux kernel are affected by CVE-2024-50066?

CVE-2024-50066 affects Linux kernel versions between 6.7 and 6.11.5, and specific RC versions including 6.12-rc1 to 6.12-rc3.

4

What kind of vulnerability is CVE-2024-50066?

CVE-2024-50066 is a race condition vulnerability that occurs in the mremap() function of the Linux kernel.

5

Is there a known exploit for CVE-2024-50066?

As of now, there are no known active exploits for CVE-2024-50066.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203