aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2012-11-15 16:12:00 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-11-19 09:14:17 -0500
commit9b790d71d58be65f9508ab60920eb978af828412 (patch)
tree42114518c27f840aca3ef395636ca1f2fcf09a0e
parent1f59d13bee172945ccdfbc5018477ba94a0ac28e (diff)
ARM: 7578/1: arch/move secure_computing into trace
There is very little difference in the TIF_SECCOMP and TIF_SYSCALL_WORK path in entry-common.S, so merge TIF_SECCOMP into TIF_SYSCALL_WORK and move seccomp into the syscall_trace_enter() handler. Expanded some of the tracehook logic into the callers to make this code more readable. Since tracehook needs to do register changing, this portion is best left in its own function instead of copy/pasting into the callers. Additionally, the return value for secure_computing() is now checked and a -1 value will result in the system call being skipped. Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Will Drewry <wad@chromium.org> Reviewed-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/include/asm/thread_info.h7
-rw-r--r--arch/arm/kernel/entry-common.S10
-rw-r--r--arch/arm/kernel/ptrace.c29
3 files changed, 24 insertions, 22 deletions
diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
index 8477b4c1d39f..cddda1f41f0f 100644
--- a/arch/arm/include/asm/thread_info.h
+++ b/arch/arm/include/asm/thread_info.h
@@ -151,10 +151,10 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
151#define TIF_SYSCALL_TRACE 8 151#define TIF_SYSCALL_TRACE 8
152#define TIF_SYSCALL_AUDIT 9 152#define TIF_SYSCALL_AUDIT 9
153#define TIF_SYSCALL_TRACEPOINT 10 153#define TIF_SYSCALL_TRACEPOINT 10
154#define TIF_SECCOMP 11 /* seccomp syscall filtering active */
154#define TIF_USING_IWMMXT 17 155#define TIF_USING_IWMMXT 17
155#define TIF_MEMDIE 18 /* is terminating due to OOM killer */ 156#define TIF_MEMDIE 18 /* is terminating due to OOM killer */
156#define TIF_RESTORE_SIGMASK 20 157#define TIF_RESTORE_SIGMASK 20
157#define TIF_SECCOMP 21
158#define TIF_SWITCH_MM 22 /* deferred switch_mm */ 158#define TIF_SWITCH_MM 22 /* deferred switch_mm */
159 159
160#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 160#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
@@ -163,11 +163,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
163#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 163#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
164#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 164#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
165#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) 165#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
166#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
167#define _TIF_SECCOMP (1 << TIF_SECCOMP) 166#define _TIF_SECCOMP (1 << TIF_SECCOMP)
167#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
168 168
169/* Checks for any syscall work in entry-common.S */ 169/* Checks for any syscall work in entry-common.S */
170#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT) 170#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
171 _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
171 172
172/* 173/*
173 * Change these and you break ASM code in entry-common.S 174 * Change these and you break ASM code in entry-common.S
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 417bac1846bd..b621871dd277 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -417,16 +417,6 @@ local_restart:
417 ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing 417 ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing
418 stmdb sp!, {r4, r5} @ push fifth and sixth args 418 stmdb sp!, {r4, r5} @ push fifth and sixth args
419 419
420#ifdef CONFIG_SECCOMP
421 tst r10, #_TIF_SECCOMP
422 beq 1f
423 mov r0, scno
424 bl __secure_computing
425 add r0, sp, #S_R0 + S_OFF @ pointer to regs
426 ldmia r0, {r0 - r3} @ have to reload r0 - r3
4271:
428#endif
429
430 tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls? 420 tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls?
431 bne __sys_trace 421 bne __sys_trace
432 422
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index 739db3a1b2d2..518536d93fba 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -916,16 +916,11 @@ enum ptrace_syscall_dir {
916 PTRACE_SYSCALL_EXIT, 916 PTRACE_SYSCALL_EXIT,
917}; 917};
918 918
919static int ptrace_syscall_trace(struct pt_regs *regs, int scno, 919static int tracehook_report_syscall(struct pt_regs *regs,
920 enum ptrace_syscall_dir dir) 920 enum ptrace_syscall_dir dir)
921{ 921{
922 unsigned long ip; 922 unsigned long ip;
923 923
924 current_thread_info()->syscall = scno;
925
926 if (!test_thread_flag(TIF_SYSCALL_TRACE))
927 return scno;
928
929 /* 924 /*
930 * IP is used to denote syscall entry/exit: 925 * IP is used to denote syscall entry/exit:
931 * IP = 0 -> entry, =1 -> exit 926 * IP = 0 -> entry, =1 -> exit
@@ -944,19 +939,35 @@ static int ptrace_syscall_trace(struct pt_regs *regs, int scno,
944 939
945asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno) 940asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
946{ 941{
947 scno = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_ENTER); 942 current_thread_info()->syscall = scno;
943
944 /* Do the secure computing check first; failures should be fast. */
945 if (secure_computing(scno) == -1)
946 return -1;
947
948 if (test_thread_flag(TIF_SYSCALL_TRACE))
949 scno = tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
950
948 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) 951 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
949 trace_sys_enter(regs, scno); 952 trace_sys_enter(regs, scno);
953
950 audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0, regs->ARM_r1, 954 audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0, regs->ARM_r1,
951 regs->ARM_r2, regs->ARM_r3); 955 regs->ARM_r2, regs->ARM_r3);
956
952 return scno; 957 return scno;
953} 958}
954 959
955asmlinkage int syscall_trace_exit(struct pt_regs *regs, int scno) 960asmlinkage int syscall_trace_exit(struct pt_regs *regs, int scno)
956{ 961{
957 scno = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_EXIT); 962 current_thread_info()->syscall = scno;
963
964 if (test_thread_flag(TIF_SYSCALL_TRACE))
965 scno = tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT);
966
958 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) 967 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
959 trace_sys_exit(regs, scno); 968 trace_sys_exit(regs, scno);
969
960 audit_syscall_exit(regs); 970 audit_syscall_exit(regs);
971
961 return scno; 972 return scno;
962} 973}