aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/ptrace.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2005-11-07 03:59:47 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 10:53:42 -0500
commit481bed454247538e9f57d4ea37b153ccba24ba7b (patch)
treebb4198296962c08dbf52e8f377dc27206f621640 /arch/arm/kernel/ptrace.c
parentdb73e9aa99bf093427b79877f9475392724fd5e5 (diff)
[PATCH] consolidate sys_ptrace()
The sys_ptrace boilerplate code (everything outside the big switch statement for the arch-specific requests) is shared by most architectures. This patch moves it to kernel/ptrace.c and leaves the arch-specific code as arch_ptrace. Some architectures have a too different ptrace so we have to exclude them. They continue to keep their implementations. For sh64 I had to add a sh64_ptrace wrapper because it does some initialization on the first call. For um I removed an ifdefed SUBARCH_PTRACE_SPECIAL block, but SUBARCH_PTRACE_SPECIAL isn't defined anywhere in the tree. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Paul Mackerras <paulus@samba.org> Acked-by: Ralf Baechle <ralf@linux-mips.org> Acked-By: David Howells <dhowells@redhat.com> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/arm/kernel/ptrace.c')
-rw-r--r--arch/arm/kernel/ptrace.c49
1 files changed, 1 insertions, 48 deletions
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index 9bd8609a2926..9a340e790da5 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -648,7 +648,7 @@ static int ptrace_setwmmxregs(struct task_struct *tsk, void __user *ufp)
648 648
649#endif 649#endif
650 650
651static int do_ptrace(int request, struct task_struct *child, long addr, long data) 651long arch_ptrace(struct task_struct *child, long request, long addr, long data)
652{ 652{
653 unsigned long tmp; 653 unsigned long tmp;
654 int ret; 654 int ret;
@@ -782,53 +782,6 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat
782 return ret; 782 return ret;
783} 783}
784 784
785asmlinkage long sys_ptrace(long request, long pid, long addr, long data)
786{
787 struct task_struct *child;
788 int ret;
789
790 lock_kernel();
791 ret = -EPERM;
792 if (request == PTRACE_TRACEME) {
793 /* are we already being traced? */
794 if (current->ptrace & PT_PTRACED)
795 goto out;
796 ret = security_ptrace(current->parent, current);
797 if (ret)
798 goto out;
799 /* set the ptrace bit in the process flags. */
800 current->ptrace |= PT_PTRACED;
801 ret = 0;
802 goto out;
803 }
804 ret = -ESRCH;
805 read_lock(&tasklist_lock);
806 child = find_task_by_pid(pid);
807 if (child)
808 get_task_struct(child);
809 read_unlock(&tasklist_lock);
810 if (!child)
811 goto out;
812
813 ret = -EPERM;
814 if (pid == 1) /* you may not mess with init */
815 goto out_tsk;
816
817 if (request == PTRACE_ATTACH) {
818 ret = ptrace_attach(child);
819 goto out_tsk;
820 }
821 ret = ptrace_check_attach(child, request == PTRACE_KILL);
822 if (ret == 0)
823 ret = do_ptrace(request, child, addr, data);
824
825out_tsk:
826 put_task_struct(child);
827out:
828 unlock_kernel();
829 return ret;
830}
831
832asmlinkage void syscall_trace(int why, struct pt_regs *regs) 785asmlinkage void syscall_trace(int why, struct pt_regs *regs)
833{ 786{
834 unsigned long ip; 787 unsigned long ip;