Skip to content

Commit 42309ab

Browse files
wildea01Russell King
authored andcommitted
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: Kees Cook <keescook@chromium.org> Tested-by: Kees Cook <keescook@chromium.org> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 6980c3e commit 42309ab

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎arch/arm/kernel/ptrace.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ enum ptrace_syscall_dir {
908908
PTRACE_SYSCALL_EXIT,
909909
};
910910

911-
static int tracehook_report_syscall(struct pt_regs *regs,
911+
static void tracehook_report_syscall(struct pt_regs *regs,
912912
enum ptrace_syscall_dir dir)
913913
{
914914
unsigned long ip;
@@ -926,7 +926,6 @@ static int tracehook_report_syscall(struct pt_regs *regs,
926926
current_thread_info()->syscall = -1;
927927

928928
regs->ARM_ip = ip;
929-
return current_thread_info()->syscall;
930929
}
931930

932931
asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
@@ -938,7 +937,9 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
938937
return -1;
939938

940939
if (test_thread_flag(TIF_SYSCALL_TRACE))
941-
scno = tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
940+
tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
941+
942+
scno = current_thread_info()->syscall;
942943

943944
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
944945
trace_sys_enter(regs, scno);

0 commit comments

Comments
 (0)