CVE-2023-52490: mm: migrate: fix getting incorrect page mapping during page migration
In the Linux kernel, the following vulnerability has been resolved:
mm: migrate: fix getting incorrect page mapping during page migration
The Linux kernel CVE team has assigned CVE-2023-52490 to this issue.
Upstream advisory: https://lore.kernel.org/linux-cve-announce/20240229155245.1571576-31-lee@kernel.org/T
Other sources
In the Linux kernel, the following vulnerability has been resolved:
mm: migrate: fix getting incorrect page mapping during page migration
When running stress-ng testing, we found below kernel crash after a few hours:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 pc : dentryname+0xd8/0x224 lr : pointer+0x22c/0x370 sp : ffff800025f134c0 ...... Call trace: dentryname+0xd8/0x224 pointer+0x22c/0x370 vsnprintf+0x1ec/0x730 vscnprintf+0x2c/0x60 vprintkstore+0x70/0x234 vprintkemit+0xe0/0x24c vprintkdefault+0x3c/0x44 vprintkfunc+0x84/0x2d0 printk+0x64/0x88 dumppage+0x52c/0x530 dumppage+0x14/0x20 setmigratetypeisolate+0x110/0x224 startisolatepagerange+0xc4/0x20c offlinepages+0x124/0x474 memoryblockoffline+0x44/0xf4 memorysubsysoffline+0x3c/0x70 deviceoffline+0xf0/0x120 ......
After analyzing the vmcore, I found this issue is caused by page migration. The scenario is that, one thread is doing page migration, and we will use the target page's ->mapping field to save 'anonvma' pointer between page unmap and page move, and now the target page is locked and refcount is 1.
Currently, there is another stress-ng thread performing memory hotplug, attempting to offline the target page that is being migrated. It discovers that the refcount of this target page is 1, preventing the offline operation, thus proceeding to dump the page. However, pagemapping() of the target page may return an incorrect file mapping to crash the system in dumpmapping(), since the target page->mapping only saves 'anonvma' pointer without setting PAGEMAPPINGANON flag.
There are seveval ways to fix this issue: (1) Setting the PAGEMAPPINGANON flag for target page's ->mapping when saving 'anonvma', but this can confuse PageAnon() for PFN walkers, since the target page has not built mappings yet. (2) Getting the page lock to call pagemapping() in dumppage() to avoid crashing the system, however, there are still some PFN walkers that call pagemapping() without holding the page lock, such as compaction. (3) Using target page->private field to save the 'anonvma' pointer and 2 bits page state, just as page->mapping records an anonymous page, which can remove the pagemapping() impact for PFN walkers and also seems a simple way.
So I choose option 3 to fix this issue, and this can also fix other potential issues for PFN walkers, such as compaction.
— NVD
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
redhat/kernelto a version that resolves this vulnerability.Fixed in 6.6.15 - Upgrade
Upgrade
redhat/kernelto a version that resolves this vulnerability.Fixed in 6.7.3 - Upgrade
Upgrade
redhat/kernelto a version that resolves this vulnerability.Fixed in 6.8 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.1.191 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.6.15 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.7.3 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.6.15-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.1.176-1Fixed in 6.1.190-1Fixed in 6.12.107-1Fixed in 6.12.113-1Fixed in 7.2.12-1Fixed in 7.2.14-1
Event History
Frequently Asked Questions
What is the severity of CVE-2023-52490?
CVE-2023-52490 has a moderate severity level as it involves incorrect page mapping during memory migration in the Linux kernel.
How do I fix CVE-2023-52490?
To fix CVE-2023-52490, update the Linux kernel to version 6.6.15, 6.7.3, or 6.8, or apply the necessary patches provided by your Linux distribution.
Which Linux kernel versions are affected by CVE-2023-52490?
CVE-2023-52490 affects Linux kernel versions prior to 6.6.15, 6.7.3, and 6.8.
What components should I check for CVE-2023-52490?
Check the 'kernel' packages on Red Hat systems and 'linux' packages on Debian systems for vulnerabilities related to CVE-2023-52490.
Is CVE-2023-52490 specific to any distribution?
CVE-2023-52490 is relevant to multiple Linux distributions, including Red Hat and Debian.