From: David Laight <David.Laight@ACULAB.COM>
To: 'Kees Cook' <keescook@chromium.org>,
"Dr. David Alan Gilbert" <linux@treblig.org>
Cc: Dave Kleikamp <shaggy@kernel.org>,
Christian Brauner <brauner@kernel.org>,
Dave Chinner <dchinner@redhat.com>,
"jfs-discussion@lists.sourceforge.net"
<jfs-discussion@lists.sourceforge.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-hardening@vger.kernel.org"
<linux-hardening@vger.kernel.org>
Subject: RE: [PATCH] jfs: Use unsigned variable for length calculations
Date: Mon, 5 Jun 2023 13:24:07 +0000 [thread overview]
Message-ID: <a84cfb004c5f43589129d70b9b39c2b2@AcuMS.aculab.com> (raw)
In-Reply-To: <202306010954.23972A710A@keescook>
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@chromium.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)
next prev parent reply other threads:[~2023-06-05 13:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-04 18:33 [PATCH] jfs: Use unsigned variable for length calculations Kees Cook
2023-02-04 20:25 ` Dr. David Alan Gilbert
2023-02-06 18:35 ` Kees Cook
2023-02-06 19:50 ` Dr. David Alan Gilbert
2023-06-01 16:55 ` Kees Cook
2023-06-02 5:28 ` Jeff Xu
2023-06-05 13:24 ` David Laight [this message]
2023-06-02 8:32 ` Christian Brauner
2023-06-02 13:37 ` Dave Kleikamp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a84cfb004c5f43589129d70b9b39c2b2@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=brauner@kernel.org \
--cc=dchinner@redhat.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@treblig.org \
--cc=shaggy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox