From: Kees Cook Date: Thu, 2 Jun 2016 19:16:31 +0000 (-0700) Subject: arm/ptrace: run seccomp after ptrace X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0f3912fd934cdfd03d93f2dc6f064099795bf638;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git arm/ptrace: run seccomp after ptrace Close the hole where ptrace can change a syscall out from under seccomp. Signed-off-by: Kees Cook Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org --- diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index 1027d3b54541..ce131ed5939d 100644 --- a/arch/arm/kernel/ptrace.c +++ b/arch/arm/kernel/ptrace.c @@ -932,18 +932,19 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno) { current_thread_info()->syscall = scno; - /* Do the secure computing check first; failures should be fast. */ + if (test_thread_flag(TIF_SYSCALL_TRACE)) + tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); + + /* Do seccomp after ptrace; syscall may have changed. */ #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER if (secure_computing(NULL) == -1) return -1; #else /* XXX: remove this once OABI gets fixed */ - secure_computing_strict(scno); + secure_computing_strict(current_thread_info()->syscall); #endif - if (test_thread_flag(TIF_SYSCALL_TRACE)) - tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); - + /* Tracer or seccomp may have changed syscall. */ scno = current_thread_info()->syscall; if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))