From: "Woodhouse, David" <dwmw@amazon.co.uk>
To: "torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
"luto@kernel.org" <luto@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"mingo@kernel.org" <mingo@kernel.org>,
"peterz@infradead.org" <peterz@infradead.org>,
"keescook@chromium.org" <keescook@chromium.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"jpoimboe@redhat.com" <jpoimboe@redhat.com>,
"x86@kernel.org" <x86@kernel.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"brgerst@gmail.com" <brgerst@gmail.com>,
"bp@alien8.de" <bp@alien8.de>, "w@1wt.eu" <w@1wt.eu>
Subject: Re: [RFC PATCH v3 6/8] x86/pti: don't mark the user PGD with _PAGE_NX.
Date: Wed, 10 Jan 2018 20:28:27 +0000 [thread overview]
Message-ID: <1515616106.22302.237.camel@amazon.co.uk> (raw)
In-Reply-To: <CALCETrUH6s8=w6O67g39B45of6XBJv2CTt24Xw-darfb6KB42A@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 2168 bytes --]
On Wed, 2018-01-10 at 11:59 -0800, Andy Lutomirski wrote:
> On Wed, Jan 10, 2018 at 11:54 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > On Wed, Jan 10, 2018 at 11:28 AM, Willy Tarreau <w@1wt.eu> wrote:
> > >
> > > Since we're going to keep running on the same PGD when returning to
> > > userspace for certain performance-critical tasks, we'll need the user
> > > pages to be executable. So this code disables the extra protection
> > > that was added consisting in marking user pages _PAGE_NX so that this
> > > pgd remains usable for userspace.
> > Yeah, no. This is wrong.
> >
> > Sure, SMEP gives the same thing in most cases, but not for older CPU's.
> >
> > So NX is a really nice way to make sure that PTI really does protect
> > against user-space gadgets.
> >
> > We don't break that, and we definitely don't break that just because
> > of some broken notion of "let's make page table isolation per-thread".
> >
> If we're going to have a thread without PTI off, that thread needs to
> run with the same page tables for kernel and user, so it needs NX off
> on the user part. I don't see any way around it.
>
> We could nix the entire concept of fine-grained PTI control, or we
> could make it require SMEP, I suppose.
We've been bashing out the precise requirements for RSB clearing (for
pre-SKL to avoid bogus entries) or stuffing (for SKL+ to avoid
underflow causing the BTB to be used).
It looks like we can avoid the RSB clearing on kernel entry if we have
SMEP. And PTI setting NX on userspace pages is equivalent to SMEP for
this purpose — so the RSB clearing basically ended up being AMD-only
(!SMEP && !PTI).
We also need to clear the RSB on vmexit, as documented. And if we
really want 100% support for retpoline on SKL+ instead of saying "use
IBRS if you're paranoid", then there are a few more cases where we need
to stuff it to avoid underflow (which is the same operation, but Arjan
insists we should differentiate the two, which is reasonable enough).
So... we'd really like to *not* lose the property that KPTI implies
SMEP-like NX of user space for the kernel.
[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5210 bytes --]
[-- Attachment #2.1: Type: text/plain, Size: 197 bytes --]
Amazon Web Services UK Limited. Registered in England and Wales with registration number 08650665 and which has its registered office at 60 Holborn Viaduct, London EC1A 2FD, United Kingdom.
[-- Attachment #2.2: Type: text/html, Size: 197 bytes --]
next prev parent reply other threads:[~2018-01-10 20:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 19:28 [RFC PATCH v3 0/8] Per process PTI activation Willy Tarreau
2018-01-10 19:28 ` [RFC PATCH v3 1/8] x86/thread_info: add TIF_DISABLE_PTI_{NOW,NEXT} to disable PTI per task Willy Tarreau
2018-01-10 19:28 ` [RFC PATCH v3 2/8] x86/pti: add new config option PER_PROCESS_PTI Willy Tarreau
2018-01-10 19:28 ` [RFC PATCH v3 3/8] x86/pti: create the pti_adjust sysctl Willy Tarreau
2018-01-10 19:28 ` [RFC PATCH v3 4/8] x86/arch_prctl: add ARCH_DISABLE_PTI_{NOW,NEXT} to enable/disable PTI Willy Tarreau
2018-01-10 19:28 ` [RFC PATCH v3 5/8] exec: take care of disabling PTI upon execve() Willy Tarreau
2018-01-10 19:28 ` [RFC PATCH v3 6/8] x86/pti: don't mark the user PGD with _PAGE_NX Willy Tarreau
2018-01-10 19:54 ` Linus Torvalds
2018-01-10 19:59 ` Andy Lutomirski
2018-01-10 20:28 ` Woodhouse, David [this message]
2018-01-11 6:23 ` Willy Tarreau
2018-02-23 17:58 ` Konrad Rzeszutek Wilk
2018-02-23 19:30 ` Dave Hansen
2018-01-10 20:20 ` Dave Hansen
2018-01-11 6:27 ` Willy Tarreau
2018-01-10 19:28 ` [RFC PATCH v3 7/8] x86/entry/pti: avoid setting CR3 when it's already correct Willy Tarreau
2018-01-10 19:28 ` [RFC PATCH v3 8/8] x86/entry/pti: don't switch PGD when TIF_DISABLE_PTI_NOW is set Willy Tarreau
2018-01-10 19:35 ` [RFC PATCH v3 0/8] Per process PTI activation Linus Torvalds
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=1515616106.22302.237.camel@amazon.co.uk \
--to=dwmw@amazon.co.uk \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=w@1wt.eu \
--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