summaryrefslogtreecommitdiffstats
path: root/kernel/seccomp.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2018-05-04 09:12:06 -0400
committerThomas Gleixner <tglx@linutronix.de>2018-05-04 18:51:44 -0400
commit8bf37d8c067bb7eb8e7c381bdadf9bd89182b6bc (patch)
treeac991511615d563b0141782cba95fc2482a68afc /kernel/seccomp.c
parent00a02d0c502a06d15e07b857f8ff921e3e402675 (diff)
seccomp: Move speculation migitation control to arch code
The migitation control is simpler to implement in architecture code as it avoids the extra function call to check the mode. Aside of that having an explicit seccomp enabled mode in the architecture mitigations would require even more workarounds. Move it into architecture code and provide a weak function in the seccomp code. Remove the 'which' argument as this allows the architecture to decide which mitigations are relevant for seccomp. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/seccomp.c')
-rw-r--r--kernel/seccomp.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 53eb946120c1..e691d9a6c58d 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -229,18 +229,7 @@ static inline bool seccomp_may_assign_mode(unsigned long seccomp_mode)
229 return true; 229 return true;
230} 230}
231 231
232/* 232void __weak arch_seccomp_spec_mitigate(struct task_struct *task) { }
233 * If a given speculation mitigation is opt-in (prctl()-controlled),
234 * select it, by disabling speculation (enabling mitigation).
235 */
236static inline void spec_mitigate(struct task_struct *task,
237 unsigned long which)
238{
239 int state = arch_prctl_spec_ctrl_get(task, which);
240
241 if (state > 0 && (state & PR_SPEC_PRCTL))
242 arch_prctl_spec_ctrl_set(task, which, PR_SPEC_FORCE_DISABLE);
243}
244 233
245static inline void seccomp_assign_mode(struct task_struct *task, 234static inline void seccomp_assign_mode(struct task_struct *task,
246 unsigned long seccomp_mode, 235 unsigned long seccomp_mode,
@@ -256,7 +245,7 @@ static inline void seccomp_assign_mode(struct task_struct *task,
256 smp_mb__before_atomic(); 245 smp_mb__before_atomic();
257 /* Assume default seccomp processes want spec flaw mitigation. */ 246 /* Assume default seccomp processes want spec flaw mitigation. */
258 if ((flags & SECCOMP_FILTER_FLAG_SPEC_ALLOW) == 0) 247 if ((flags & SECCOMP_FILTER_FLAG_SPEC_ALLOW) == 0)
259 spec_mitigate(task, PR_SPEC_STORE_BYPASS); 248 arch_seccomp_spec_mitigate(task);
260 set_tsk_thread_flag(task, TIF_SECCOMP); 249 set_tsk_thread_flag(task, TIF_SECCOMP);
261} 250}
262 251