linux/drivers/virt/coco
Alexey Kardashevskiy 3e385c0d6c virt: sev-guest: Move SNP Guest Request data pages handling under snp_cmd_mutex
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

  ae596615d9 ("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: ae596615d9 ("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
2025-03-07 14:09:33 +01:00
..
arm-cca-guest arm64: rsi: Add automatic arm-cca-guest module loading 2025-01-08 13:58:49 +00:00
efi_secret Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
pkvm-guest drivers/virt: pkvm: Don't fail ioremap() call if MMIO_GUARD fails 2024-12-03 18:10:20 +00:00
sev-guest virt: sev-guest: Move SNP Guest Request data pages handling under snp_cmd_mutex 2025-03-07 14:09:33 +01:00
tdx-guest virt: tdx-guest: Just leak decrypted memory on unrecoverable errors 2024-12-29 10:18:44 +01:00
Kconfig virt: arm-cca-guest: TSM_REPORT support for realms 2024-10-23 10:19:33 +01:00
Makefile virt: arm-cca-guest: TSM_REPORT support for realms 2024-10-23 10:19:33 +01:00
tsm.c x86/sev: Extend the config-fs attestation support for an SVSM 2024-06-17 20:42:57 +02:00