From: Willy Tarreau <w@1wt.eu>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
the arch/x86 maintainers <x86@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>,
Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH RFC 2/4] x86/arch_prctl: add ARCH_GET_NOPTI and ARCH_SET_NOPTI to enable/disable PTI
Date: Mon, 8 Jan 2018 21:35:50 +0100 [thread overview]
Message-ID: <20180108203550.GA11238@1wt.eu> (raw)
In-Reply-To: <CA+55aFyfq+qx-68KzDes86ErpjYvu_UmwnqzKiXb1T=GA_+--A@mail.gmail.com>
[ increased the CC list this time ]
On Mon, Jan 08, 2018 at 09:54:05AM -0800, Linus Torvalds wrote:
> On Mon, Jan 8, 2018 at 8:12 AM, Willy Tarreau <w@1wt.eu> wrote:
> > This allows to report the current state of the PTI protection and to
> > enable or disable it for the current task.
>
> So I really think that this needs to be done up-front to avoid a lot
> of complexity. And per mm.
>
> If the process is already threaded (so the mm has multiple users),
> it's too late to start playing games with PTI.
>
> In fact, maybe the whole thing needs to be controlled before "exec"
> happens, so that we have the knowledge as we build up the mm, rather
> than being "runtime" dynamic at all.
>
> But in no case should you even try to handle the multi-threaded case -
> just error out for trying to change the PTI setting.
>
> So make the thing per-mm, and then at task switch time as you switch
> mms, you set the bit in a percpu variable for testing at kernel entry.
So I did something like this (will have to remerge the awful patches
and remove the printks before resending). In short, now here's what it
does :
- added a new x86 flag : "mm->context.pti_disable", depends on
CONFIG_PAGE_TABLE_ISOLATION.
- the new prctl() also depends on this config setting.
- prctl() refuses any change if mm->mm_users > 1
- prctl() refuses to set nopti if !CAP_SYS_RAWIO, but clearing it is
fine without (Ingo's idea)
- __switch_to() sets a new "pti_disable" per-cpu variable to the copy
of mm->context.pti_disable
- entry code in SWITCH_TO_USER_CR3_NOSTACK now checks
PER_CPU_VAR(pti_disable)
First tests show that it still works. One main difference I immediately
observed is that it stops at execve(). This means that it will not be
possible to implement a wrapper to enable the bypass, but on the other
hand it guarantees that any execve() even from a so called "trusted"
process doesn't accidently expose a victim program. So there are pros
and cons here.
I'm personally fine with both the wrapper and the code changes. But I'm
in the easiest situation, working with opensource code that I can easily
update to accommodate the changes. Other users might have a different
opinion here.
Another option could be to have a per-task (and really task here) flag
is only passed to execve() to mention that the per-mm pti_disable has
to be set in the new mm (and which would clear the task flag). But this
mechanism would always require a wrapper. Or we could have both.
I'll clean up my patches tomorrow morning and will post an update. Ideas
and objections welcome in the mean time ;-)
Cheers,
Willy
next prev parent reply other threads:[~2018-01-08 20:36 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-08 16:12 [PATCH RFC 0/4] Per-task PTI activation Willy Tarreau
2018-01-08 16:12 ` [PATCH RFC 1/4] x86/thread_info: add TIF_NOPTI to disable PTI per task Willy Tarreau
2018-01-08 16:57 ` Thomas Gleixner
2018-01-08 17:03 ` Willy Tarreau
2018-01-08 17:14 ` Ingo Molnar
2018-01-08 16:12 ` [PATCH RFC 2/4] x86/arch_prctl: add ARCH_GET_NOPTI and ARCH_SET_NOPTI to enable/disable PTI Willy Tarreau
2018-01-08 16:49 ` Peter Zijlstra
2018-01-08 16:56 ` Willy Tarreau
2018-01-08 17:02 ` Thomas Gleixner
2018-01-08 17:10 ` Willy Tarreau
2018-01-08 17:17 ` Ingo Molnar
2018-01-08 17:26 ` Thomas Gleixner
2018-01-08 17:46 ` Ingo Molnar
2018-01-08 17:05 ` Ingo Molnar
2018-01-08 17:19 ` Peter Zijlstra
2018-01-08 17:26 ` Ingo Molnar
2018-01-08 17:50 ` Borislav Petkov
2018-01-08 17:54 ` Linus Torvalds
2018-01-08 18:22 ` Willy Tarreau
2018-01-08 20:49 ` Thomas Gleixner
2018-01-08 21:03 ` Willy Tarreau
2018-01-08 20:35 ` Willy Tarreau [this message]
2018-01-08 16:12 ` [PATCH RFC 3/4] x86/pti: don't mark the user PGD with _PAGE_NX Willy Tarreau
2018-01-08 17:03 ` Dave Hansen
2018-01-08 17:17 ` Willy Tarreau
2018-01-08 17:23 ` Dave Hansen
2018-01-08 17:30 ` Peter Zijlstra
2018-01-08 17:49 ` Willy Tarreau
2018-01-08 17:21 ` Ingo Molnar
2018-01-08 23:05 ` Andy Lutomirski
2018-01-08 23:09 ` Kees Cook
2018-01-09 4:22 ` Willy Tarreau
2018-01-08 17:05 ` Thomas Gleixner
2018-01-08 17:28 ` Dave Hansen
2018-01-08 17:50 ` Ingo Molnar
2018-01-08 18:25 ` Alan Cox
2018-01-08 18:35 ` Ingo Molnar
2018-01-08 18:35 ` Linus Torvalds
2018-01-08 18:44 ` Dave Hansen
2018-01-08 16:12 ` [PATCH RFC 4/4] x86/entry/pti: don't switch PGD on tasks holding flag TIF_NOPTI Willy Tarreau
2018-01-08 17:11 ` Ingo Molnar
2018-01-08 17:20 ` Dave Hansen
2018-01-08 18:12 ` Willy Tarreau
2018-01-08 23:01 ` Andy Lutomirski
2018-01-08 16:59 ` [PATCH RFC 0/4] Per-task PTI activation Dave Hansen
2018-01-08 17:06 ` Willy Tarreau
2018-01-08 17:17 ` Dave Hansen
2018-01-08 17:13 ` Ingo Molnar
2018-01-09 15:31 ` Eric W. Biederman
2018-01-09 16:02 ` Willy Tarreau
2018-01-09 18:11 ` Zhi Wang
2018-01-09 21:07 ` Eric W. Biederman
2018-01-09 21:57 ` Willy Tarreau
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=20180108203550.GA11238@1wt.eu \
--to=w@1wt.eu \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=gnomes@lxorguk.ukuu.org.uk \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--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=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