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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a84cfb004c5f43589129d70b9b39c2b2@AcuMS.aculab.com>
Date:   Mon, 5 Jun 2023 13:24:07 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Kees Cook' <keescook@...omium.org>,
        "Dr. David Alan Gilbert" <linux@...blig.org>
CC:     Dave Kleikamp <shaggy@...nel.org>,
        Christian Brauner <brauner@...nel.org>,
        Dave Chinner <dchinner@...hat.com>,
        "jfs-discussion@...ts.sourceforge.net" 
        <jfs-discussion@...ts.sourceforge.net>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>
Subject: RE: [PATCH] jfs: Use unsigned variable for length calculations

From: Kees Cook
> Sent: 01 June 2023 17:55
> 
> On Mon, Feb 06, 2023 at 07:50:42PM +0000, Dr. David Alan Gilbert wrote:
> > * Kees Cook (keescook@...omium.org) wrote:
> > > On Sat, Feb 04, 2023 at 08:25:45PM +0000, Dr. David Alan Gilbert wrote:
...
> > > > > -	int ssize;		/* source pathname size */
> > > > > +	u32 ssize;		/* source pathname size */
> > > >
> > > > Had you considered using size_t - this is set from a strlen and used by a memcpy
> > > > that both talk size_t.
> > >
> > > I considered that, but I've had other maintainers upset about doubling
> > > the variable size.
> >
> > I bet at least on some platforms it's cheaper as the 64 bit.
> >
> > > I opted to keep the variable 32-bit here, so the
> > > machine code would only change to lose signed-ness.

On x86-64 'unsigned int' and 'signed long' are likely to
generate the best code.

If you use 'signed int' it will to have to be sign extended
if used in a 64-bit expression (eg as an array index).

(That is probably true of most 64bit arch.)

OTOH 'unsigned long' always requires a REX prefix - making the
code that bit larger.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ