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: <18cc6ae97e1f4bf5a81167e0c1313935@AcuMS.aculab.com>
Date:   Tue, 15 Sep 2020 08:22:49 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Josh Poimboeuf' <jpoimboe@...hat.com>
CC:     'Borislav Petkov' <bp@...en8.de>,
        "x86@...nel.org" <x86@...nel.org>,
        "Al Viro" <viro@...iv.linux.org.uk>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Will Deacon <will@...nel.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Andrea Arcangeli <aarcange@...hat.com>,
        "Waiman Long" <longman@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        "Thomas Gleixner" <tglx@...utronix.de>,
        Andrew Cooper <andrew.cooper3@...rix.com>,
        Andy Lutomirski <luto@...nel.org>,
        Christoph Hellwig <hch@....de>,
        "Mark Rutland" <mark.rutland@....com>
Subject: RE: [PATCH v3] x86/uaccess: Use pointer masking to limit uaccess
 speculation

From: Josh Poimboeuf
> Sent: 14 September 2020 22:51
> 
> On Mon, Sep 14, 2020 at 09:23:59PM +0000, David Laight wrote:
> > From: Borislav Petkov
> > > Sent: 14 September 2020 18:56
> > >
> > > On Thu, Sep 10, 2020 at 12:22:53PM -0500, Josh Poimboeuf wrote:
> > > > +/*
> > > > + * Sanitize a user pointer such that it becomes NULL if it's not a valid user
> > > > + * pointer.  This prevents speculative dereferences of user-controlled pointers
> > > > + * to kernel space when access_ok() speculatively returns true.  This should be
> > > > + * done *after* access_ok(), to avoid affecting error handling behavior.
> > >
> > > Err, stupid question: can this macro then be folded into access_ok() so
> > > that you don't have to touch so many places and the check can happen
> > > automatically?
> >
> > My thoughts are that access_ok() could return 0 for fail and ~0u
> > for success.
> > You could then do (with a few casts):
> > 	mask = access_ok(ptr, size);
> > 	/* Stop gcc tracking the value of mask. */
> > 	asm volatile( "" : "+r" (mask));
> > 	addr = ptr & mask;
> > 	if (!addr && ptr)  // Let NULL through??
> > 		return -EFAULT;
> >
> > I think there are other changes in the pipeline to remove
> > most of the access_ok() apart from those inside put/get_user()
> > and copy_to/from_user().
> > So the changes should be more limited than you might think.
> 
> Maybe, but I believe that's still going to end up a treewide change.
> 
> And, if we're going to the trouble of changing the access_ok()
> interface, we should change it enough to make sure that accidental uses
> of the old interface (after years of muscle memory) will fail to build.
> 
> We could either add a 3rd argument, or rename it to access_ok_mask() or
> something.

It would take some thought to get right (and fool proof) so would need
new names so it could co-exist with the existing code so that the
changes could 'ripple through' the source tree instead of all having to
be made at once.

	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