Skip to contentSkip to conversation

CVE-2024-57881: mm/page_alloc: don't call pfn_to_page() on possibly non-existent PFN in split_large_buddy()

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Jan 11, 2025

lore
Share & tools
lore
#0 lore raw

Description
===========

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

mm/page_alloc: don't call pfn_to_page() on possibly non-existent PFN in split_large_buddy()

In split_large_buddy(), we might call pfn_to_page() on a PFN that might not exist. In corner cases, such as when freeing the highest pageblock in the last memory section, this could result with CONFIG_SPARSEMEM && !CONFIG_SPARSEMEM_EXTREME in __pfn_to_section() returning NULL and and __section_mem_map_addr() dereferencing that NULL pointer.

Let's fix it, and avoid doing a pfn_to_page() call for the first iteration, where we already have the page.

So far this was found by code inspection, but let's just CC stable as the fix is easy.

The Linux kernel CVE team has assigned CVE-2024-57881 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 6.10 with commit fd919a85cd55be5d00a6a7372071f44c8eafb825 and fixed in 6.12.7 with commit 4234ca9884bcae9e48ed38652d91696ad5cd591d
	Issue introduced in 6.10 with commit fd919a85cd55be5d00a6a7372071f44c8eafb825 and fixed in 6.13-rc4 with commit faeec8e23c10bd30e8aa759a2eb3018dae00f924

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2024-57881

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
mm/page_alloc.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/4234ca9884bcae9e48ed38652d91696ad5cd591d
	https://git.kernel.org/stable/c/faeec8e23c10bd30e8aa759a2eb3018dae00f924