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>] [day] [month] [year] [list]
Message-ID: <Z7CJMfywZ8HoqbnL@qasdev.system>
Date: Sat, 15 Feb 2025 12:31:45 +0000
From: Qasim Ijaz <qasdev00@...il.com>
To: Alexander Gordeev <agordeev@...ux.ibm.com>
Cc: gerald.schaefer@...ux.ibm.com, hca@...ux.ibm.com, gor@...ux.ibm.com,
	borntraeger@...ux.ibm.com, svens@...ux.ibm.com,
	linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] s390/mm: Simplify gap clamping in mmap_base() using
 clamp()

On Fri, Feb 14, 2025 at 11:58:24AM +0100, Alexander Gordeev wrote:
> On Tue, Feb 04, 2025 at 04:25:08PM +0000, Qasim Ijaz wrote:
> > mmap_base() has logic to ensure that the variable "gap" stays within the 
> > range defined by "gap_min" and "gap_max". Replace this with the clamp() 
> > macro to shorten and simplify code.
> > 
> > Signed-off-by: Qasim Ijaz <qasdev00@...il.com>
> > ---
> >  arch/s390/mm/mmap.c | 6 +-----
> >  1 file changed, 1 insertion(+), 5 deletions(-)
> > 
> > diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
> > index 76f376876e0d..a3d3e09a2828 100644
> > --- a/arch/s390/mm/mmap.c
> > +++ b/arch/s390/mm/mmap.c
> > @@ -63,11 +63,7 @@ static inline unsigned long mmap_base(unsigned long rnd,
> >  	 */
> >  	gap_min = SZ_128M;
> >  	gap_max = (STACK_TOP / 6) * 5;
> > -
> > -	if (gap < gap_min)
> > -		gap = gap_min;
> > -	else if (gap > gap_max)
> > -		gap = gap_max;
> > +	gap = clamp(gap, gap_min, gap_max);
> >  
> >  	return PAGE_ALIGN(STACK_TOP - gap - rnd);
> >  }
> 
> Whenever possible I personally prefer branches over ternary operators.
> But if one wants to clump it in one line, then gap_min and gap_max
> are also redundant.

Thank you for the feedback Alexander, would you like me to send a v2
patch without the gap_min and gap_max variables as you suggested?

> 
> Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ