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]
Date:   Thu, 7 Jan 2021 10:06:43 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Randy Dunlap' <rdunlap@...radead.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Alexander Viro <viro@...iv.linux.org.uk>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Peter Zijlstra" <peterz@...radead.org>
Subject: RE: [PATCH] mm/uaccess: Use 'unsigned long' to placate UBSAN
 warnings, again

From: Randy Dunlap
> Sent: 23 December 2020 07:19
> 
> On 12/22/20 9:04 PM, Josh Poimboeuf wrote:
> > GCC 7 has a known bug where UBSAN ignores '-fwrapv' and generates false
> > signed-overflow-UB warnings.  The type mismatch between 'i' and
> > 'nr_segs' in copy_compat_iovec_from_user() is causing such a warning,
> > which also happens to violate uaccess rules:
> >
> >   lib/iov_iter.o: warning: objtool: iovec_from_user()+0x22d: call to __ubsan_handle_add_overflow()
> with UACCESS enabled
> >
> > Fix it by making the variable types match.
> >
> > This is similar to a previous commit:
> >
> >   29da93fea3ea ("mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions")
> >
> > Reported-by: Randy Dunlap <rdunlap@...radead.org>
> > Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
> 
> All good. Thanks.
> 
> Acked-by: Randy Dunlap <rdunlap@...radead.org> # build-tested

FWIW I've tested the equivalent change locally.
It generates rather better code on amd64.
(You don't want to index arrays with 'int' unless you really have to.)
So probably:

Acked-by: David Laight <david.laight@...lab.com>

	David

> 
> 
> > ---
> >  lib/iov_iter.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> > index 1635111c5bd2..2e6a42f5d1df 100644
> > --- a/lib/iov_iter.c
> > +++ b/lib/iov_iter.c
> > @@ -1656,7 +1656,8 @@ static int copy_compat_iovec_from_user(struct iovec *iov,
> >  {
> >  	const struct compat_iovec __user *uiov =
> >  		(const struct compat_iovec __user *)uvec;
> > -	int ret = -EFAULT, i;
> > +	int ret = -EFAULT;
> > +	unsigned long i;
> >
> >  	if (!user_access_begin(uvec, nr_segs * sizeof(*uvec)))
> >  		return -EFAULT;
> >
> 
> 
> --
> ~Randy

-
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