From: Ingo Molnar <mingo@kernel.org>
To: Willy Tarreau <w@1wt.eu>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de,
gnomes@lxorguk.ukuu.org.uk, torvalds@linux-foundation.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Borislav Petkov <bp@alien8.de>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Andy Lutomirski <luto@kernel.org>,
Dave Hansen <dave.hansen@linux.intel.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 18:05:31 +0100 [thread overview]
Message-ID: <20180108170531.um2sb5wm6u4dc3rb@gmail.com> (raw)
In-Reply-To: <1515427939-10999-3-git-send-email-w@1wt.eu>
(Expanded the Cc: list.)
* 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.
>
> Signed-off-by: Willy Tarreau <w@1wt.eu>
> ---
> arch/x86/include/uapi/asm/prctl.h | 3 +++
> arch/x86/kernel/process_64.c | 24 ++++++++++++++++++++++++
> 2 files changed, 27 insertions(+)
>
> diff --git a/arch/x86/include/uapi/asm/prctl.h b/arch/x86/include/uapi/asm/prctl.h
> index 5a6aac9..1f1b5bc 100644
> --- a/arch/x86/include/uapi/asm/prctl.h
> +++ b/arch/x86/include/uapi/asm/prctl.h
> @@ -10,6 +10,9 @@
> #define ARCH_GET_CPUID 0x1011
> #define ARCH_SET_CPUID 0x1012
>
> +#define ARCH_GET_NOPTI 0x1021
> +#define ARCH_SET_NOPTI 0x1022
> +
> #define ARCH_MAP_VDSO_X32 0x2001
> #define ARCH_MAP_VDSO_32 0x2002
> #define ARCH_MAP_VDSO_64 0x2003
> diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
> index c754662..1686d3d 100644
> --- a/arch/x86/kernel/process_64.c
> +++ b/arch/x86/kernel/process_64.c
> @@ -654,6 +654,30 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
> ret = put_user(base, (unsigned long __user *)arg2);
> break;
> }
> + case ARCH_GET_NOPTI: {
> + unsigned long flag;
> +
> + printk(KERN_DEBUG "get1: task=%p ti=%p fl=%16lx\n", task, task_thread_info(task), task_thread_info(task)->flags);
> + flag = !!(task_thread_info(task)->flags & _TIF_NOPTI);
> + ret = put_user(flag, (unsigned long __user *)arg2);
> + break;
> + }
> +
> + case ARCH_SET_NOPTI:
> + if (!capable(CAP_SYS_RAWIO))
> + return -EPERM;
> +
> + printk(KERN_DEBUG "set1: task=%p ti=%p fl=%16lx doit=%d arg2=%ld\n", task, task_thread_info(task), task_thread_info(task)->flags, doit, arg2);
> +
> + if (doit) {
> + if (arg2)
> + task_thread_info(task)->flags |= _TIF_NOPTI;
> + else
> + task_thread_info(task)->flags &= ~_TIF_NOPTI;
> +
> + printk(KERN_DEBUG "set2: task=%p ti=%p fl=%16lx\n", task, task_thread_info(task), task_thread_info(task)->flags);
> + }
> + break;
Btw., we could enforce the CAP_SYS_RAWIO permission check only if it's _clearing_
the PTI flag.
I.e. this would allow apps and runtime environments to opt into PTI, without
having to rely on external security frameworks getting it right.
Note that there is somewhat of a fuzzy detail regarding AMD CPUs which are marked
as 'Meltdown safe': should an explicit request to turn on PTI be honored by the
kernel? Should that be some sort of separate 'force PTI on' attribute?
Thanks,
Ingo
next prev parent reply other threads:[~2018-01-08 17:05 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 [this message]
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
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=20180108170531.um2sb5wm6u4dc3rb@gmail.com \
--to=mingo@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=gnomes@lxorguk.ukuu.org.uk \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.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
Powered by JetHome