aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
author <dwmw2@shinybook.infradead.org>2005-04-29 11:08:28 -0400
committer <dwmw2@shinybook.infradead.org>2005-04-29 11:08:28 -0400
commit2fd6f58ba6efc82ea2c9c2630f7ff5ed9eeaf34a (patch)
tree87cf236a78ad242ae01f1b71c289131e6d1c0662 /arch/mips
parentea3834d9fb348fb1144ad3affea22df933eaf62e (diff)
[AUDIT] Don't allow ptrace to fool auditing, log arch of audited syscalls.
We were calling ptrace_notify() after auditing the syscall and arguments, but the debugger could have _changed_ them before the syscall was actually invoked. Reorder the calls to fix that. While we're touching ever call to audit_syscall_entry(), we also make it take an extra argument: the architecture of the syscall which was made, because some architectures allow more than one type of syscall. Also add an explicit success/failure flag to audit_syscall_exit(), for the benefit of architectures which return that in a condition register rather than only returning a single register. Change type of syscall return value to 'long' not 'int'. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/kernel/ptrace.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 92f2c39afe27..eaf7be9d0b0a 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -300,25 +300,38 @@ out:
300 return ret; 300 return ret;
301} 301}
302 302
303static inline int audit_arch()
304{
305#ifdef CONFIG_CPU_LITTLE_ENDIAN
306#ifdef CONFIG_MIPS64
307 if (!(current->thread.mflags & MF_32BIT_REGS))
308 return AUDIT_ARCH_MIPSEL64;
309#endif /* MIPS64 */
310 return AUDIT_ARCH_MIPSEL;
311
312#else /* big endian... */
313#ifdef CONFIG_MIPS64
314 if (!(current->thread.mflags & MF_32BIT_REGS))
315 return AUDIT_ARCH_MIPS64;
316#endif /* MIPS64 */
317 return AUDIT_ARCH_MIPS;
318
319#endif /* endian */
320}
321
303/* 322/*
304 * Notification of system call entry/exit 323 * Notification of system call entry/exit
305 * - triggered by current->work.syscall_trace 324 * - triggered by current->work.syscall_trace
306 */ 325 */
307asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit) 326asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
308{ 327{
309 if (unlikely(current->audit_context)) { 328 if (unlikely(current->audit_context) && entryexit)
310 if (!entryexit) 329 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 330
318 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 331 if (!test_thread_flag(TIF_SYSCALL_TRACE))
319 return; 332 goto out;
320 if (!(current->ptrace & PT_PTRACED)) 333 if (!(current->ptrace & PT_PTRACED))
321 return; 334 goto out;
322 335
323 /* The 0x80 provides a way for the tracing parent to distinguish 336 /* The 0x80 provides a way for the tracing parent to distinguish
324 between a syscall stop and SIGTRAP delivery */ 337 between a syscall stop and SIGTRAP delivery */
@@ -334,4 +347,9 @@ asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
334 send_sig(current->exit_code, current, 1); 347 send_sig(current->exit_code, current, 1);
335 current->exit_code = 0; 348 current->exit_code = 0;
336 } 349 }
350 out:
351 if (unlikely(current->audit_context) && !entryexit)
352 audit_syscall_entry(current, audit_arch(), regs->regs[2],
353 regs->regs[4], regs->regs[5],
354 regs->regs[6], regs->regs[7]);
337} 355}