Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 2407
b: refs/heads/master
c: 6f817ab
h: refs/heads/master
i:
  2405: 67982fd
  2403: 0384373
  2399: c171c0a
v: v3
  • Loading branch information
Dave Kleikamp committed May 5, 2005
1 parent 510716c commit ca57c06
Show file tree
Hide file tree
Showing 19 changed files with 270 additions and 128 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: f77165df5ba75461b491a9f20f778307f1b4a0ac
refs/heads/master: 6f817abc643ec84cf07c99f964d04976212e1fd3
19 changes: 9 additions & 10 deletions trunk/arch/i386/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,24 +683,18 @@ 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)) {
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 (unlikely(current->audit_context) && entryexit)
audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), regs->eax);

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

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

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

/* the 0x80 provides a way for the tracing parent to distinguish
between a syscall stop and SIGTRAP delivery */
Expand All @@ -715,4 +709,9 @@ 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);

}
21 changes: 13 additions & 8 deletions trunk/arch/ia64/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1596,20 +1596,25 @@ syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
long arg4, long arg5, long arg6, long arg7,
struct pt_regs regs)
{
long syscall;
if (test_thread_flag(TIF_SYSCALL_TRACE)
&& (current->ptrace & PT_PTRACED))
syscall_trace();

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

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

audit_syscall_entry(current, syscall, arg0, arg1, arg2, arg3);
audit_syscall_entry(current, arch, 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 @@ -1620,7 +1625,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, regs.r8);
audit_syscall_exit(current, AUDITSC_RESULT(regs.r10), regs.r8);

if (test_thread_flag(TIF_SYSCALL_TRACE)
&& (current->ptrace & PT_PTRACED))
Expand Down
38 changes: 28 additions & 10 deletions trunk/arch/mips/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,25 +301,38 @@ 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)) {
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 (unlikely(current->audit_context) && entryexit)
audit_syscall_exit(current, AUDITSC_RESULT(regs->regs[2]), regs->regs[2]);

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

/* The 0x80 provides a way for the tracing parent to distinguish
between a syscall stop and SIGTRAP delivery */
Expand All @@ -335,4 +348,9 @@ 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]);
}
15 changes: 10 additions & 5 deletions trunk/arch/ppc64/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,22 +305,27 @@ 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, regs->gpr[0],
audit_syscall_entry(current,
test_thread_flag(TIF_32BIT)?AUDIT_ARCH_PPC:AUDIT_ARCH_PPC64,
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->result);
audit_syscall_exit(current,
(regs->ccr&0x1000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
regs->result);

if ((test_thread_flag(TIF_SYSCALL_TRACE)
|| test_thread_flag(TIF_SINGLESTEP))
Expand Down
21 changes: 11 additions & 10 deletions trunk/arch/s390/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,18 +712,13 @@ 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)) {
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 (unlikely(current->audit_context) && entryexit)
audit_syscall_exit(current, AUDITSC_RESULT(regs->gprs[2]), regs->gprs[2]);

if (!test_thread_flag(TIF_SYSCALL_TRACE))
return;
goto out;
if (!(current->ptrace & PT_PTRACED))
return;
goto out;
ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
? 0x80 : 0));

Expand All @@ -736,4 +731,10 @@ 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: 12 additions & 9 deletions trunk/arch/um/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,18 @@ void syscall_trace(union uml_pt_regs *regs, int entryexit)

if (unlikely(current->audit_context)) {
if (!entryexit)
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));
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);
}
}

/* Fake a debug trap */
Expand Down
21 changes: 15 additions & 6 deletions trunk/arch/x86_64/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,20 +635,29 @@ 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, regs->rax);
audit_syscall_exit(current, AUDITSC_RESULT(regs->rax), regs->rax);

if ((test_thread_flag(TIF_SYSCALL_TRACE)
|| test_thread_flag(TIF_SINGLESTEP))
Expand Down
20 changes: 12 additions & 8 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.
*
* 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.
*/
static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
{
Expand Down Expand Up @@ -929,8 +929,10 @@ int fastcall path_walk(const char * name, struct nameidata *nd)
return link_path_walk(name, nd);
}

/* SMP-safe */
/* returns 1 if everything is done */
/*
* 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;
*/
static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
{
if (path_walk(name, nd))
Expand Down Expand Up @@ -994,9 +996,10 @@ 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;
int retval = 0;

nd->last_type = LAST_ROOT; /* if there are only slashes... */
nd->flags = flags;
Expand All @@ -1009,7 +1012,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))
return 0;
goto out; /* found in altroot */
read_lock(&current->fs->lock);
}
nd->mnt = mntget(current->fs->rootmnt);
Expand All @@ -1021,6 +1024,7 @@ 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->audit_context, loginuid);
length = audit_set_loginuid(task, loginuid);
if (likely(length == 0))
length = count;

Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-um/ptrace-i386.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#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
2 changes: 2 additions & 0 deletions trunk/include/asm-um/ptrace-x86_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "asm/ptrace-generic.h"
#undef signal_fault

#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64

void signal_fault(struct pt_regs_subarch *regs, void *frame, char *where);

#define FS_BASE (21 * sizeof(unsigned long))
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/asm-um/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ static inline struct thread_info *current_thread_info(void)
*/
#define TIF_RESTART_BLOCK 4
#define TIF_MEMDIE 5
#define TIF_SYSCALL_AUDIT 6

#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
#define _TIF_RESTART_BLOCK (1 << TIF_RESTART_BLOCK)
#define _TIF_MEMDIE (1 << TIF_MEMDIE)
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)

#endif

Expand Down
Loading

0 comments on commit ca57c06

Please sign in to comment.