Messages in this thread | | | Date | Mon, 8 Jan 2018 19:22:34 +0100 | From | Willy Tarreau <> | Subject | Re: [PATCH RFC 2/4] x86/arch_prctl: add ARCH_GET_NOPTI and ARCH_SET_NOPTI to enable/disable PTI |
| |
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.
In fact I initially wanted to start with a prctl() flag that acts upon exec because it looked simpler. But then I realized that this would always require a wrapper and that it's not necessarily more convenient. It even makes permission checks more complicated from an administration perspective, and I'd hate to see such a wrapper ending up setuid...
> But in no case should you even try to handle the multi-threaded case - > just error out for trying to change the PTI setting.
I totally agree here. Like Ingo says, there *may* be useful cases for this but I'm not sure we're prepared to address a new class of bugs caused by this yet. And now I can get rid of GET_NOPTI, it was just for debugging.
> 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.
I'll see how to do that, this is not yet 100% clear to me, I'm still discovering (this code has immensely changed since last time I *really* dug into it). So I suspect I'll have to set this variable in __switch_to() based on this other MM flag.
I'll study this.
Thanks, Willy
| |