Skip to content

Commit 1322b9d

Browse files
Yuichi Nakamurapmundt
authored andcommitted
sh: syscall audit support.
Support syscall auditing.. Signed-off-by: Yuichi Nakamura <ynakam@hitachisoft.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent 12760cb commit 1322b9d

4 files changed

Lines changed: 26 additions & 7 deletions

File tree

‎arch/sh/kernel/entry-common.S‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ work_resched:
224224
syscall_exit_work:
225225
! r0: current_thread_info->flags
226226
! r8: current_thread_info
227-
tst #_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP, r0
227+
tst #_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | _TIF_SYSCALL_AUDIT, r0
228228
bt/s work_pending
229229
tst #_TIF_NEED_RESCHED, r0
230230
#ifdef CONFIG_TRACE_IRQFLAGS
@@ -234,6 +234,8 @@ syscall_exit_work:
234234
#endif
235235
sti
236236
! XXX setup arguments...
237+
mov r15, r4
238+
mov #1, r5
237239
mov.l 4f, r0 ! do_syscall_trace
238240
jsr @r0
239241
nop
@@ -244,6 +246,8 @@ syscall_exit_work:
244246
syscall_trace_entry:
245247
! Yes it is traced.
246248
! XXX setup arguments...
249+
mov r15, r4
250+
mov #0, r5
247251
mov.l 4f, r11 ! Call do_syscall_trace which notifies
248252
jsr @r11 ! superior (will chomp R[0-7])
249253
nop
@@ -366,7 +370,7 @@ ENTRY(system_call)
366370
!
367371
get_current_thread_info r8, r10
368372
mov.l @(TI_FLAGS,r8), r8
369-
mov #_TIF_SYSCALL_TRACE, r10
373+
mov #(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT), r10
370374
tst r10, r8
371375
bf syscall_trace_entry
372376
!

‎arch/sh/kernel/ptrace_32.c‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
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>
@@ -19,6 +19,7 @@
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
}

‎include/asm-sh/thread_info.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static inline struct thread_info *current_thread_info(void)
113113
#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
114114
#define TIF_RESTORE_SIGMASK 3 /* restore signal mask in do_signal() */
115115
#define TIF_SINGLESTEP 4 /* singlestepping active */
116+
#define TIF_SYSCALL_AUDIT 5
116117
#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
117118
#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
118119
#define TIF_MEMDIE 18
@@ -123,6 +124,7 @@ static inline struct thread_info *current_thread_info(void)
123124
#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
124125
#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
125126
#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
127+
#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
126128
#define _TIF_USEDFPU (1<<TIF_USEDFPU)
127129
#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
128130
#define _TIF_FREEZE (1<<TIF_FREEZE)

‎init/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ config AUDIT
238238

239239
config AUDITSYSCALL
240240
bool "Enable system-call auditing support"
241-
depends on AUDIT && (X86 || PPC || PPC64 || S390 || IA64 || UML || SPARC64)
241+
depends on AUDIT && (X86 || PPC || PPC64 || S390 || IA64 || UML || SPARC64|| SUPERH)
242242
default y if SECURITY_SELINUX
243243
help
244244
Enable low-overhead system-call auditing infrastructure that

0 commit comments

Comments
 (0)