66 * edited by Linus Torvalds
77 *
88 * SuperH version: Copyright (C) 1999, 2000 Kaz Kojima & Niibe Yutaka
9- *
9+ * Audit support: Yuichi Nakamura <ynakam@hitachisoft.jp>
1010 */
1111#include <linux/kernel.h>
1212#include <linux/sched.h>
1919#include <linux/security.h>
2020#include <linux/signal.h>
2121#include <linux/io.h>
22+ #include <linux/audit.h>
2223#include <asm/uaccess.h>
2324#include <asm/pgtable.h>
2425#include <asm/system.h>
@@ -248,15 +249,20 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
248249 return ret ;
249250}
250251
251- asmlinkage void do_syscall_trace (void )
252+ asmlinkage void do_syscall_trace (struct pt_regs * regs , int entryexit )
252253{
253254 struct task_struct * tsk = current ;
254255
256+ if (unlikely (current -> audit_context ) && entryexit )
257+ audit_syscall_exit (AUDITSC_RESULT (regs -> regs [0 ]),
258+ regs -> regs [0 ]);
259+
255260 if (!test_thread_flag (TIF_SYSCALL_TRACE ) &&
256261 !test_thread_flag (TIF_SINGLESTEP ))
257- return ;
262+ goto out ;
258263 if (!(tsk -> ptrace & PT_PTRACED ))
259- return ;
264+ goto out ;
265+
260266 /* the 0x80 provides a way for the tracing parent to distinguish
261267 between a syscall stop and SIGTRAP delivery */
262268 ptrace_notify (SIGTRAP | ((current -> ptrace & PT_TRACESYSGOOD ) &&
@@ -271,4 +277,11 @@ asmlinkage void do_syscall_trace(void)
271277 send_sig (tsk -> exit_code , tsk , 1 );
272278 tsk -> exit_code = 0 ;
273279 }
280+
281+ out :
282+ if (unlikely (current -> audit_context ) && !entryexit )
283+ audit_syscall_entry (AUDIT_ARCH_SH , regs -> regs [3 ],
284+ regs -> regs [4 ], regs -> regs [5 ],
285+ regs -> regs [6 ], regs -> regs [7 ]);
286+
274287}
0 commit comments