From: David Laight <David.Laight@ACULAB.COM>
To: 'Josh Poimboeuf' <jpoimboe@redhat.com>,
"x86@kernel.org" <x86@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
Al Viro <viro@zeniv.linux.org.uk>, 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 v2] x86/uaccess: Use pointer masking to limit uaccess speculation
Date: Wed, 9 Sep 2020 08:20:07 +0000 [thread overview]
Message-ID: <01b027d0d46d4572b3b16e2b49f0f2b3@AcuMS.aculab.com> (raw)
In-Reply-To: <20200908174329.ryfprry62e4tuodw@treble>
From: Josh Poimboeuf <jpoimboe@redhat.com>
> Sent: 08 September 2020 18:43
> Hi x86 maintainers,
...
> > --- a/arch/x86/lib/putuser.S
> > +++ b/arch/x86/lib/putuser.S
> > @@ -38,6 +38,8 @@ SYM_FUNC_START(__put_user_1)
> > ENTER
> > cmp TASK_addr_limit(%_ASM_BX),%_ASM_CX
> > jae .Lbad_put_user
> > + sbb %_ASM_BX, %_ASM_BX /* uaccess_mask_ptr() */
> > + and %_ASM_BX, %_ASM_CX
> > ASM_STAC
> > 1: movb %al,(%_ASM_CX)
> > xor %eax,%eax
For 64bit the sbb+and pattern can be replaced by an instruction
that clears the high bit (eg btr $63, %rcx).
This isn't dependant on the earlier instructions so can execute
in parallel with them.
I still think that doing the same comparisons in access_ok()
and for the pointer masking is silly - and they should get merged.
While it may be possible to fake 'asm volatile goto with outputs'
by using a local asm register variable and alternative pattern
might be to have access_ok() return 0 (fail) or ~0 (ok).
Then the usage can be (with a load of casts):
p1 = p & access_ok(p);
if (!p1 && p)
return -EFAULT;
foo(*p1);
With any luck the compiler will use the result of the & for the
!p1 test.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2020-09-09 8:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-01 15:30 Josh Poimboeuf
2020-09-08 17:43 ` Josh Poimboeuf
2020-09-09 8:20 ` David Laight [this message]
2020-09-09 12:46 ` Josh Poimboeuf
2020-09-09 13:00 ` Josh Poimboeuf
2020-09-09 13:46 ` David Laight
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=01b027d0d46d4572b3b16e2b49f0f2b3@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=aarcange@redhat.com \
--cc=andrew.cooper3@citrix.com \
--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®