Commit 9e7870a1 authored by Kees Cook's avatar Kees Cook Committed by Juerg Haefliger

UBUNTU: SAUCE: seccomp: Enable speculation flaw mitigations

CVE-2018-3639 (x86)

When speculation flaw mitigations are opt-in (via prctl), using seccomp
will automatically opt-in to these protections, since using seccomp
indicates at least some level of sandboxing is desired.
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarTyler Hicks <tyhicks@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
parent c2f3edf4
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include <linux/audit.h> #include <linux/audit.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/kmemleak.h> #include <linux/kmemleak.h>
#include <linux/nospec.h>
#include <linux/prctl.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/seccomp.h> #include <linux/seccomp.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -224,6 +226,19 @@ static inline bool seccomp_may_assign_mode(unsigned long seccomp_mode) ...@@ -224,6 +226,19 @@ static inline bool seccomp_may_assign_mode(unsigned long seccomp_mode)
return true; return true;
} }
/*
* If a given speculation mitigation is opt-in (prctl()-controlled),
* select it, by disabling speculation (enabling mitigation).
*/
static inline void spec_mitigate(struct task_struct *task,
unsigned long which)
{
int state = arch_prctl_spec_ctrl_get(task, which);
if (state > 0 && (state & PR_SPEC_PRCTL))
arch_prctl_spec_ctrl_set(task, which, PR_SPEC_DISABLE);
}
static inline void seccomp_assign_mode(struct task_struct *task, static inline void seccomp_assign_mode(struct task_struct *task,
unsigned long seccomp_mode) unsigned long seccomp_mode)
{ {
...@@ -235,6 +250,8 @@ static inline void seccomp_assign_mode(struct task_struct *task, ...@@ -235,6 +250,8 @@ static inline void seccomp_assign_mode(struct task_struct *task,
* filter) is set. * filter) is set.
*/ */
smp_mb__before_atomic(); smp_mb__before_atomic();
/* Assume seccomp processes want speculation flaw mitigation. */
spec_mitigate(task, PR_SPEC_STORE_BYPASS);
set_tsk_thread_flag(task, TIF_SECCOMP); set_tsk_thread_flag(task, TIF_SECCOMP);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment