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: <Z-Vn91fADShpp65e@kernel.org>
Date: Thu, 27 Mar 2025 17:00:07 +0200
From: Jarkko Sakkinen <jarkko@...nel.org>
To: James Bottomley <James.Bottomley@...senpartnership.com>
Cc: Stefano Garzarella <sgarzare@...hat.com>,
	linux-integrity@...r.kernel.org, Sumit Garg <sumit.garg@...nel.org>,
	Jens Wiklander <jens.wiklander@...aro.org>,
	Jarkko Sakkinen <jarkko.sakkinen@...nsys.com>,
	Peter Huewe <peterhuewe@....de>, Jason Gunthorpe <jgg@...pe.ca>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tpm: Make chip->{status,cancel,req_canceled} opt

On Thu, Mar 27, 2025 at 10:12:36AM -0400, James Bottomley wrote:
> On Thu, 2025-03-27 at 15:23 +0200, Jarkko Sakkinen wrote:
> > On Thu, Mar 27, 2025 at 10:58:00AM +0100, Stefano Garzarella wrote:
> [...]
> > > > @@ -65,6 +89,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip
> > > > *chip, void *buf, size_t bufsiz)
> > > > 	ssize_t len = 0;
> > > > 	u32 count, ordinal;
> > > > 	unsigned long stop;
> > > > +	u8 status;
> > > 
> > > Why move `status` out of the do/while block?
> > 
> > I'm not a huge fan of stack allocations inside blocks, unless there
> > is a particular reason to do so.
> 
> The move to scope based locking and freeing in cleanup.h necessitates
> using scope based variables as well, so they're something we all have
> to embrace.  They're also useful to tell the compiler when it can
> reclaim the variable and they often create an extra stack frame that
> allows the reclaim to be effective (even if the compiler can work out
> where a variable is no longer reference, the space can't be reclaimed
> if it's in the middle of an in-use stack frame).  I'd say the rule of
> thumb should be only do something like this if it improves readability
> or allows you to remove an additional block from the code.

Reclaiming here is only shift in the frame pointer, nothing to do with
reclaiming resources or freeing locks. Consolidating value state into
single location does improve readability as far as I'm concerned.
 
> Regards,
> 
> James
> 

BR, Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ