Re: [PATCH RFC 2/4] x86/arch_prctl: add ARCH_GET_NOPTI and ARCH_SET_NOPTI to enable/disable PTI

From: Linus Torvalds
Date: Mon Jan 08 2018 - 12:54:11 EST


On Mon, Jan 8, 2018 at 8:12 AM, Willy Tarreau <w@xxxxxx> 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.

Linus