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: <16e559e9-7161-4ac5-a823-22c5cf529bab@amd.com>
Date: Tue, 6 May 2025 12:05:49 +1000
From: Alexey Kardashevskiy <aik@....com>
To: Dave Hansen <dave.hansen@...el.com>, x86@...nel.org
Cc: linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
 Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
 Dave Hansen <dave.hansen@...ux.intel.com>, "H. Peter Anvin" <hpa@...or.com>,
 Tom Lendacky <thomas.lendacky@....com>, Nikunj A Dadhania <nikunj@....com>,
 Ard Biesheuvel <ardb@...nel.org>, Brijesh Singh <brijesh.singh@....com>,
 Ashish Kalra <ashish.kalra@....com>, Paolo Bonzini <pbonzini@...hat.com>,
 Michael Roth <michael.roth@....com>,
 Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@...ux.intel.com>,
 Liam Merwick <liam.merwick@...cle.com>
Subject: Re: [PATCH 2/4] x86/sev: Allocate request in TSC_INFO_REQ on stack



On 6/5/25 02:03, Dave Hansen wrote:
> On 5/5/25 07:12, Alexey Kardashevskiy wrote:
>> Allocate a 88 byte request structure on stack and skip needless
>> kzalloc/kfree.
> 
> Could you maybe take a closer look at _all_ of these rather than poking
> at them one at a time?
> 
> snp_guest_request_ioctl, for example, looks to be ~32 bytes. Why fix
> 'struct snp_guest_req' and leave an even worse offender?

snp_guest_request_ioctl is allocated on the stack in snp_guest_ioctl(), it calls, say, get_report() which allocates snp_guest_req on the stack too. Do I miss something?

> Or, maybe just be done with it and convert them all over to __free().
> Yeah, some of them don't need to be kmalloc(), but kmalloc()s are cheap
> and consistency is nice, like in the attached patch.

I'd rather not. cheap != free, also hurts to read all these __free - I know it is cheap to kmalloc() and initialize pointers on the stack with NULL but also useless.

More to the oint - it helps (at least me) to see from declarations what structure must be page aligned page size (or any other special allocation requirements) allocation for aesgcm_encrypt() to not barf later on and what does not.

> It also wouldn't be awful to mix stack and kmalloc() allocations,
> especially when the freeing semantics are the same for stack and
> __free()-annotated allocations.

If anything, I'd rather merge snp_msg_alloc() into snp_msg_init() and skip on allocating the snp_msg_desc struct.

For now I want the patch to be painfully simple to review and make the code a little easier to read.

> But it would be really nice to completely eliminate the goto mess.

I understand it is 2025 but it is not exactly mess. Thanks for the review, I am planning to follow up on this, just probably not exactly with __free-cation of everything.


-- 
Alexey


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ