diff options
Diffstat (limited to 'arch/m32r/kernel/ptrace.c')
| -rw-r--r-- | arch/m32r/kernel/ptrace.c | 47 |
1 files changed, 9 insertions, 38 deletions
diff --git a/arch/m32r/kernel/ptrace.c b/arch/m32r/kernel/ptrace.c index 078d2a0e71c2..340a3bf59b88 100644 --- a/arch/m32r/kernel/ptrace.c +++ b/arch/m32r/kernel/ptrace.c | |||
| @@ -35,23 +35,6 @@ | |||
| 35 | #include <asm/mmu_context.h> | 35 | #include <asm/mmu_context.h> |
| 36 | 36 | ||
| 37 | /* | 37 | /* |
| 38 | * Get the address of the live pt_regs for the specified task. | ||
| 39 | * These are saved onto the top kernel stack when the process | ||
| 40 | * is not running. | ||
| 41 | * | ||
| 42 | * Note: if a user thread is execve'd from kernel space, the | ||
| 43 | * kernel stack will not be empty on entry to the kernel, so | ||
| 44 | * ptracing these tasks will fail. | ||
| 45 | */ | ||
| 46 | static inline struct pt_regs * | ||
| 47 | get_user_regs(struct task_struct *task) | ||
| 48 | { | ||
| 49 | return (struct pt_regs *) | ||
| 50 | ((unsigned long)task->thread_info + THREAD_SIZE | ||
| 51 | - sizeof(struct pt_regs)); | ||
| 52 | } | ||
| 53 | |||
| 54 | /* | ||
| 55 | * This routine will get a word off of the process kernel stack. | 38 | * This routine will get a word off of the process kernel stack. |
| 56 | */ | 39 | */ |
| 57 | static inline unsigned long int | 40 | static inline unsigned long int |
| @@ -59,7 +42,7 @@ get_stack_long(struct task_struct *task, int offset) | |||
| 59 | { | 42 | { |
| 60 | unsigned long *stack; | 43 | unsigned long *stack; |
| 61 | 44 | ||
| 62 | stack = (unsigned long *)get_user_regs(task); | 45 | stack = (unsigned long *)task_pt_regs(task); |
| 63 | 46 | ||
| 64 | return stack[offset]; | 47 | return stack[offset]; |
| 65 | } | 48 | } |
| @@ -72,7 +55,7 @@ put_stack_long(struct task_struct *task, int offset, unsigned long data) | |||
| 72 | { | 55 | { |
| 73 | unsigned long *stack; | 56 | unsigned long *stack; |
| 74 | 57 | ||
| 75 | stack = (unsigned long *)get_user_regs(task); | 58 | stack = (unsigned long *)task_pt_regs(task); |
| 76 | stack[offset] = data; | 59 | stack[offset] = data; |
| 77 | 60 | ||
| 78 | return 0; | 61 | return 0; |
| @@ -208,7 +191,7 @@ static int ptrace_write_user(struct task_struct *tsk, unsigned long off, | |||
| 208 | */ | 191 | */ |
| 209 | static int ptrace_getregs(struct task_struct *tsk, void __user *uregs) | 192 | static int ptrace_getregs(struct task_struct *tsk, void __user *uregs) |
| 210 | { | 193 | { |
| 211 | struct pt_regs *regs = get_user_regs(tsk); | 194 | struct pt_regs *regs = task_pt_regs(tsk); |
| 212 | 195 | ||
| 213 | return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0; | 196 | return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0; |
| 214 | } | 197 | } |
| @@ -223,7 +206,7 @@ static int ptrace_setregs(struct task_struct *tsk, void __user *uregs) | |||
| 223 | 206 | ||
| 224 | ret = -EFAULT; | 207 | ret = -EFAULT; |
| 225 | if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) { | 208 | if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) { |
| 226 | struct pt_regs *regs = get_user_regs(tsk); | 209 | struct pt_regs *regs = task_pt_regs(tsk); |
| 227 | *regs = newregs; | 210 | *regs = newregs; |
| 228 | ret = 0; | 211 | ret = 0; |
| 229 | } | 212 | } |
| @@ -762,28 +745,16 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | |||
| 762 | int ret; | 745 | int ret; |
| 763 | 746 | ||
| 764 | lock_kernel(); | 747 | lock_kernel(); |
| 765 | ret = -EPERM; | ||
| 766 | if (request == PTRACE_TRACEME) { | 748 | if (request == PTRACE_TRACEME) { |
| 767 | /* are we already being traced? */ | 749 | ret = ptrace_traceme(); |
| 768 | if (current->ptrace & PT_PTRACED) | ||
| 769 | goto out; | ||
| 770 | /* set the ptrace bit in the process flags. */ | ||
| 771 | current->ptrace |= PT_PTRACED; | ||
| 772 | ret = 0; | ||
| 773 | goto out; | 750 | goto out; |
| 774 | } | 751 | } |
| 775 | ret = -ESRCH; | ||
| 776 | read_lock(&tasklist_lock); | ||
| 777 | child = find_task_by_pid(pid); | ||
| 778 | if (child) | ||
| 779 | get_task_struct(child); | ||
| 780 | read_unlock(&tasklist_lock); | ||
| 781 | if (!child) | ||
| 782 | goto out; | ||
| 783 | 752 | ||
| 784 | ret = -EPERM; | 753 | child = ptrace_get_task_struct(pid); |
| 785 | if (pid == 1) /* you may not mess with init */ | 754 | if (IS_ERR(child)) { |
| 755 | ret = PTR_ERR(child); | ||
| 786 | goto out; | 756 | goto out; |
| 757 | } | ||
| 787 | 758 | ||
| 788 | if (request == PTRACE_ATTACH) { | 759 | if (request == PTRACE_ATTACH) { |
| 789 | ret = ptrace_attach(child); | 760 | ret = ptrace_attach(child); |
