Skip to content
Snippets Groups Projects
Commit acebc07a authored by Will Deacon's avatar Will Deacon Committed by Christian Bejram
Browse files

ARM: 8087/1: ptrace: reload syscall number after secure_computing() check


On the syscall tracing path, we call out to secure_computing() to allow
seccomp to check the syscall number being attempted. As part of this, a
SIGTRAP may be sent to the tracer and the syscall could be re-written by
a subsequent SET_SYSCALL ptrace request. Unfortunately, this new syscall
is ignored by the current code unless TIF_SYSCALL_TRACE is also set on
the current thread.

This patch slightly reworks the enter path of the syscall tracing code
so that we always reload the syscall number from
current_thread_info()->syscall after the potential ptrace traps.

Acked-by: default avatarKees Cook <keescook@chromium.org>
Tested-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 1930635c
No related branches found
No related tags found
No related merge requests found
...@@ -916,7 +916,7 @@ enum ptrace_syscall_dir { ...@@ -916,7 +916,7 @@ enum ptrace_syscall_dir {
PTRACE_SYSCALL_EXIT, PTRACE_SYSCALL_EXIT,
}; };
static int tracehook_report_syscall(struct pt_regs *regs, static void tracehook_report_syscall(struct pt_regs *regs,
enum ptrace_syscall_dir dir) enum ptrace_syscall_dir dir)
{ {
unsigned long ip; unsigned long ip;
...@@ -934,7 +934,6 @@ static int tracehook_report_syscall(struct pt_regs *regs, ...@@ -934,7 +934,6 @@ static int tracehook_report_syscall(struct pt_regs *regs,
current_thread_info()->syscall = -1; current_thread_info()->syscall = -1;
regs->ARM_ip = ip; regs->ARM_ip = ip;
return current_thread_info()->syscall;
} }
asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno) asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
...@@ -946,7 +945,9 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno) ...@@ -946,7 +945,9 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
return -1; return -1;
if (test_thread_flag(TIF_SYSCALL_TRACE)) if (test_thread_flag(TIF_SYSCALL_TRACE))
scno = tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
scno = current_thread_info()->syscall;
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
trace_sys_enter(regs, scno); trace_sys_enter(regs, scno);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment