aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2007-11-28 05:58:11 -0500
committerPaul Mundt <lethal@linux-sh.org>2008-01-27 23:18:58 -0500
commit4b27c47cf8eddb4153a026e89c7b092598c98b12 (patch)
tree5142d1c0bbfe289ee757dfc147bb6394244c4d67
parentc019fd8839503a91c556ae68d773e3bbb9b476e1 (diff)
sh: syscall auditing for sh5, too.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--arch/sh/kernel/cpu/sh5/entry.S10
-rw-r--r--arch/sh/kernel/ptrace_64.c38
2 files changed, 30 insertions, 18 deletions
diff --git a/arch/sh/kernel/cpu/sh5/entry.S b/arch/sh/kernel/cpu/sh5/entry.S
index 0f65bb4372da..dbf2d7684502 100644
--- a/arch/sh/kernel/cpu/sh5/entry.S
+++ b/arch/sh/kernel/cpu/sh5/entry.S
@@ -942,9 +942,6 @@ ret_with_reschedule:
942 getcon KCR0, r6 ! r6 contains current_thread_info 942 getcon KCR0, r6 ! r6 contains current_thread_info
943 ld.l r6, TI_FLAGS, r7 ! r7 contains current_thread_info->flags 943 ld.l r6, TI_FLAGS, r7 ! r7 contains current_thread_info->flags
944 944
945 ! FIXME:!!!
946 ! no handling of TIF_SYSCALL_TRACE yet!!
947
948 movi _TIF_NEED_RESCHED, r8 945 movi _TIF_NEED_RESCHED, r8
949 and r8, r7, r8 946 and r8, r7, r8
950 pta work_resched, tr0 947 pta work_resched, tr0
@@ -1280,14 +1277,17 @@ syscall_allowed:
1280 1277
1281 getcon KCR0, r2 1278 getcon KCR0, r2
1282 ld.l r2, TI_FLAGS, r4 1279 ld.l r2, TI_FLAGS, r4
1283 movi (1 << TIF_SYSCALL_TRACE), r6 1280 movi (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | _TIF_SYSCALL_AUDIT), r6
1284 and r6, r4, r6 1281 and r6, r4, r6
1285 beq/l r6, ZERO, tr0 1282 beq/l r6, ZERO, tr0
1286 1283
1287 /* Trace it by calling syscall_trace before and after */ 1284 /* Trace it by calling syscall_trace before and after */
1288 movi syscall_trace, r4 1285 movi syscall_trace, r4
1286 or SP, ZERO, r2
1287 or ZERO, ZERO, r3
1289 ptabs r4, tr0 1288 ptabs r4, tr0
1290 blink tr0, LINK 1289 blink tr0, LINK
1290
1291 /* Reload syscall number as r5 is trashed by syscall_trace */ 1291 /* Reload syscall number as r5 is trashed by syscall_trace */
1292 ld.q SP, FRAME_S(FSYSCALL_ID), r5 1292 ld.q SP, FRAME_S(FSYSCALL_ID), r5
1293 andi r5, 0x1ff, r5 1293 andi r5, 0x1ff, r5
@@ -1321,6 +1321,8 @@ syscall_ret_trace:
1321 st.q SP, FRAME_R(9), r2 /* Save return value */ 1321 st.q SP, FRAME_R(9), r2 /* Save return value */
1322 1322
1323 movi syscall_trace, LINK 1323 movi syscall_trace, LINK
1324 or SP, ZERO, r2
1325 movi 1, r3
1324 ptabs LINK, tr0 1326 ptabs LINK, tr0
1325 blink tr0, LINK 1327 blink tr0, LINK
1326 1328
diff --git a/arch/sh/kernel/ptrace_64.c b/arch/sh/kernel/ptrace_64.c
index e9cc6ebd2cea..f6fbdfa6876d 100644
--- a/arch/sh/kernel/ptrace_64.c
+++ b/arch/sh/kernel/ptrace_64.c
@@ -1,12 +1,8 @@
1/* 1/*
2 * This file is subject to the terms and conditions of the GNU General Public 2 * arch/sh/kernel/ptrace_64.c
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/ptrace.c
7 * 3 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli 4 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003 Paul Mundt 5 * Copyright (C) 2003 - 2007 Paul Mundt
10 * 6 *
11 * Started from SH3/4 version: 7 * Started from SH3/4 version:
12 * SuperH version: Copyright (C) 1999, 2000 Kaz Kojima & Niibe Yutaka 8 * SuperH version: Copyright (C) 1999, 2000 Kaz Kojima & Niibe Yutaka
@@ -15,8 +11,10 @@
15 * By Ross Biro 1/23/92 11 * By Ross Biro 1/23/92
16 * edited by Linus Torvalds 12 * edited by Linus Torvalds
17 * 13 *
14 * This file is subject to the terms and conditions of the GNU General Public
15 * License. See the file "COPYING" in the main directory of this archive
16 * for more details.
18 */ 17 */
19
20#include <linux/kernel.h> 18#include <linux/kernel.h>
21#include <linux/rwsem.h> 19#include <linux/rwsem.h>
22#include <linux/sched.h> 20#include <linux/sched.h>
@@ -28,7 +26,7 @@
28#include <linux/user.h> 26#include <linux/user.h>
29#include <linux/signal.h> 27#include <linux/signal.h>
30#include <linux/syscalls.h> 28#include <linux/syscalls.h>
31 29#include <linux/audit.h>
32#include <asm/io.h> 30#include <asm/io.h>
33#include <asm/uaccess.h> 31#include <asm/uaccess.h>
34#include <asm/pgtable.h> 32#include <asm/pgtable.h>
@@ -274,17 +272,23 @@ asmlinkage int sh64_ptrace(long request, long pid, long addr, long data)
274 return sys_ptrace(request, pid, addr, data); 272 return sys_ptrace(request, pid, addr, data);
275} 273}
276 274
277asmlinkage void syscall_trace(void) 275asmlinkage void syscall_trace(struct pt_regs *regs, int entryexit)
278{ 276{
279 struct task_struct *tsk = current; 277 struct task_struct *tsk = current;
280 278
281 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 279 if (unlikely(current->audit_context) && entryexit)
282 return; 280 audit_syscall_exit(AUDITSC_RESULT(regs->regs[9]),
281 regs->regs[9]);
282
283 if (!test_thread_flag(TIF_SYSCALL_TRACE) &&
284 !test_thread_flag(TIF_SINGLESTEP))
285 goto out;
283 if (!(tsk->ptrace & PT_PTRACED)) 286 if (!(tsk->ptrace & PT_PTRACED))
284 return; 287 goto out;
288
289 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) &&
290 !test_thread_flag(TIF_SINGLESTEP) ? 0x80 : 0));
285 291
286 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
287 ? 0x80 : 0));
288 /* 292 /*
289 * this isn't the same as continuing with a signal, but it will do 293 * this isn't the same as continuing with a signal, but it will do
290 * for normal use. strace only continues with a signal if the 294 * for normal use. strace only continues with a signal if the
@@ -294,6 +298,12 @@ asmlinkage void syscall_trace(void)
294 send_sig(tsk->exit_code, tsk, 1); 298 send_sig(tsk->exit_code, tsk, 1);
295 tsk->exit_code = 0; 299 tsk->exit_code = 0;
296 } 300 }
301
302out:
303 if (unlikely(current->audit_context) && !entryexit)
304 audit_syscall_entry(AUDIT_ARCH_SH, regs->regs[1],
305 regs->regs[2], regs->regs[3],
306 regs->regs[4], regs->regs[5]);
297} 307}
298 308
299/* Called with interrupts disabled */ 309/* Called with interrupts disabled */