[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <b90027df45623dea4b3461853332eb7758b5b065.1542418937.git.tim.c.chen@linux.intel.com>
Date: Fri, 16 Nov 2018 17:53:57 -0800
From: Tim Chen <tim.c.chen@...ux.intel.com>
To: Jiri Kosina <jikos@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>
Cc: Tim Chen <tim.c.chen@...ux.intel.com>,
Tom Lendacky <thomas.lendacky@....com>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Andrea Arcangeli <aarcange@...hat.com>,
David Woodhouse <dwmw@...zon.co.uk>,
Andi Kleen <ak@...ux.intel.com>,
Dave Hansen <dave.hansen@...el.com>,
Casey Schaufler <casey.schaufler@...el.com>,
Asit Mallick <asit.k.mallick@...el.com>,
Arjan van de Ven <arjan@...ux.intel.com>,
Jon Masters <jcm@...hat.com>,
Waiman Long <longman9394@...il.com>,
linux-kernel@...r.kernel.org, x86@...nel.org
Subject: [Patch v5 14/16] x86/speculation: Use STIBP to restrict speculation on non-dumpable task
When a task changes its dumpability, arch_update_spec_ctrl_restriction()
is called to place restriction on the task's speculative execution
according to dumpability changes.
Implements arch_update_spec_restriction() for x86. Use STIBP to
restrict speculative execution when running a task set to non-dumpable,
or clear the restriction if the task is set to dumpable.
Signed-off-by: Tim Chen <tim.c.chen@...ux.intel.com>
---
Documentation/admin-guide/kernel-parameters.txt | 3 ++-
arch/x86/kernel/cpu/bugs.c | 21 +++++++++++++++++++--
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 9c306e3..102f9a1 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4221,7 +4221,8 @@
vulnerability.
off - Unconditionally disable mitigations
- lite - Protect tasks which have requested restricted
+ lite - Protect tasks which are marked non-dumpable
+ and tasks which have requested restricted
indirect branch speculation via the
PR_SET_SPECULATION_CTRL prctl().
strict - Protect all processes
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 8f5187e..e7f9334 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/nospec.h>
#include <linux/prctl.h>
+#include <linux/coredump.h>
#include <asm/spec-ctrl.h>
#include <asm/cmdline.h>
@@ -152,7 +153,7 @@ static const char *spectre_v2_strings[] = {
static const char *spectre_v2_app2app_strings[] = {
[SPECTRE_V2_APP2APP_NONE] = "App-App Vulnerable",
- [SPECTRE_V2_APP2APP_LITE] = "App-App Mitigation: Protect branch speculation restricted tasks",
+ [SPECTRE_V2_APP2APP_LITE] = "App-App Mitigation: Protect non-dumpable and branch speculation restricted tasks",
[SPECTRE_V2_APP2APP_STRICT] = "App-App Mitigation: Full app to app attack protection",
};
@@ -779,13 +780,29 @@ static void set_task_stibp(struct task_struct *tsk, bool stibp_on)
if (stibp_on)
update = !test_and_set_tsk_thread_flag(tsk, TIF_STIBP);
- else
+ else if (!task_spec_indir_branch_disable(tsk))
update = test_and_clear_tsk_thread_flag(tsk, TIF_STIBP);
if (tsk == current && update)
speculation_ctrl_update_current();
}
+int arch_update_spec_restriction(struct task_struct *task)
+{
+ if (!static_branch_unlikely(&spectre_v2_app_lite))
+ return 0;
+
+ if (!task->mm)
+ return -EINVAL;
+
+ if (get_dumpable(task->mm) != SUID_DUMP_USER)
+ set_task_stibp(task, true);
+ else
+ set_task_stibp(task, false);
+
+ return 0;
+}
+
static int indir_branch_prctl_set(struct task_struct *task, unsigned long ctrl)
{
switch (ctrl) {
--
2.9.4
Powered by blists - more mailing lists