]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commite8cc4b16d9e379e95ff3d578967512c33e0ff86b
tree3bf42169c17b4970acba1a2c05def6399fad609a
parent2e3c2571813581b04fc6d806cc9bd3184e8163e9
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: 4822b984cb56d ("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