diff options
author | Kees Cook <keescook@chromium.org> | 2016-06-02 12:16:31 -0700 |
---|---|---|
committer | Greg Hackmann <ghackmann@google.com> | 2018-11-27 21:12:05 +0000 |
commit | d5ea505d8bc7339ec14bc3837dcfbdfaf3d68478 (patch) | |
tree | 8b5e44d6400b41350ba918255a30fd2040890b7c /arch | |
parent | 7f891268d5b80d4b9ee38be1a37cce5959bec00f (diff) |
UPSTREAM: arm/ptrace: run seccomp after ptrace
Close the hole where ptrace can change a syscall out from under seccomp.
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
(cherry picked from commit 0f3912fd934cdfd03d93f2dc6f064099795bf638)
Bug: 119769499
Change-Id: Id82e4137207db42a8af31b2745581c53eaaf1f89
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/kernel/ptrace.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index e6a538be2d88..ae738a6319f6 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)) |