summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@amd.com>2025-03-07 12:37:00 +1100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-03-22 12:56:39 -0700
commit0b16521f95c875e79d657cb8d6911c15080dbb80 (patch)
tree6620f1ca9d5522ba592c488bd65bf79d3f39b084 /arch
parent656e35bf66a11e1adde44c4c12050086dc39f241 (diff)
downloadlinux-0b16521f95c875e79d657cb8d6911c15080dbb80.tar.gz
linux-0b16521f95c875e79d657cb8d6911c15080dbb80.tar.bz2
linux-0b16521f95c875e79d657cb8d6911c15080dbb80.zip
virt: sev-guest: Move SNP Guest Request data pages handling under snp_cmd_mutex
commit 3e385c0d6ce88ac9916dcf84267bd5855d830748 upstream. Compared to the SNP Guest Request, the "Extended" version adds data pages for receiving certificates. If not enough pages provided, the HV can report to the VM how much is needed so the VM can reallocate and repeat. Commit ae596615d93d ("virt: sev-guest: Reduce the scope of SNP command mutex") moved handling of the allocated/desired pages number out of scope of said mutex and create a possibility for a race (multiple instances trying to trigger Extended request in a VM) as there is just one instance of snp_msg_desc per /dev/sev-guest and no locking other than snp_cmd_mutex. Fix the issue by moving the data blob/size and the GHCB input struct (snp_req_data) into snp_guest_req which is allocated on stack now and accessed by the GHCB caller under that mutex. Stop allocating SEV_FW_BLOB_MAX_SIZE in snp_msg_alloc() as only one of four callers needs it. Free the received blob in get_ext_report() right after it is copied to the userspace. Possible future users of snp_send_guest_request() are likely to have different ideas about the buffer size anyways. Fixes: ae596615d93d ("virt: sev-guest: Reduce the scope of SNP command mutex") Signed-off-by: Alexey Kardashevskiy <aik@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Nikunj A Dadhania <nikunj@amd.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20250307013700.437505-3-aik@amd.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/sev.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
index 91f08af31078..82d9250aac34 100644
--- a/arch/x86/include/asm/sev.h
+++ b/arch/x86/include/asm/sev.h
@@ -185,6 +185,9 @@ struct snp_guest_req {
unsigned int vmpck_id;
u8 msg_version;
u8 msg_type;
+
+ struct snp_req_data input;
+ void *certs_data;
};
/*
@@ -245,9 +248,6 @@ struct snp_msg_desc {
struct snp_guest_msg secret_request, secret_response;
struct snp_secrets_page *secrets;
- struct snp_req_data input;
-
- void *certs_data;
struct aesgcm_ctx *ctx;