Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 946
b: refs/heads/master
c: 4f7a181
h: refs/heads/master
v: v3
  • Loading branch information
Russell King committed May 5, 2005
1 parent c613d1f commit 3059f55
Show file tree
Hide file tree
Showing 58 changed files with 396 additions and 955 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: 3b9fa0931dd86a1fe5507311ee8031650f5d0e8c
refs/heads/master: 4f7a18124c1a44858fb74a1c4234015009952959
3 changes: 2 additions & 1 deletion trunk/arch/arm/kernel/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <asm/procinfo.h>
#include <asm/ptrace.h>
#include <asm/constants.h>
#include <asm/thread_info.h>
#include <asm/system.h>

#define PROCINFO_MMUFLAGS 8
Expand Down Expand Up @@ -131,7 +132,7 @@ __switch_data:
.long processor_id @ r4
.long __machine_arch_type @ r5
.long cr_alignment @ r6
.long init_thread_union+8192 @ sp
.long init_thread_union + THREAD_START_SP @ sp

/*
* The following fragment of code is executed with the MMU on, and uses
Expand Down
25 changes: 12 additions & 13 deletions trunk/arch/arm/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ static unsigned long *thread_info_head;
static unsigned int nr_thread_info;

#define EXTRA_TASK_STRUCT 4
#define ll_alloc_task_struct() ((struct thread_info *) __get_free_pages(GFP_KERNEL,1))
#define ll_free_task_struct(p) free_pages((unsigned long)(p),1)

struct thread_info *alloc_thread_info(struct task_struct *task)
{
Expand All @@ -274,17 +272,16 @@ struct thread_info *alloc_thread_info(struct task_struct *task)
}

if (!thread)
thread = ll_alloc_task_struct();
thread = (struct thread_info *)
__get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER);

#ifdef CONFIG_MAGIC_SYSRQ
#ifdef CONFIG_DEBUG_STACK_USAGE
/*
* The stack must be cleared if you want SYSRQ-T to
* give sensible stack usage information
*/
if (thread) {
char *p = (char *)thread;
memzero(p+KERNEL_STACK_SIZE, KERNEL_STACK_SIZE);
}
if (thread)
memzero(thread, THREAD_SIZE);
#endif
return thread;
}
Expand All @@ -297,7 +294,7 @@ void free_thread_info(struct thread_info *thread)
thread_info_head = p;
nr_thread_info += 1;
} else
ll_free_task_struct(thread);
free_pages((unsigned long)thread, THREAD_SIZE_ORDER);
}

/*
Expand Down Expand Up @@ -350,7 +347,7 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start,
struct thread_info *thread = p->thread_info;
struct pt_regs *childregs;

childregs = ((struct pt_regs *)((unsigned long)thread + THREAD_SIZE - 8)) - 1;
childregs = ((struct pt_regs *)((unsigned long)thread + THREAD_START_SP)) - 1;
*childregs = *regs;
childregs->ARM_r0 = 0;
childregs->ARM_sp = stack_start;
Expand Down Expand Up @@ -447,15 +444,17 @@ EXPORT_SYMBOL(kernel_thread);
unsigned long get_wchan(struct task_struct *p)
{
unsigned long fp, lr;
unsigned long stack_page;
unsigned long stack_start, stack_end;
int count = 0;
if (!p || p == current || p->state == TASK_RUNNING)
return 0;

stack_page = 4096 + (unsigned long)p->thread_info;
stack_start = (unsigned long)(p->thread_info + 1);
stack_end = ((unsigned long)p->thread_info) + THREAD_SIZE;

fp = thread_saved_fp(p);
do {
if (fp < stack_page || fp > 4092+stack_page)
if (fp < stack_start || fp > stack_end)
return 0;
lr = pc_pointer (((unsigned long *)fp)[-1]);
if (!in_sched_functions(lr))
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/arm/kernel/sys_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ long execve(const char *filename, char **argv, char **envp)
"b ret_to_user"
:
: "r" (current_thread_info()),
"Ir" (THREAD_SIZE - 8 - sizeof(regs)),
"Ir" (THREAD_START_SP - sizeof(regs)),
"r" (&regs),
"Ir" (sizeof(regs))
: "r0", "r1", "r2", "r3", "ip", "memory");
Expand Down
3 changes: 2 additions & 1 deletion trunk/arch/arm/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ NORET_TYPE void die(const char *str, struct pt_regs *regs, int err)
tsk->comm, tsk->pid, tsk->thread_info + 1);

if (!user_mode(regs) || in_interrupt()) {
dump_mem("Stack: ", regs->ARM_sp, 8192+(unsigned long)tsk->thread_info);
dump_mem("Stack: ", regs->ARM_sp,
THREAD_SIZE + (unsigned long)tsk->thread_info);
dump_backtrace(regs, tsk);
dump_instr(regs);
}
Expand Down
3 changes: 2 additions & 1 deletion trunk/arch/arm/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <asm-generic/vmlinux.lds.h>
#include <linux/config.h>
#include <asm/thread_info.h>

OUTPUT_ARCH(arm)
ENTRY(stext)
Expand Down Expand Up @@ -103,7 +104,7 @@ SECTIONS
__data_loc = ALIGN(4); /* location in binary */
. = DATAADDR;
#else
. = ALIGN(8192);
. = ALIGN(THREAD_SIZE);
__data_loc = .;
#endif

Expand Down
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);

}
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
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]);
}
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
Loading

0 comments on commit 3059f55

Please sign in to comment.