[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/3] sev/i386: Warn if using -kernel with invalid OVMF hashes
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH 2/3] sev/i386: Warn if using -kernel with invalid OVMF hashes table area |
Date: |
Wed, 3 Nov 2021 16:07:45 +0000 |
User-agent: |
Mutt/2.0.7 (2021-05-04) |
On Mon, Nov 01, 2021 at 10:21:35AM +0000, Dov Murik wrote:
> 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, warn and skip the hashes entries addition. In such case, the
> following warning will be displayed:
>
> qemu-system-x86_64: warning: SEV: OVMF's 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>
> ---
> target/i386/sev.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index 682b8ccf6c..a20ddb545e 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -1201,13 +1201,18 @@ bool
> sev_add_kernel_loader_hashes(SevKernelLoaderContext *ctx, Error **errp)
> uint8_t kernel_hash[HASH_SIZE];
> uint8_t *hashp;
> size_t hash_len = HASH_SIZE;
> - int aligned_len;
> + int aligned_len = ROUND_UP(sizeof(SevHashTable), 16);
>
> if (!pc_system_ovmf_table_find(SEV_HASH_TABLE_RV_GUID, &data, NULL)) {
> warn_report("SEV: kernel specified but OVMF has no hash table guid");
> return false;
> }
> area = (SevHashTableDescriptor *)data;
> + if (!area->base || area->size < aligned_len) {
> + warn_report("SEV: OVMF's hashes table area is invalid (base=0x%x
> size=0x%x)",
> + area->base, area->size);
> + return false;
> + }
I think warn_report is likely a bad idea.
If someone's use case is relying on the hashs being populated, then
we need to be able to error_report and exit, not carry on with a
known broken setup.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
- Re: [PATCH 1/3] sev/i386: Allow launching with -kernel if no OVMF hashes table found, (continued)
[PATCH 2/3] sev/i386: Warn if using -kernel with invalid OVMF hashes table area, Dov Murik, 2021/11/01
Re: [PATCH 2/3] sev/i386: Warn if using -kernel with invalid OVMF hashes table area,
Daniel P . Berrangé <=
Re: [PATCH 0/3] SEV: fixes for -kernel launch with incompatible OVMF, Brijesh Singh, 2021/11/02
Re: [PATCH 0/3] SEV: fixes for -kernel launch with incompatible OVMF, Dov Murik, 2021/11/05
Re: [PATCH 0/3] SEV: fixes for -kernel launch with incompatible OVMF, Brijesh Singh, 2021/11/08
Re: [PATCH 0/3] SEV: fixes for -kernel launch with incompatible OVMF, Dov Murik, 2021/11/09