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] [thread-next>] [day] [month] [year] [list]
Message-ID: <fe74fd23-5a5f-9539-ba1e-fb22f4fa5fc1@amd.com>
Date: Mon, 24 Jun 2024 08:00:38 -0500
From: Tom Lendacky <thomas.lendacky@....com>
To: "Nikunj A. Dadhania" <nikunj@....com>, Borislav Petkov <bp@...en8.de>
Cc: 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 6/23/24 11:16, Nikunj A. Dadhania wrote:
> On 6/21/2024 10:24 PM, Borislav Petkov wrote:
>> On Fri, May 31, 2024 at 10:00:17AM +0530, Nikunj A Dadhania wrote:
>>> Currently, guest message is PAGE_SIZE bytes and payload is hard-coded to
>>> 4000 bytes, assuming snp_guest_msg_hdr structure as 96 bytes.
>>>
>>> Remove the structure size assumption and hard-coding of payload size and
>>> instead use variable length array.
>>
>> I don't understand here what hard-coding is being removed?
>>
>> It is simply done differently:
>>
>> from
>>
>>> -     snp_dev->request = alloc_shared_pages(dev, sizeof(struct snp_guest_msg));
>>
>> to
>>
>>> +     snp_dev->request = alloc_shared_pages(dev, SNP_GUEST_MSG_SIZE);
>>
>> Maybe I'm missing the point here but do you mean by removing the hard-coding
>> this:
>>
>> +#define SNP_GUEST_MSG_SIZE 4096
>> +#define SNP_GUEST_MSG_PAYLOAD_SIZE (SNP_GUEST_MSG_SIZE - sizeof(struct snp_guest_msg))
>>
>> where the msg payload size will get computed at build time and you won't have
>> to do that 4000 in the struct definition:
>>
>> 	u8 payload[4000];
>>
>> ?
> 
> Yes, payload was earlier fixed at 4000 bytes, without considering the size of snp_guest_msg.

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.

Thanks,
Tom

> 
> Regards
> Nikunj

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ