CVE-2023-52659: x86/mm: Ensure input to pfn_to_kaddr() is treated as a 64-bit type
In the Linux kernel, the following vulnerability has been resolved:
x86/mm: Ensure input to pfntokaddr() is treated as a 64-bit type
On 64-bit platforms, the pfntokaddr() macro requires that the input value is 64 bits in order to ensure that valid address bits don't get lost when shifting that input by PAGESHIFT to calculate the physical address to provide a virtual address for.
One such example is in pvalidatepages() (used by SEV-SNP guests), where the GFN in the struct used for page-state change requests is a 40-bit bit-field, so attempts to pass this GFN field directly into pfntokaddr() ends up causing guest crashes when dealing with addresses above the 1TB range due to the above.
Fix this issue with SEV-SNP guests, as well as any similar cases that might cause issues in current/future code, by using an inline function, instead of a macro, so that the input is implicitly cast to the expected 64-bit input type prior to performing the shift operation.
While it might be argued that the issue is on the caller side, other archs/macros have taken similar approaches to deal with instances like this, such as ARM explicitly casting the input to physaddrt:
e48866647b48 ("ARM: 8396/1: use physaddrt in pfntokaddr()")
A C inline function is even better though.
[ mingo: Refined the changelog some more & added alwaysinline. ]
Other sources
In the Linux kernel, the following vulnerability has been resolved:
x86/mm: Ensure input to pfntokaddr() is treated as a 64-bit type
The Linux kernel CVE team has assigned CVE-2023-52659 to this issue.
Upstream advisory: https://lore.kernel.org/linux-cve-announce/2024051755-CVE-2023-52659-6f51@gregkh/T
— Red Hat
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2023-52659?
CVE-2023-52659 is classified as a medium severity vulnerability in the Linux kernel.
How do I fix CVE-2023-52659?
To fix CVE-2023-52659, upgrade the kernel to version 6.6.23 or later for Red Hat or to specified versions for Debian as detailed in the advisory.
What systems are affected by CVE-2023-52659?
CVE-2023-52659 affects the Linux kernel on 64-bit platforms across various distributions including Red Hat and Debian.
What is the impact of CVE-2023-52659?
CVE-2023-52659 may allow an attacker to exploit loss of address bits leading to potential memory corruption or loss of intended behavior.
When was CVE-2023-52659 disclosed?
CVE-2023-52659 was disclosed as part of a set of kernel vulnerabilities affecting various versions of the Linux kernel.