Re: [PATCH v9 03/24] virt: sev-guest: Make payload a variable length array

Borislav Petkov
2024-06-24T13:40:19Z

On Mon, Jun 24, 2024 at 08:00:38AM -0500, Tom Lendacky wrote:
> An alternative to the #defines would be something like:
>
> struct snp_guest_msg {
> struct snp_guest_msg_hdr hdr;
> u8 payload[PAGE_SIZE - sizeof(struct snp_guest_msg_hdr)];
> } __packed;
>
> Not sure it matters, but does reduce the changes while ensuring the
> payload plus header doesn't exceed a page.

Yeah, because that would've been my next question - the requirement to keep it
<= PAGE_SIZE.

So yeah, Nikunj, please do that also and add a

BUILD_BUG_ON(sizeof(struct snp_guest_msg) > PAGE_SIZE);

somewhere in the driver to catch all kinds of funky stuff.

Thx.

--
Regards/Gruss,
Boris.