Skip to content

Commit

Permalink
x86/sev: Change npages to unsigned long in snp_accept_memory()
Browse files Browse the repository at this point in the history
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: 6c32117 ("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
  • Loading branch information
Tom Lendacky authored and Borislav Petkov (AMD) committed Oct 2, 2023
1 parent 6bc6f7d commit 62d5e97
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions arch/x86/kernel/sev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 62d5e97

Please sign in to comment.