CVE-2023-52490
Severity CVSS v4.0:
Pending analysis
Type:
CWE-476
NULL Pointer Dereference
Publication date:
11/03/2024
Last modified:
22/04/2025
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
mm: migrate: fix getting incorrect page mapping during page migration<br />
<br />
When running stress-ng testing, we found below kernel crash after a few hours:<br />
<br />
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000<br />
pc : dentry_name+0xd8/0x224<br />
lr : pointer+0x22c/0x370<br />
sp : ffff800025f134c0<br />
......<br />
Call trace:<br />
dentry_name+0xd8/0x224<br />
pointer+0x22c/0x370<br />
vsnprintf+0x1ec/0x730<br />
vscnprintf+0x2c/0x60<br />
vprintk_store+0x70/0x234<br />
vprintk_emit+0xe0/0x24c<br />
vprintk_default+0x3c/0x44<br />
vprintk_func+0x84/0x2d0<br />
printk+0x64/0x88<br />
__dump_page+0x52c/0x530<br />
dump_page+0x14/0x20<br />
set_migratetype_isolate+0x110/0x224<br />
start_isolate_page_range+0xc4/0x20c<br />
offline_pages+0x124/0x474<br />
memory_block_offline+0x44/0xf4<br />
memory_subsys_offline+0x3c/0x70<br />
device_offline+0xf0/0x120<br />
......<br />
<br />
After analyzing the vmcore, I found this issue is caused by page migration.<br />
The scenario is that, one thread is doing page migration, and we will use the<br />
target page&#39;s ->mapping field to save &#39;anon_vma&#39; pointer between page unmap and<br />
page move, and now the target page is locked and refcount is 1.<br />
<br />
Currently, there is another stress-ng thread performing memory hotplug,<br />
attempting to offline the target page that is being migrated. It discovers that<br />
the refcount of this target page is 1, preventing the offline operation, thus<br />
proceeding to dump the page. However, page_mapping() of the target page may<br />
return an incorrect file mapping to crash the system in dump_mapping(), since<br />
the target page->mapping only saves &#39;anon_vma&#39; pointer without setting<br />
PAGE_MAPPING_ANON flag.<br />
<br />
There are seveval ways to fix this issue:<br />
(1) Setting the PAGE_MAPPING_ANON flag for target page&#39;s ->mapping when saving<br />
&#39;anon_vma&#39;, but this can confuse PageAnon() for PFN walkers, since the target<br />
page has not built mappings yet.<br />
(2) Getting the page lock to call page_mapping() in __dump_page() to avoid crashing<br />
the system, however, there are still some PFN walkers that call page_mapping()<br />
without holding the page lock, such as compaction.<br />
(3) Using target page->private field to save the &#39;anon_vma&#39; pointer and 2 bits<br />
page state, just as page->mapping records an anonymous page, which can remove<br />
the page_mapping() impact for PFN walkers and also seems a simple way.<br />
<br />
So I choose option 3 to fix this issue, and this can also fix other potential<br />
issues for PFN walkers, such as compaction.
Impact
Base Score 3.x
5.50
Severity 3.x
MEDIUM
Vulnerable products and versions
CPE | From | Up to |
---|---|---|
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.3 (including) | 6.6.15 (excluding) |
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 6.7 (including) | 6.7.3 (excluding) |
To consult the complete list of CPE names with products and versions, see this page
References to Advisories, Solutions, and Tools
- https://git.kernel.org/stable/c/3889a418b6eb9a1113fb989aaadecf2f64964767
- https://git.kernel.org/stable/c/9128bfbc5c80d8f4874dd0a0424d1f5fb010df1b
- https://git.kernel.org/stable/c/d1adb25df7111de83b64655a80b5a135adbded61
- https://git.kernel.org/stable/c/3889a418b6eb9a1113fb989aaadecf2f64964767
- https://git.kernel.org/stable/c/9128bfbc5c80d8f4874dd0a0424d1f5fb010df1b
- https://git.kernel.org/stable/c/d1adb25df7111de83b64655a80b5a135adbded61