Re: [PATCH v6 19/42] x86/mm: Add support to validate memory when changing C-bit

From: Borislav Petkov
Date: Thu Nov 11 2021 - 11:01:24 EST


On Thu, Nov 11, 2021 at 08:49:49AM -0600, Tom Lendacky wrote:
> 2032 => sizeof(ghcb->shared_buffer) ?

Or that.

> The idea is that a full snp_psc_desc structure is meant to fit completely in
> the shared_buffer area. So if there are no compile time checks, then the
> code on the HV side will need to ensure that the input doesn't cause the HV
> to access the structure outside of the shared_buffer area - which, IIRC, it
> does (think protect against a malicious guest), so the min_t() on the memcpy
> should be safe on the guest side.
>
> But given the snp_psc_desc is sized/meant to fit completely in the
> shared_buffer, a compile time check would be a good idea, too, right?

If the desc thing is meant to fit, then a compile-time check is also a
good way to express that intention. So yeah.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette