]> www.infradead.org Git - qemu-nvme.git/commit
target/i386/sev: Fail when invalid hashes table area detected
authorDov Murik <dovmurik@linux.ibm.com>
Thu, 11 Nov 2021 10:00:46 +0000 (10:00 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 18 Nov 2021 11:08:03 +0000 (11:08 +0000)
commita0190bf15044d2410e84f9a12aeac9ed56bd58b0
tree4eda5ab8c9f9fd2fc193bdeec36f339b3791cd21
parent5a0294a21c7677498bf40a447cc4a417d51a3cf4
target/i386/sev: Fail when invalid hashes table area detected

Commit cff03145ed3c ("sev/i386: Introduce sev_add_kernel_loader_hashes
for measured linux boot", 2021-09-30) introduced measured direct boot
with -kernel, using an OVMF-designated hashes table which QEMU fills.

However, no checks are performed on the validity of the hashes area
designated by OVMF.  Specifically, if OVMF publishes the
SEV_HASH_TABLE_RV_GUID entry but it is filled with zeroes, this will
cause QEMU to write the hashes entries over the first page of the
guest's memory (GPA 0).

Add validity checks to the published area.  If the hashes table area's
base address is zero, or its size is too small to fit the aligned hashes
table, display an error and stop the guest launch.  In such case, the
following error will be displayed:

    qemu-system-x86_64: SEV: guest firmware hashes table area is invalid (base=0x0 size=0x0)

Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
Reported-by: Brijesh Singh <brijesh.singh@amd.com>
Acked-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
target/i386/sev.c