Commit 6751b2da authored by Peter Martuccelli's avatar Peter Martuccelli Committed by David Mosberger

[PATCH] ia64: add audit support

This patch adds IA64 support to the audit infrastructure.  The IA64
audit patch complements the existing audit support for the i386,
PPC64, and x86_64 architectures.  This patch is based on work by Ray
Lanza.
Signed-off-by: default avatarPeter Martuccelli <peterm@redhat.com>
Signed-off-by: default avatarDavid Mosberger <davidm@hpl.hp.com>
parent 670a7f72
...@@ -110,7 +110,9 @@ GLOBAL_ENTRY(ia32_ret_from_clone) ...@@ -110,7 +110,9 @@ GLOBAL_ENTRY(ia32_ret_from_clone)
ld4 r2=[r2] ld4 r2=[r2]
;; ;;
mov r8=0 mov r8=0
tbit.nz p6,p0=r2,TIF_SYSCALL_TRACE and r2=_TIF_SYSCALL_TRACEAUDIT,r2
;;
cmp.ne p6,p0=r2,r0
(p6) br.cond.spnt .ia32_strace_check_retval (p6) br.cond.spnt .ia32_strace_check_retval
;; // prevent RAW on r8 ;; // prevent RAW on r8
END(ia32_ret_from_clone) END(ia32_ret_from_clone)
...@@ -142,7 +144,7 @@ GLOBAL_ENTRY(ia32_trace_syscall) ...@@ -142,7 +144,7 @@ GLOBAL_ENTRY(ia32_trace_syscall)
adds r2=IA64_PT_REGS_R8_OFFSET+16,sp adds r2=IA64_PT_REGS_R8_OFFSET+16,sp
;; ;;
st8 [r2]=r3 // initialize return code to -ENOSYS st8 [r2]=r3 // initialize return code to -ENOSYS
br.call.sptk.few rp=syscall_trace // give parent a chance to catch syscall args br.call.sptk.few rp=syscall_trace_enter // give parent a chance to catch syscall args
.ret2: // Need to reload arguments (they may be changed by the tracing process) .ret2: // Need to reload arguments (they may be changed by the tracing process)
adds r2=IA64_PT_REGS_R1_OFFSET+16,sp // r2 = &pt_regs.r1 adds r2=IA64_PT_REGS_R1_OFFSET+16,sp // r2 = &pt_regs.r1
adds r3=IA64_PT_REGS_R13_OFFSET+16,sp // r3 = &pt_regs.r13 adds r3=IA64_PT_REGS_R13_OFFSET+16,sp // r3 = &pt_regs.r13
...@@ -170,7 +172,7 @@ GLOBAL_ENTRY(ia32_trace_syscall) ...@@ -170,7 +172,7 @@ GLOBAL_ENTRY(ia32_trace_syscall)
adds r2=IA64_PT_REGS_R8_OFFSET+16,sp // r2 = &pt_regs.r8 adds r2=IA64_PT_REGS_R8_OFFSET+16,sp // r2 = &pt_regs.r8
;; ;;
st8.spill [r2]=r8 // store return value in slot for r8 st8.spill [r2]=r8 // store return value in slot for r8
br.call.sptk.few rp=syscall_trace // give parent a chance to catch return value br.call.sptk.few rp=syscall_trace_leave // give parent a chance to catch return value
.ret4: alloc r2=ar.pfs,0,0,0,0 // drop the syscall argument frame .ret4: alloc r2=ar.pfs,0,0,0,0 // drop the syscall argument frame
br.cond.sptk.many ia64_leave_kernel br.cond.sptk.many ia64_leave_kernel
END(ia32_trace_syscall) END(ia32_trace_syscall)
......
...@@ -508,7 +508,7 @@ GLOBAL_ENTRY(ia64_trace_syscall) ...@@ -508,7 +508,7 @@ GLOBAL_ENTRY(ia64_trace_syscall)
;; ;;
stf.spill [r16]=f10 stf.spill [r16]=f10
stf.spill [r17]=f11 stf.spill [r17]=f11
br.call.sptk.many rp=syscall_trace // give parent a chance to catch syscall args br.call.sptk.many rp=syscall_trace_enter // give parent a chance to catch syscall args
adds r16=PT(F6)+16,sp adds r16=PT(F6)+16,sp
adds r17=PT(F7)+16,sp adds r17=PT(F7)+16,sp
;; ;;
...@@ -548,7 +548,7 @@ GLOBAL_ENTRY(ia64_trace_syscall) ...@@ -548,7 +548,7 @@ GLOBAL_ENTRY(ia64_trace_syscall)
.strace_save_retval: .strace_save_retval:
.mem.offset 0,0; st8.spill [r2]=r8 // store return value in slot for r8 .mem.offset 0,0; st8.spill [r2]=r8 // store return value in slot for r8
.mem.offset 8,0; st8.spill [r3]=r10 // clear error indication in slot for r10 .mem.offset 8,0; st8.spill [r3]=r10 // clear error indication in slot for r10
br.call.sptk.many rp=syscall_trace // give parent a chance to catch return value br.call.sptk.many rp=syscall_trace_leave // give parent a chance to catch return value
.ret3: br.cond.sptk ia64_leave_syscall .ret3: br.cond.sptk ia64_leave_syscall
strace_error: strace_error:
...@@ -575,7 +575,7 @@ GLOBAL_ENTRY(ia64_strace_leave_kernel) ...@@ -575,7 +575,7 @@ GLOBAL_ENTRY(ia64_strace_leave_kernel)
*/ */
nop.m 0 nop.m 0
nop.i 0 nop.i 0
br.call.sptk.many rp=syscall_trace // give parent a chance to catch return value br.call.sptk.many rp=syscall_trace_leave // give parent a chance to catch return value
} }
.ret4: br.cond.sptk ia64_leave_kernel .ret4: br.cond.sptk ia64_leave_kernel
END(ia64_strace_leave_kernel) END(ia64_strace_leave_kernel)
...@@ -601,7 +601,9 @@ GLOBAL_ENTRY(ia64_ret_from_clone) ...@@ -601,7 +601,9 @@ GLOBAL_ENTRY(ia64_ret_from_clone)
ld4 r2=[r2] ld4 r2=[r2]
;; ;;
mov r8=0 mov r8=0
tbit.nz p6,p0=r2,TIF_SYSCALL_TRACE and r2=_TIF_SYSCALL_TRACEAUDIT,r2
;;
cmp.ne p6,p0=r2,r0
(p6) br.cond.spnt .strace_check_retval (p6) br.cond.spnt .strace_check_retval
;; // added stop bits to prevent r8 dependency ;; // added stop bits to prevent r8 dependency
END(ia64_ret_from_clone) END(ia64_ret_from_clone)
......
...@@ -752,7 +752,9 @@ ENTRY(break_fault) ...@@ -752,7 +752,9 @@ ENTRY(break_fault)
;; ;;
ld4 r2=[r2] // r2 = current_thread_info()->flags ld4 r2=[r2] // r2 = current_thread_info()->flags
;; ;;
tbit.z p8,p0=r2,TIF_SYSCALL_TRACE and r2=_TIF_SYSCALL_TRACEAUDIT,r2 // mask trace or audit
;;
cmp.eq p8,p0=r2,r0
mov b6=r20 mov b6=r20
;; ;;
(p8) br.call.sptk.many b6=b6 // ignore this return addr (p8) br.call.sptk.many b6=b6 // ignore this return addr
...@@ -1573,10 +1575,11 @@ ENTRY(dispatch_to_ia32_handler) ...@@ -1573,10 +1575,11 @@ ENTRY(dispatch_to_ia32_handler)
ld4 r2=[r2] // r2 = current_thread_info()->flags ld4 r2=[r2] // r2 = current_thread_info()->flags
;; ;;
ld8 r16=[r16] ld8 r16=[r16]
tbit.z p8,p0=r2,TIF_SYSCALL_TRACE and r2=_TIF_SYSCALL_TRACEAUDIT,r2 // mask trace or audit
;; ;;
mov b6=r16 mov b6=r16
movl r15=ia32_ret_from_syscall movl r15=ia32_ret_from_syscall
cmp.eq p8,p0=r2,r0
;; ;;
mov rp=r15 mov rp=r15
(p8) br.call.sptk.many b6=b6 (p8) br.call.sptk.many b6=b6
......
...@@ -1447,9 +1447,8 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data, ...@@ -1447,9 +1447,8 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data,
return ret; return ret;
} }
/* "asmlinkage" so the input arguments are preserved... */
asmlinkage void void
syscall_trace (void) syscall_trace (void)
{ {
if (!test_thread_flag(TIF_SYSCALL_TRACE)) if (!test_thread_flag(TIF_SYSCALL_TRACE))
...@@ -1472,3 +1471,42 @@ syscall_trace (void) ...@@ -1472,3 +1471,42 @@ syscall_trace (void)
current->exit_code = 0; current->exit_code = 0;
} }
} }
/* "asmlinkage" so the input arguments are preserved... */
asmlinkage void
syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
long arg4, long arg5, long arg6, long arg7, long stack)
{
struct pt_regs *regs = (struct pt_regs *) &stack;
long syscall;
if (unlikely(current->audit_context)) {
if (IS_IA32_PROCESS(regs))
syscall = regs->r1;
else
syscall = regs->r15;
audit_syscall_entry(current, syscall, arg0, arg1, arg2, arg3);
}
if (test_thread_flag(TIF_SYSCALL_TRACE)
&& (current->ptrace & PT_PTRACED))
syscall_trace();
}
/* "asmlinkage" so the input arguments are preserved... */
asmlinkage void
syscall_trace_leave (long arg0, long arg1, long arg2, long arg3,
long arg4, long arg5, long arg6, long arg7, long stack)
{
struct pt_regs *regs = (struct pt_regs *) &stack;
if (unlikely(current->audit_context))
audit_syscall_exit(current, regs->r8);
if (test_thread_flag(TIF_SYSCALL_TRACE)
&& (current->ptrace & PT_PTRACED))
syscall_trace();
}
...@@ -73,12 +73,15 @@ struct thread_info { ...@@ -73,12 +73,15 @@ struct thread_info {
#define TIF_SIGPENDING 1 /* signal pending */ #define TIF_SIGPENDING 1 /* signal pending */
#define TIF_NEED_RESCHED 2 /* rescheduling necessary */ #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
#define TIF_SYSCALL_TRACE 3 /* syscall trace active */ #define TIF_SYSCALL_TRACE 3 /* syscall trace active */
#define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */
#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
#define TIF_WORK_MASK 0x7 /* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE */ #define TIF_WORK_MASK 0x7 /* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE */
#define TIF_ALLWORK_MASK 0xf /* bits 0..3 are "work to do on user-return" bits */ #define TIF_ALLWORK_MASK 0x1f /* bits 0..4 are "work to do on user-return" bits */
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
#define _TIF_SYSCALL_TRACEAUDIT (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
......
...@@ -162,7 +162,7 @@ config AUDIT ...@@ -162,7 +162,7 @@ config AUDIT
config AUDITSYSCALL config AUDITSYSCALL
bool "Enable system-call auditing support" bool "Enable system-call auditing support"
depends on AUDIT && (X86 || PPC64 || ARCH_S390) depends on AUDIT && (X86 || PPC64 || ARCH_S390 || IA64)
default y if SECURITY_SELINUX default y if SECURITY_SELINUX
default n default n
help help
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment