summaryrefslogtreecommitdiff
path: root/arch/x86
diff options
context:
space:
mode:
authorNikunj A Dadhania <nikunj@amd.com>2024-07-31 18:07:55 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-10-10 13:03:14 +0300
commitf20a9ddc6f1d2033400f1aaffc050f390af69abf (patch)
tree94924254ec9f1063b47f83fba9afe50905f0befe /arch/x86
parentc0b4f5d94934c290479180868a32c15ba36a6d9e (diff)
downloadlinux-f20a9ddc6f1d2033400f1aaffc050f390af69abf.tar.xz
virt: sev-guest: Ensure the SNP guest messages do not exceed a page
[ Upstream commit 2b9ac0b84c2cae91bbaceab62df4de6d503421ec ] Currently, struct snp_guest_msg includes a message header (96 bytes) and a payload (4000 bytes). There is an implicit assumption here that the SNP message header will always be 96 bytes, and with that assumption the payload array size has been set to 4000 bytes - a magic number. If any new member is added to the SNP message header, the SNP guest message will span more than a page. Instead of using a magic number for the payload, declare struct snp_guest_msg in a way that payload plus the message header do not exceed a page. [ bp: Massage. ] Suggested-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Nikunj A Dadhania <nikunj@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20240731150811.156771-5-nikunj@amd.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/sev.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
index 79bbe2be900e..ee34ab00a8d6 100644
--- a/arch/x86/include/asm/sev.h
+++ b/arch/x86/include/asm/sev.h
@@ -164,7 +164,7 @@ struct snp_guest_msg_hdr {
struct snp_guest_msg {
struct snp_guest_msg_hdr hdr;
- u8 payload[4000];
+ u8 payload[PAGE_SIZE - sizeof(struct snp_guest_msg_hdr)];
} __packed;
struct sev_guest_platform_data {