[RFC PATCH 2/3] arch/x86: move secure_computing after ptrace

From: Will Drewry
Date: Thu May 24 2012 - 12:08:41 EST


At present, seccomp modes 1 and 2 may have their
behavior changed by a ptrace()ing task. The ptracer
cannot change blocked/disallowed system calls, but it can
change allowed system calls to calls that would otherwise
not be allowed by the seccomp policy.

Signed-off-by: Will Drewry <wad@xxxxxxxxxxxx>
---
arch/x86/kernel/ptrace.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 13b1990..ad649a6 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1479,13 +1479,6 @@ long syscall_trace_enter(struct pt_regs *regs)
if (test_thread_flag(TIF_SINGLESTEP))
regs->flags |= X86_EFLAGS_TF;

- /* do the secure computing check first */
- if (secure_computing(regs->orig_ax)) {
- /* seccomp failures shouldn't expose any additional code. */
- ret = -1L;
- goto out;
- }
-
if (unlikely(test_thread_flag(TIF_SYSCALL_EMU)))
ret = -1L;

@@ -1493,6 +1486,12 @@ long syscall_trace_enter(struct pt_regs *regs)
tracehook_report_syscall_entry(regs))
ret = -1L;

+ /* check secure computing after userspace can't change the syscall. */
+ if (!ret && secure_computing(regs->orig_ax)) {
+ ret = -1L;
+ goto out;
+ }
+
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
trace_sys_enter(regs, regs->orig_ax);

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/