lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240625121927.GEZnq1z90yeZFFvaM-@fat_crate.local>
Date: Tue, 25 Jun 2024 14:19:27 +0200
From: Borislav Petkov <bp@...en8.de>
To: "Nikunj A. Dadhania" <nikunj@....com>
Cc: Tom Lendacky <thomas.lendacky@....com>, linux-kernel@...r.kernel.org,
	x86@...nel.org, kvm@...r.kernel.org, mingo@...hat.com,
	tglx@...utronix.de, dave.hansen@...ux.intel.com, pgonda@...gle.com,
	seanjc@...gle.com, pbonzini@...hat.com
Subject: Re: [PATCH v9 03/24] virt: sev-guest: Make payload a variable length
 array

On Mon, Jun 24, 2024 at 11:42:44PM +0530, Nikunj A. Dadhania wrote:
> Sure, here is the new patch. I have separated the variable name changes to a new patch.

Right, please next time you send your set, sort the cleanups to sev-guest
first so that I can pick them up separately.

> 
> Subject: [PATCH] virt: sev-guest: Ensure the SNP guest messages do not exceed
>  a page
> 
> Currently, snp_guest_msg includes a message header (96 bytes) and a
> payload (4000 bytes). There is an implicit assumption here that the SNP
> message header will always be 96 bytes, and with that assumption the
> payload array size has been set to 4000 bytes magic number. If any new
> member is added to the SNP message header, the SNP guest message will span
> more than a page.
> 
> Instead of using magic number '4000' for the payload, declare the
> snp_guest_msg in a way that payload plus the message header do not exceed a
> page.
> 
> Signed-off-by: Nikunj A Dadhania <nikunj@....com>
> Suggested-by: Tom Lendacky <thomas.lendacky@....com>
> ---
>  drivers/virt/coco/sev-guest/sev-guest.h | 2 +-
>  drivers/virt/coco/sev-guest/sev-guest.c | 3 +++
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/virt/coco/sev-guest/sev-guest.h b/drivers/virt/coco/sev-guest/sev-guest.h
> index ceb798a404d6..de14a4f01b9d 100644
> --- a/drivers/virt/coco/sev-guest/sev-guest.h
> +++ b/drivers/virt/coco/sev-guest/sev-guest.h
> @@ -60,7 +60,7 @@ struct snp_guest_msg_hdr {
>  
>  struct snp_guest_msg {
>  	struct snp_guest_msg_hdr hdr;
> -	u8 payload[4000];
> +	u8 payload[PAGE_SIZE - sizeof(struct snp_guest_msg_hdr)];
>  } __packed;
>  
>  #endif /* __VIRT_SEVGUEST_H__ */
> diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
> index 427571a2d1a2..c4aae5d4308e 100644
> --- a/drivers/virt/coco/sev-guest/sev-guest.c
> +++ b/drivers/virt/coco/sev-guest/sev-guest.c
> @@ -1033,6 +1033,9 @@ static int __init sev_guest_probe(struct platform_device *pdev)
>  	snp_dev->dev = dev;
>  	snp_dev->secrets = secrets;
>  
> +	/* Ensure SNP guest messages do not span more than a page */
> +	BUILD_BUG_ON(sizeof(struct snp_guest_msg) > PAGE_SIZE);
> +
>  	/* Allocate the shared page used for the request and response message. */
>  	snp_dev->request = alloc_shared_pages(dev, sizeof(struct snp_guest_msg));
>  	if (!snp_dev->request)
> -- 

Yap, that's exactly how stuff like that should be done:

Acked-by: Borislav Petkov (AMD) <bp@...en8.de>

-- 
Regards/Gruss,
    Boris.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ