OSDN Git Service

virt/sev-guest: Prevent IV reuse in the SNP guest driver
authorPeter Gonda <pgonda@google.com>
Wed, 16 Nov 2022 17:55:58 +0000 (09:55 -0800)
committerBorislav Petkov <bp@suse.de>
Mon, 21 Nov 2022 10:03:40 +0000 (11:03 +0100)
commit47894e0fa6a56a42be6a47c767e79cce8125489d
tree3bf42169c17b4970acba1a2c05def6399fad609a
parenteb7081409f94a9a8608593d0fb63a1aa3d6f95d8
virt/sev-guest: Prevent IV reuse in the SNP guest driver

The AMD Secure Processor (ASP) and an SNP guest use a series of
AES-GCM keys called VMPCKs to communicate securely with each other.
The IV to this scheme is a sequence number that both the ASP and the
guest track.

Currently, this sequence number in a guest request must exactly match
the sequence number tracked by the ASP. This means that if the guest
sees an error from the host during a request it can only retry that
exact request or disable the VMPCK to prevent an IV reuse. AES-GCM
cannot tolerate IV reuse, see: "Authentication Failures in NIST version
of GCM" - Antoine Joux et al.

In order to address this, make handle_guest_request() delete the VMPCK
on any non successful return. To allow userspace querying the cert_data
length make handle_guest_request() save the number of pages required by
the host, then have handle_guest_request() retry the request without
requesting the extended data, then return the number of pages required
back to userspace.

  [ bp: Massage, incorporate Tom's review comments. ]

Fixes: fce96cf044308 ("virt: Add SEV-SNP guest driver")
Reported-by: Peter Gonda <pgonda@google.com>
Signed-off-by: Peter Gonda <pgonda@google.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Cc: stable@kernel.org
Link: https://lore.kernel.org/r/20221116175558.2373112-1-pgonda@google.com
drivers/virt/coco/sev-guest/sev-guest.c