Messages in this thread Patch in this message | | | From | Willy Tarreau <> | Subject | [RFC PATCH v3 5/8] exec: take care of disabling PTI upon execve() | Date | Wed, 10 Jan 2018 20:28:17 +0100 |
| |
Here's what we do here : - TIF_DISABLE_PTI_NOW is always cleared as we don't want an unprotected process to pass its lack of protection to any possible other program it could exec.
- TIF_DISABLE_PTI_NEXT is copied into TIF_DISABLE_PTI_NOW and cleared, this is used by wrappers to disable PTI for a single exec call.
Thanks to this, PTI-aware programs can adjust TIF_DISABLE_PTI_NOW for themselves, and a simple wrapper can be implemented by setting TIF_DISABLE_PTI_NEXT to manage those unable to set TIF_DISABLE_PTI_NOW themselves.
Signed-off-by: Willy Tarreau <w@1wt.eu> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Kees Cook <keescook@chromium.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk> --- fs/exec.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/fs/exec.c b/fs/exec.c index 7eb8d21..cf42ddc 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1814,6 +1814,16 @@ static int do_execveat_common(int fd, struct filename *filename, putname(filename); if (displaced) put_files_struct(displaced); + +#ifdef CONFIG_PER_PROCESS_PTI + /* + * TIF_DISABLE_PTI_NOW doesn't pass execve(). TIF_DISABLE_PTI_NEXT + * turns into TIF_DISABLE_PTI_NOW and disappears. + */ + clear_thread_flag(TIF_DISABLE_PTI_NOW); + if (test_and_clear_thread_flag(TIF_DISABLE_PTI_NEXT)) + set_thread_flag(TIF_DISABLE_PTI_NOW); +#endif return retval; out: -- 1.7.12.1
| |