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: <202306010954.23972A710A@keescook>
Date:   Thu, 1 Jun 2023 09:55:14 -0700
From:   Kees Cook <keescook@...omium.org>
To:     "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, linux-kernel@...r.kernel.org,
        linux-hardening@...r.kernel.org
Subject: Re: [PATCH] jfs: Use unsigned variable for length calculations

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:
> > > * Kees Cook (keescook@...omium.org) wrote:
> > > > To avoid confusing the compiler about possible negative sizes, switch
> > > > "ssize" which can never be negative from int to u32.  Seen with GCC 13:
> > > > 
> > > > ../fs/jfs/namei.c: In function 'jfs_symlink': ../include/linux/fortify-string.h:57:33: warning: '__builtin_memcpy' pointer overflow between offset 0 and size [-2147483648, -1]
> > > > [-Warray-bounds=]
> > > >    57 | #define __underlying_memcpy     __builtin_memcpy
> > > >       |                                 ^
> > > > ...
> > > > ../fs/jfs/namei.c:950:17: note: in expansion of macro 'memcpy'
> > > >   950 |                 memcpy(ip->i_link, name, ssize);
> > > >       |                 ^~~~~~
> > > > 
> > > > Cc: Dave Kleikamp <shaggy@...nel.org>
> > > > Cc: Christian Brauner <brauner@...nel.org>
> > > > Cc: Dave Chinner <dchinner@...hat.com>
> > > > Cc: jfs-discussion@...ts.sourceforge.net
> > > > Signed-off-by: Kees Cook <keescook@...omium.org>
> > > > ---
> > > >  fs/jfs/namei.c | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
> > > > index b29d68b5eec5..494b9f4043cf 100644
> > > > --- a/fs/jfs/namei.c
> > > > +++ b/fs/jfs/namei.c
> > > > @@ -876,7 +876,7 @@ static int jfs_symlink(struct mnt_idmap *idmap, struct inode *dip,
> > > >  	tid_t tid;
> > > >  	ino_t ino = 0;
> > > >  	struct component_name dname;
> > > > -	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.
> 
> Fair enough.

Thread ping. Can someone pick this up (or Ack it for my tree), please?

Thanks!

-Kees

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ