Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 811
b: refs/heads/master
c: 52292c9
h: refs/heads/master
i:
  809: 643cfa7
  807: 9e4be59
v: v3
  • Loading branch information
Benjamin Herrenschmidt authored and Linus Torvalds committed May 3, 2005
1 parent c3b80f8 commit b881e74
Show file tree
Hide file tree
Showing 22 changed files with 137 additions and 275 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 488f2eaca1b0831a5a5e6a66e33bad2cdeff7238
refs/heads/master: 52292c9b8c16aa9024a65aaeeca434bb8fec7d24
19 changes: 10 additions & 9 deletions trunk/arch/i386/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,18 +683,24 @@ void do_syscall_trace(struct pt_regs *regs, int entryexit)
/* do the secure computing check first */
secure_computing(regs->orig_eax);

if (unlikely(current->audit_context) && entryexit)
audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), regs->eax);
if (unlikely(current->audit_context)) {
if (!entryexit)
audit_syscall_entry(current, regs->orig_eax,
regs->ebx, regs->ecx,
regs->edx, regs->esi);
else
audit_syscall_exit(current, regs->eax);
}

if (!(current->ptrace & PT_PTRACED))
goto out;
return;

/* Fake a debug trap */
if (test_thread_flag(TIF_SINGLESTEP))
send_sigtrap(current, regs, 0);

if (!test_thread_flag(TIF_SYSCALL_TRACE))
goto out;
return;

/* the 0x80 provides a way for the tracing parent to distinguish
between a syscall stop and SIGTRAP delivery */
Expand All @@ -709,9 +715,4 @@ void do_syscall_trace(struct pt_regs *regs, int entryexit)
send_sig(current->exit_code, current, 1);
current->exit_code = 0;
}
out:
if (unlikely(current->audit_context) && !entryexit)
audit_syscall_entry(current, AUDIT_ARCH_I386, regs->orig_eax,
regs->ebx, regs->ecx, regs->edx, regs->esi);

}
4 changes: 1 addition & 3 deletions trunk/arch/ia64/kernel/fsys.S
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,8 @@ GLOBAL_ENTRY(fsys_bubble_down)
movl r2=ia64_ret_from_syscall
;;
mov rp=r2 // set the real return addr
and r3=_TIF_SYSCALL_TRACEAUDIT,r3
tbit.z p8,p0=r3,TIF_SYSCALL_TRACE
;;
cmp.eq p8,p0=r3,r0

(p10) br.cond.spnt.many ia64_ret_from_syscall // p10==true means out registers are more than 8
(p8) br.call.sptk.many b6=b6 // ignore this return addr
br.cond.sptk ia64_trace_syscall
Expand Down
21 changes: 8 additions & 13 deletions trunk/arch/ia64/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1596,25 +1596,20 @@ syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
long arg4, long arg5, long arg6, long arg7,
struct pt_regs regs)
{
if (test_thread_flag(TIF_SYSCALL_TRACE)
&& (current->ptrace & PT_PTRACED))
syscall_trace();
long syscall;

if (unlikely(current->audit_context)) {
long syscall;
int arch;

if (IS_IA32_PROCESS(&regs)) {
if (IS_IA32_PROCESS(&regs))
syscall = regs.r1;
arch = AUDIT_ARCH_I386;
} else {
else
syscall = regs.r15;
arch = AUDIT_ARCH_IA64;
}

audit_syscall_entry(current, arch, syscall, arg0, arg1, arg2, arg3);
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... */
Expand All @@ -1625,7 +1620,7 @@ syscall_trace_leave (long arg0, long arg1, long arg2, long arg3,
struct pt_regs regs)
{
if (unlikely(current->audit_context))
audit_syscall_exit(current, AUDITSC_RESULT(regs.r10), regs.r8);
audit_syscall_exit(current, regs.r8);

if (test_thread_flag(TIF_SYSCALL_TRACE)
&& (current->ptrace & PT_PTRACED))
Expand Down
3 changes: 1 addition & 2 deletions trunk/arch/ia64/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ ia64_rt_sigreturn (struct sigscratch *scr)
* could be corrupted.
*/
retval = (long) &ia64_leave_kernel;
if (test_thread_flag(TIF_SYSCALL_TRACE)
|| test_thread_flag(TIF_SYSCALL_AUDIT))
if (test_thread_flag(TIF_SYSCALL_TRACE))
/*
* strace expects to be notified after sigreturn returns even though the
* context to which we return may not be in the middle of a syscall.
Expand Down
38 changes: 10 additions & 28 deletions trunk/arch/mips/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,38 +301,25 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
return ret;
}

static inline int audit_arch(void)
{
#ifdef CONFIG_CPU_LITTLE_ENDIAN
#ifdef CONFIG_MIPS64
if (!(current->thread.mflags & MF_32BIT_REGS))
return AUDIT_ARCH_MIPSEL64;
#endif /* MIPS64 */
return AUDIT_ARCH_MIPSEL;

#else /* big endian... */
#ifdef CONFIG_MIPS64
if (!(current->thread.mflags & MF_32BIT_REGS))
return AUDIT_ARCH_MIPS64;
#endif /* MIPS64 */
return AUDIT_ARCH_MIPS;

#endif /* endian */
}

/*
* Notification of system call entry/exit
* - triggered by current->work.syscall_trace
*/
asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
{
if (unlikely(current->audit_context) && entryexit)
audit_syscall_exit(current, AUDITSC_RESULT(regs->regs[2]), regs->regs[2]);
if (unlikely(current->audit_context)) {
if (!entryexit)
audit_syscall_entry(current, regs->regs[2],
regs->regs[4], regs->regs[5],
regs->regs[6], regs->regs[7]);
else
audit_syscall_exit(current, regs->regs[2]);
}

if (!test_thread_flag(TIF_SYSCALL_TRACE))
goto out;
return;
if (!(current->ptrace & PT_PTRACED))
goto out;
return;

/* The 0x80 provides a way for the tracing parent to distinguish
between a syscall stop and SIGTRAP delivery */
Expand All @@ -348,9 +335,4 @@ asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
send_sig(current->exit_code, current, 1);
current->exit_code = 0;
}
out:
if (unlikely(current->audit_context) && !entryexit)
audit_syscall_entry(current, audit_arch(), regs->regs[2],
regs->regs[4], regs->regs[5],
regs->regs[6], regs->regs[7]);
}
7 changes: 7 additions & 0 deletions trunk/arch/ppc64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@ LDFLAGS_vmlinux := -Bstatic -e $(KERNELLOAD) -Ttext $(KERNELLOAD)
CFLAGS += -msoft-float -pipe -mminimal-toc -mtraceback=none \
-mcall-aixdesc

GCC_VERSION := $(call cc-version)
GCC_BROKEN_VEC := $(shell if [ $(GCC_VERSION) -lt 0400 ] ; then echo "y"; fi ;)

ifeq ($(CONFIG_POWER4_ONLY),y)
ifeq ($(CONFIG_ALTIVEC),y)
ifeq ($(GCC_BROKEN_VEC),y)
CFLAGS += $(call cc-option,-mcpu=970)
else
CFLAGS += $(call cc-option,-mcpu=power4)
endif
else
CFLAGS += $(call cc-option,-mcpu=power4)
endif
else
CFLAGS += $(call cc-option,-mtune=power4)
endif
Expand Down
15 changes: 5 additions & 10 deletions trunk/arch/ppc64/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,27 +305,22 @@ static void do_syscall_trace(void)

void do_syscall_trace_enter(struct pt_regs *regs)
{
if (test_thread_flag(TIF_SYSCALL_TRACE)
&& (current->ptrace & PT_PTRACED))
do_syscall_trace();

if (unlikely(current->audit_context))
audit_syscall_entry(current,
test_thread_flag(TIF_32BIT)?AUDIT_ARCH_PPC:AUDIT_ARCH_PPC64,
regs->gpr[0],
audit_syscall_entry(current, regs->gpr[0],
regs->gpr[3], regs->gpr[4],
regs->gpr[5], regs->gpr[6]);

if (test_thread_flag(TIF_SYSCALL_TRACE)
&& (current->ptrace & PT_PTRACED))
do_syscall_trace();
}

void do_syscall_trace_leave(struct pt_regs *regs)
{
secure_computing(regs->gpr[0]);

if (unlikely(current->audit_context))
audit_syscall_exit(current,
(regs->ccr&0x1000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
regs->result);
audit_syscall_exit(current, regs->result);

if ((test_thread_flag(TIF_SYSCALL_TRACE)
|| test_thread_flag(TIF_SINGLESTEP))
Expand Down
21 changes: 10 additions & 11 deletions trunk/arch/s390/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,13 +712,18 @@ sys_ptrace(long request, long pid, long addr, long data)
asmlinkage void
syscall_trace(struct pt_regs *regs, int entryexit)
{
if (unlikely(current->audit_context) && entryexit)
audit_syscall_exit(current, AUDITSC_RESULT(regs->gprs[2]), regs->gprs[2]);

if (unlikely(current->audit_context)) {
if (!entryexit)
audit_syscall_entry(current, regs->gprs[2],
regs->orig_gpr2, regs->gprs[3],
regs->gprs[4], regs->gprs[5]);
else
audit_syscall_exit(current, regs->gprs[2]);
}
if (!test_thread_flag(TIF_SYSCALL_TRACE))
goto out;
return;
if (!(current->ptrace & PT_PTRACED))
goto out;
return;
ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
? 0x80 : 0));

Expand All @@ -731,10 +736,4 @@ syscall_trace(struct pt_regs *regs, int entryexit)
send_sig(current->exit_code, current, 1);
current->exit_code = 0;
}
out:
if (unlikely(current->audit_context) && !entryexit)
audit_syscall_entry(current,
test_thread_flag(TIF_31BIT)?AUDIT_ARCH_S390:AUDIT_ARCH_S390X,
regs->gprs[2], regs->orig_gpr2, regs->gprs[3],
regs->gprs[4], regs->gprs[5]);
}
21 changes: 9 additions & 12 deletions trunk/arch/um/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,15 @@ void syscall_trace(union uml_pt_regs *regs, int entryexit)

if (unlikely(current->audit_context)) {
if (!entryexit)
audit_syscall_entry(current,
HOST_AUDIT_ARCH,
UPT_SYSCALL_NR(regs),
UPT_SYSCALL_ARG1(regs),
UPT_SYSCALL_ARG2(regs),
UPT_SYSCALL_ARG3(regs),
UPT_SYSCALL_ARG4(regs));
else {
int res = UPT_SYSCALL_RET(regs);
audit_syscall_exit(current, AUDITSC_RESULT(res),
res);
}
audit_syscall_entry(current,
UPT_SYSCALL_NR(&regs->regs),
UPT_SYSCALL_ARG1(&regs->regs),
UPT_SYSCALL_ARG2(&regs->regs),
UPT_SYSCALL_ARG3(&regs->regs),
UPT_SYSCALL_ARG4(&regs->regs));
else
audit_syscall_exit(current,
UPT_SYSCALL_RET(&regs->regs));
}

/* Fake a debug trap */
Expand Down
21 changes: 6 additions & 15 deletions trunk/arch/x86_64/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,29 +635,20 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
/* do the secure computing check first */
secure_computing(regs->orig_rax);

if (unlikely(current->audit_context))
audit_syscall_entry(current, regs->orig_rax,
regs->rdi, regs->rsi,
regs->rdx, regs->r10);

if (test_thread_flag(TIF_SYSCALL_TRACE)
&& (current->ptrace & PT_PTRACED))
syscall_trace(regs);

if (unlikely(current->audit_context)) {
if (test_thread_flag(TIF_IA32)) {
audit_syscall_entry(current, AUDIT_ARCH_I386,
regs->orig_rax,
regs->rbx, regs->rcx,
regs->rdx, regs->rsi);
} else {
audit_syscall_entry(current, AUDIT_ARCH_X86_64,
regs->orig_rax,
regs->rdi, regs->rsi,
regs->rdx, regs->r10);
}
}
}

asmlinkage void syscall_trace_leave(struct pt_regs *regs)
{
if (unlikely(current->audit_context))
audit_syscall_exit(current, AUDITSC_RESULT(regs->rax), regs->rax);
audit_syscall_exit(current, regs->rax);

if ((test_thread_flag(TIF_SYSCALL_TRACE)
|| test_thread_flag(TIF_SINGLESTEP))
Expand Down
20 changes: 8 additions & 12 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,11 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,

/*
* Name resolution.
* This is the basic name resolution function, turning a pathname into
* the final dentry. We expect 'base' to be positive and a directory.
*
* Returns 0 and nd will have valid dentry and mnt on success.
* Returns error and drops reference to input namei data on failure.
* This is the basic name resolution function, turning a pathname
* into the final dentry.
*
* We expect 'base' to be positive and a directory.
*/
static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
{
Expand Down Expand Up @@ -929,10 +929,8 @@ int fastcall path_walk(const char * name, struct nameidata *nd)
return link_path_walk(name, nd);
}

/*
* SMP-safe: Returns 1 and nd will have valid dentry and mnt, if
* everything is done. Returns 0 and drops input nd, if lookup failed;
*/
/* SMP-safe */
/* returns 1 if everything is done */
static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
{
if (path_walk(name, nd))
Expand Down Expand Up @@ -996,10 +994,9 @@ void set_fs_altroot(void)
}
}

/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata *nd)
{
int retval = 0;
int retval;

nd->last_type = LAST_ROOT; /* if there are only slashes... */
nd->flags = flags;
Expand All @@ -1012,7 +1009,7 @@ int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata
nd->dentry = dget(current->fs->altroot);
read_unlock(&current->fs->lock);
if (__emul_lookup_dentry(name,nd))
goto out; /* found in altroot */
return 0;
read_lock(&current->fs->lock);
}
nd->mnt = mntget(current->fs->rootmnt);
Expand All @@ -1024,7 +1021,6 @@ int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata
read_unlock(&current->fs->lock);
current->total_link_count = 0;
retval = link_path_walk(name, nd);
out:
if (unlikely(current->audit_context
&& nd && nd->dentry && nd->dentry->d_inode))
audit_inode(name, nd->dentry->d_inode);
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
goto out_free_page;

}
length = audit_set_loginuid(task, loginuid);
length = audit_set_loginuid(task->audit_context, loginuid);
if (likely(length == 0))
length = count;

Expand Down
2 changes: 0 additions & 2 deletions trunk/include/asm-um/ptrace-i386.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#ifndef __UM_PTRACE_I386_H
#define __UM_PTRACE_I386_H

#define HOST_AUDIT_ARCH AUDIT_ARCH_I386

#include "sysdep/ptrace.h"
#include "asm/ptrace-generic.h"

Expand Down
Loading

0 comments on commit b881e74

Please sign in to comment.