]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86/sev: Change npages to unsigned long in snp_accept_memory()
authorTom Lendacky <thomas.lendacky@amd.com>
Thu, 22 Jun 2023 13:45:05 +0000 (08:45 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Oct 2023 20:03:05 +0000 (22:03 +0200)
commit 62d5e970d022ef4bde18948dd67247c3194384c1 upstream.

In snp_accept_memory(), the npages variables value is calculated from
phys_addr_t variables but is an unsigned int. A very large range passed
into snp_accept_memory() could lead to truncating npages to zero. This
doesn't happen at the moment but let's be prepared.

Fixes: 6c3211796326 ("x86/sev: Add SNP-specific unaccepted memory support")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Cc: <stable@kernel.org>
Link: https://lore.kernel.org/r/6d511c25576494f682063c9fb6c705b526a3757e.1687441505.git.thomas.lendacky@amd.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/sev.c

index 1ee7bed453ded5df0d50469b6f75fbd7ca1ed189..2b0342a03c1ba0145a9327c64453362dce0792e2 100644 (file)
@@ -868,8 +868,7 @@ void snp_set_memory_private(unsigned long vaddr, unsigned long npages)
 
 void snp_accept_memory(phys_addr_t start, phys_addr_t end)
 {
-       unsigned long vaddr;
-       unsigned int npages;
+       unsigned long vaddr, npages;
 
        if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
                return;