mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
audit: inline audit_syscall_entry to reduce burden on archs
Every arch calls: if (unlikely(current->audit_context)) audit_syscall_entry() which requires knowledge about audit (the existance of audit_context) in the arch code. Just do it all in static inline in audit.h so that arch's can remain blissfully ignorant. Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
parent
f031cd2556
commit
b05d8447e7
@ -1246,15 +1246,8 @@ syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
|
||||
if (test_thread_flag(TIF_RESTORE_RSE))
|
||||
ia64_sync_krbs();
|
||||
|
||||
if (unlikely(current->audit_context)) {
|
||||
long syscall;
|
||||
int arch;
|
||||
|
||||
syscall = regs.r15;
|
||||
arch = AUDIT_ARCH_IA64;
|
||||
|
||||
audit_syscall_entry(arch, syscall, arg0, arg1, arg2, arg3);
|
||||
}
|
||||
audit_syscall_entry(AUDIT_ARCH_IA64, regs.r15, arg0, arg1, arg2, arg3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -147,10 +147,8 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
|
||||
*/
|
||||
ret = -1L;
|
||||
|
||||
if (unlikely(current->audit_context))
|
||||
audit_syscall_entry(EM_MICROBLAZE, regs->r12,
|
||||
regs->r5, regs->r6,
|
||||
regs->r7, regs->r8);
|
||||
audit_syscall_entry(EM_MICROBLAZE, regs->r12, regs->r5, regs->r6,
|
||||
regs->r7, regs->r8);
|
||||
|
||||
return ret ?: regs->r12;
|
||||
}
|
||||
|
@ -560,10 +560,9 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
|
||||
}
|
||||
|
||||
out:
|
||||
if (unlikely(current->audit_context))
|
||||
audit_syscall_entry(audit_arch(), regs->regs[2],
|
||||
regs->regs[4], regs->regs[5],
|
||||
regs->regs[6], regs->regs[7]);
|
||||
audit_syscall_entry(audit_arch(), regs->regs[2],
|
||||
regs->regs[4], regs->regs[5],
|
||||
regs->regs[6], regs->regs[7]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1724,22 +1724,20 @@ long do_syscall_trace_enter(struct pt_regs *regs)
|
||||
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
|
||||
trace_sys_enter(regs, regs->gpr[0]);
|
||||
|
||||
if (unlikely(current->audit_context)) {
|
||||
#ifdef CONFIG_PPC64
|
||||
if (!is_32bit_task())
|
||||
audit_syscall_entry(AUDIT_ARCH_PPC64,
|
||||
regs->gpr[0],
|
||||
regs->gpr[3], regs->gpr[4],
|
||||
regs->gpr[5], regs->gpr[6]);
|
||||
else
|
||||
if (!is_32bit_task())
|
||||
audit_syscall_entry(AUDIT_ARCH_PPC64,
|
||||
regs->gpr[0],
|
||||
regs->gpr[3], regs->gpr[4],
|
||||
regs->gpr[5], regs->gpr[6]);
|
||||
else
|
||||
#endif
|
||||
audit_syscall_entry(AUDIT_ARCH_PPC,
|
||||
regs->gpr[0],
|
||||
regs->gpr[3] & 0xffffffff,
|
||||
regs->gpr[4] & 0xffffffff,
|
||||
regs->gpr[5] & 0xffffffff,
|
||||
regs->gpr[6] & 0xffffffff);
|
||||
}
|
||||
audit_syscall_entry(AUDIT_ARCH_PPC,
|
||||
regs->gpr[0],
|
||||
regs->gpr[3] & 0xffffffff,
|
||||
regs->gpr[4] & 0xffffffff,
|
||||
regs->gpr[5] & 0xffffffff,
|
||||
regs->gpr[6] & 0xffffffff);
|
||||
|
||||
return ret ?: regs->gpr[0];
|
||||
}
|
||||
|
@ -740,12 +740,11 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
|
||||
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
|
||||
trace_sys_enter(regs, regs->gprs[2]);
|
||||
|
||||
if (unlikely(current->audit_context))
|
||||
audit_syscall_entry(is_compat_task() ?
|
||||
AUDIT_ARCH_S390 : AUDIT_ARCH_S390X,
|
||||
regs->gprs[2], regs->orig_gpr2,
|
||||
regs->gprs[3], regs->gprs[4],
|
||||
regs->gprs[5]);
|
||||
audit_syscall_entry(is_compat_task() ?
|
||||
AUDIT_ARCH_S390 : AUDIT_ARCH_S390X,
|
||||
regs->gprs[2], regs->orig_gpr2,
|
||||
regs->gprs[3], regs->gprs[4],
|
||||
regs->gprs[5]);
|
||||
return ret ?: regs->gprs[2];
|
||||
}
|
||||
|
||||
|
@ -518,10 +518,9 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
|
||||
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
|
||||
trace_sys_enter(regs, regs->regs[0]);
|
||||
|
||||
if (unlikely(current->audit_context))
|
||||
audit_syscall_entry(audit_arch(), regs->regs[3],
|
||||
regs->regs[4], regs->regs[5],
|
||||
regs->regs[6], regs->regs[7]);
|
||||
audit_syscall_entry(audit_arch(), regs->regs[3],
|
||||
regs->regs[4], regs->regs[5],
|
||||
regs->regs[6], regs->regs[7]);
|
||||
|
||||
return ret ?: regs->regs[0];
|
||||
}
|
||||
|
@ -536,10 +536,9 @@ asmlinkage long long do_syscall_trace_enter(struct pt_regs *regs)
|
||||
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
|
||||
trace_sys_enter(regs, regs->regs[9]);
|
||||
|
||||
if (unlikely(current->audit_context))
|
||||
audit_syscall_entry(audit_arch(), regs->regs[1],
|
||||
regs->regs[2], regs->regs[3],
|
||||
regs->regs[4], regs->regs[5]);
|
||||
audit_syscall_entry(audit_arch(), regs->regs[1],
|
||||
regs->regs[2], regs->regs[3],
|
||||
regs->regs[4], regs->regs[5]);
|
||||
|
||||
return ret ?: regs->regs[9];
|
||||
}
|
||||
|
@ -1071,15 +1071,14 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
|
||||
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
|
||||
trace_sys_enter(regs, regs->u_regs[UREG_G1]);
|
||||
|
||||
if (unlikely(current->audit_context) && !ret)
|
||||
audit_syscall_entry((test_thread_flag(TIF_32BIT) ?
|
||||
AUDIT_ARCH_SPARC :
|
||||
AUDIT_ARCH_SPARC64),
|
||||
regs->u_regs[UREG_G1],
|
||||
regs->u_regs[UREG_I0],
|
||||
regs->u_regs[UREG_I1],
|
||||
regs->u_regs[UREG_I2],
|
||||
regs->u_regs[UREG_I3]);
|
||||
audit_syscall_entry((test_thread_flag(TIF_32BIT) ?
|
||||
AUDIT_ARCH_SPARC :
|
||||
AUDIT_ARCH_SPARC64),
|
||||
regs->u_regs[UREG_G1],
|
||||
regs->u_regs[UREG_I0],
|
||||
regs->u_regs[UREG_I1],
|
||||
regs->u_regs[UREG_I2],
|
||||
regs->u_regs[UREG_I3]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -167,17 +167,15 @@ void syscall_trace(struct uml_pt_regs *regs, int entryexit)
|
||||
int is_singlestep = (current->ptrace & PT_DTRACE) && entryexit;
|
||||
int tracesysgood;
|
||||
|
||||
if (unlikely(current->audit_context)) {
|
||||
if (!entryexit)
|
||||
audit_syscall_entry(HOST_AUDIT_ARCH,
|
||||
UPT_SYSCALL_NR(regs),
|
||||
UPT_SYSCALL_ARG1(regs),
|
||||
UPT_SYSCALL_ARG2(regs),
|
||||
UPT_SYSCALL_ARG3(regs),
|
||||
UPT_SYSCALL_ARG4(regs));
|
||||
else
|
||||
audit_syscall_exit(regs);
|
||||
}
|
||||
if (!entryexit)
|
||||
audit_syscall_entry(HOST_AUDIT_ARCH,
|
||||
UPT_SYSCALL_NR(regs),
|
||||
UPT_SYSCALL_ARG1(regs),
|
||||
UPT_SYSCALL_ARG2(regs),
|
||||
UPT_SYSCALL_ARG3(regs),
|
||||
UPT_SYSCALL_ARG4(regs));
|
||||
else
|
||||
audit_syscall_exit(regs);
|
||||
|
||||
/* Fake a debug trap */
|
||||
if (is_singlestep)
|
||||
|
@ -192,7 +192,7 @@ sysexit_from_sys_call:
|
||||
movl %ebx,%edx /* 3rd arg: 1st syscall arg */
|
||||
movl %eax,%esi /* 2nd arg: syscall number */
|
||||
movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
|
||||
call audit_syscall_entry
|
||||
call __audit_syscall_entry
|
||||
movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
|
||||
cmpq $(IA32_NR_syscalls-1),%rax
|
||||
ja ia32_badsys
|
||||
|
@ -456,7 +456,7 @@ sysenter_audit:
|
||||
movl %ebx,%ecx /* 3rd arg: 1st syscall arg */
|
||||
movl %eax,%edx /* 2nd arg: syscall number */
|
||||
movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
|
||||
call audit_syscall_entry
|
||||
call __audit_syscall_entry
|
||||
pushl_cfi %ebx
|
||||
movl PT_EAX(%esp),%eax /* reload syscall number */
|
||||
jmp sysenter_do_call
|
||||
|
@ -549,7 +549,7 @@ badsys:
|
||||
#ifdef CONFIG_AUDITSYSCALL
|
||||
/*
|
||||
* Fast path for syscall audit without full syscall trace.
|
||||
* We just call audit_syscall_entry() directly, and then
|
||||
* We just call __audit_syscall_entry() directly, and then
|
||||
* jump back to the normal fast path.
|
||||
*/
|
||||
auditsys:
|
||||
@ -559,7 +559,7 @@ auditsys:
|
||||
movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
|
||||
movq %rax,%rsi /* 2nd arg: syscall number */
|
||||
movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
|
||||
call audit_syscall_entry
|
||||
call __audit_syscall_entry
|
||||
LOAD_ARGS 0 /* reload call-clobbered registers */
|
||||
jmp system_call_fastpath
|
||||
|
||||
|
@ -1392,20 +1392,18 @@ long syscall_trace_enter(struct pt_regs *regs)
|
||||
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
|
||||
trace_sys_enter(regs, regs->orig_ax);
|
||||
|
||||
if (unlikely(current->audit_context)) {
|
||||
if (IS_IA32)
|
||||
audit_syscall_entry(AUDIT_ARCH_I386,
|
||||
regs->orig_ax,
|
||||
regs->bx, regs->cx,
|
||||
regs->dx, regs->si);
|
||||
if (IS_IA32)
|
||||
audit_syscall_entry(AUDIT_ARCH_I386,
|
||||
regs->orig_ax,
|
||||
regs->bx, regs->cx,
|
||||
regs->dx, regs->si);
|
||||
#ifdef CONFIG_X86_64
|
||||
else
|
||||
audit_syscall_entry(AUDIT_ARCH_X86_64,
|
||||
regs->orig_ax,
|
||||
regs->di, regs->si,
|
||||
regs->dx, regs->r10);
|
||||
else
|
||||
audit_syscall_entry(AUDIT_ARCH_X86_64,
|
||||
regs->orig_ax,
|
||||
regs->di, regs->si,
|
||||
regs->dx, regs->r10);
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret ?: regs->orig_ax;
|
||||
}
|
||||
|
@ -334,8 +334,7 @@ void do_syscall_trace_enter(struct pt_regs *regs)
|
||||
do_syscall_trace();
|
||||
|
||||
#if 0
|
||||
if (unlikely(current->audit_context))
|
||||
audit_syscall_entry(current, AUDIT_ARCH_XTENSA..);
|
||||
audit_syscall_entry(current, AUDIT_ARCH_XTENSA..);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -418,9 +418,9 @@ extern int audit_classify_arch(int arch);
|
||||
extern void audit_finish_fork(struct task_struct *child);
|
||||
extern int audit_alloc(struct task_struct *task);
|
||||
extern void audit_free(struct task_struct *task);
|
||||
extern void audit_syscall_entry(int arch,
|
||||
int major, unsigned long a0, unsigned long a1,
|
||||
unsigned long a2, unsigned long a3);
|
||||
extern void __audit_syscall_entry(int arch,
|
||||
int major, unsigned long a0, unsigned long a1,
|
||||
unsigned long a2, unsigned long a3);
|
||||
extern void __audit_syscall_exit(int ret_success, long ret_value);
|
||||
extern void __audit_getname(const char *name);
|
||||
extern void audit_putname(const char *name);
|
||||
@ -435,6 +435,13 @@ static inline int audit_dummy_context(void)
|
||||
void *p = current->audit_context;
|
||||
return !p || *(int *)p;
|
||||
}
|
||||
static inline void audit_syscall_entry(int arch, int major, unsigned long a0,
|
||||
unsigned long a1, unsigned long a2,
|
||||
unsigned long a3)
|
||||
{
|
||||
if (unlikely(!audit_dummy_context()))
|
||||
__audit_syscall_entry(arch, major, a0, a1, a2, a3);
|
||||
}
|
||||
static inline void audit_syscall_exit(void *pt_regs)
|
||||
{
|
||||
if (unlikely(current->audit_context)) {
|
||||
|
@ -1632,7 +1632,7 @@ void audit_free(struct task_struct *tsk)
|
||||
* will only be written if another part of the kernel requests that it
|
||||
* be written).
|
||||
*/
|
||||
void audit_syscall_entry(int arch, int major,
|
||||
void __audit_syscall_entry(int arch, int major,
|
||||
unsigned long a1, unsigned long a2,
|
||||
unsigned long a3, unsigned long a4)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user