aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel
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/i386/kernel
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/i386/kernel')
-rw-r--r--arch/i386/kernel/ptrace.c44
1 files changed, 2 insertions, 42 deletions
diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c
index efd11f09c996..5ffbb4b7ad05 100644
--- a/arch/i386/kernel/ptrace.c
+++ b/arch/i386/kernel/ptrace.c
@@ -354,49 +354,12 @@ ptrace_set_thread_area(struct task_struct *child,
354 return 0; 354 return 0;
355} 355}
356 356
357asmlinkage long sys_ptrace(long request, long pid, long addr, long data) 357long arch_ptrace(struct task_struct *child, long request, long addr, long data)
358{ 358{
359 struct task_struct *child;
360 struct user * dummy = NULL; 359 struct user * dummy = NULL;
361 int i, ret; 360 int i, ret;
362 unsigned long __user *datap = (unsigned long __user *)data; 361 unsigned long __user *datap = (unsigned long __user *)data;
363 362
364 lock_kernel();
365 ret = -EPERM;
366 if (request == PTRACE_TRACEME) {
367 /* are we already being traced? */
368 if (current->ptrace & PT_PTRACED)
369 goto out;
370 ret = security_ptrace(current->parent, current);
371 if (ret)
372 goto out;
373 /* set the ptrace bit in the process flags. */
374 current->ptrace |= PT_PTRACED;
375 ret = 0;
376 goto out;
377 }
378 ret = -ESRCH;
379 read_lock(&tasklist_lock);
380 child = find_task_by_pid(pid);
381 if (child)
382 get_task_struct(child);
383 read_unlock(&tasklist_lock);
384 if (!child)
385 goto out;
386
387 ret = -EPERM;
388 if (pid == 1) /* you may not mess with init */
389 goto out_tsk;
390
391 if (request == PTRACE_ATTACH) {
392 ret = ptrace_attach(child);
393 goto out_tsk;
394 }
395
396 ret = ptrace_check_attach(child, request == PTRACE_KILL);
397 if (ret < 0)
398 goto out_tsk;
399
400 switch (request) { 363 switch (request) {
401 /* when I and D space are separate, these will need to be fixed. */ 364 /* when I and D space are separate, these will need to be fixed. */
402 case PTRACE_PEEKTEXT: /* read word at location addr. */ 365 case PTRACE_PEEKTEXT: /* read word at location addr. */
@@ -663,10 +626,7 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data)
663 ret = ptrace_request(child, request, addr, data); 626 ret = ptrace_request(child, request, addr, data);
664 break; 627 break;
665 } 628 }
666out_tsk: 629 out_tsk:
667 put_task_struct(child);
668out:
669 unlock_kernel();
670 return ret; 630 return ret;
671} 631}
672 632