diff options
Diffstat (limited to 'arch/mips/kernel/ptrace.c')
| -rw-r--r-- | arch/mips/kernel/ptrace.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index 92f2c39afe27..92e70ca3bff9 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/smp_lock.h> | 26 | #include <linux/smp_lock.h> |
| 27 | #include <linux/user.h> | 27 | #include <linux/user.h> |
| 28 | #include <linux/security.h> | 28 | #include <linux/security.h> |
| 29 | #include <linux/signal.h> | ||
| 29 | 30 | ||
| 30 | #include <asm/cpu.h> | 31 | #include <asm/cpu.h> |
| 31 | #include <asm/fpu.h> | 32 | #include <asm/fpu.h> |
| @@ -257,7 +258,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) | |||
| 257 | case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ | 258 | case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ |
| 258 | case PTRACE_CONT: { /* restart after signal. */ | 259 | case PTRACE_CONT: { /* restart after signal. */ |
| 259 | ret = -EIO; | 260 | ret = -EIO; |
| 260 | if ((unsigned long) data > _NSIG) | 261 | if (!valid_signal(data)) |
| 261 | break; | 262 | break; |
| 262 | if (request == PTRACE_SYSCALL) { | 263 | if (request == PTRACE_SYSCALL) { |
| 263 | set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); | 264 | set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); |
| @@ -300,25 +301,38 @@ out: | |||
| 300 | return ret; | 301 | return ret; |
| 301 | } | 302 | } |
| 302 | 303 | ||
| 304 | static inline int audit_arch(void) | ||
| 305 | { | ||
| 306 | #ifdef CONFIG_CPU_LITTLE_ENDIAN | ||
| 307 | #ifdef CONFIG_MIPS64 | ||
| 308 | if (!(current->thread.mflags & MF_32BIT_REGS)) | ||
| 309 | return AUDIT_ARCH_MIPSEL64; | ||
| 310 | #endif /* MIPS64 */ | ||
| 311 | return AUDIT_ARCH_MIPSEL; | ||
| 312 | |||
| 313 | #else /* big endian... */ | ||
| 314 | #ifdef CONFIG_MIPS64 | ||
| 315 | if (!(current->thread.mflags & MF_32BIT_REGS)) | ||
| 316 | return AUDIT_ARCH_MIPS64; | ||
| 317 | #endif /* MIPS64 */ | ||
| 318 | return AUDIT_ARCH_MIPS; | ||
| 319 | |||
| 320 | #endif /* endian */ | ||
| 321 | } | ||
| 322 | |||
| 303 | /* | 323 | /* |
| 304 | * Notification of system call entry/exit | 324 | * Notification of system call entry/exit |
| 305 | * - triggered by current->work.syscall_trace | 325 | * - triggered by current->work.syscall_trace |
| 306 | */ | 326 | */ |
| 307 | asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit) | 327 | asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit) |
| 308 | { | 328 | { |
| 309 | if (unlikely(current->audit_context)) { | 329 | if (unlikely(current->audit_context) && entryexit) |
| 310 | if (!entryexit) | 330 | audit_syscall_exit(current, AUDITSC_RESULT(regs->regs[2]), regs->regs[2]); |
| 311 | audit_syscall_entry(current, regs->regs[2], | ||
| 312 | regs->regs[4], regs->regs[5], | ||
| 313 | regs->regs[6], regs->regs[7]); | ||
| 314 | else | ||
| 315 | audit_syscall_exit(current, regs->regs[2]); | ||
| 316 | } | ||
| 317 | 331 | ||
| 318 | if (!test_thread_flag(TIF_SYSCALL_TRACE)) | 332 | if (!test_thread_flag(TIF_SYSCALL_TRACE)) |
| 319 | return; | 333 | goto out; |
| 320 | if (!(current->ptrace & PT_PTRACED)) | 334 | if (!(current->ptrace & PT_PTRACED)) |
| 321 | return; | 335 | goto out; |
| 322 | 336 | ||
| 323 | /* The 0x80 provides a way for the tracing parent to distinguish | 337 | /* The 0x80 provides a way for the tracing parent to distinguish |
| 324 | between a syscall stop and SIGTRAP delivery */ | 338 | between a syscall stop and SIGTRAP delivery */ |
| @@ -334,4 +348,9 @@ asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit) | |||
| 334 | send_sig(current->exit_code, current, 1); | 348 | send_sig(current->exit_code, current, 1); |
| 335 | current->exit_code = 0; | 349 | current->exit_code = 0; |
| 336 | } | 350 | } |
| 351 | out: | ||
| 352 | if (unlikely(current->audit_context) && !entryexit) | ||
| 353 | audit_syscall_entry(current, audit_arch(), regs->regs[2], | ||
| 354 | regs->regs[4], regs->regs[5], | ||
| 355 | regs->regs[6], regs->regs[7]); | ||
| 337 | } | 356 | } |
