mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Josh Poimboeuf' <jpoimboe@redhat.com>
Cc: 'Borislav Petkov' <bp@alien8.de>,
	"x86@kernel.org" <x86@kernel.org>,
	"Al Viro" <viro@zeniv.linux.org.uk>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Will Deacon <will@kernel.org>,
	Dan Williams <dan.j.williams@intel.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	"Waiman Long" <longman@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Andy Lutomirski <luto@kernel.org>, Christoph Hellwig <hch@lst.de>,
	"Mark Rutland" <mark.rutland@arm.com>
Subject: RE: [PATCH v3] x86/uaccess: Use pointer masking to limit uaccess speculation
Date: Tue, 15 Sep 2020 08:22:49 +0000	[thread overview]
Message-ID: <18cc6ae97e1f4bf5a81167e0c1313935@AcuMS.aculab.com> (raw)
In-Reply-To: <20200914215104.cjvycgie2wd3omtn@treble>

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)

  reply	other threads:[~2020-09-15  8:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10 17:22 Josh Poimboeuf
2020-09-10 19:25 ` Peter Zijlstra
2020-09-14 17:56 ` Borislav Petkov
2020-09-14 18:48   ` Dan Williams
2020-09-14 19:21     ` Borislav Petkov
2020-09-14 19:27       ` Josh Poimboeuf
2020-09-14 19:34         ` Andrew Cooper
2020-09-14 21:23   ` David Laight
2020-09-14 21:51     ` Josh Poimboeuf
2020-09-15  8:22       ` David Laight [this message]
2020-09-14 19:06 ` Dan Williams
2020-09-14 19:50   ` Josh Poimboeuf
2020-09-14 19:42 ` Borislav Petkov
2020-09-14 19:53 ` Josh Poimboeuf
2020-09-14 20:51   ` Thomas Gleixner
2020-09-23  3:38   ` Al Viro
2021-05-03 23:31     ` Josh Poimboeuf
2021-05-04  0:31       ` Al Viro
2021-05-04  4:12         ` Josh Poimboeuf

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=18cc6ae97e1f4bf5a81167e0c1313935@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=aarcange@redhat.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=hch@lst.de \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=luto@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will@kernel.org \
    --cc=x86@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

all inboxes | Powered by JetHome®