diff options
author | Christoph Hellwig <hch@lst.de> | 2005-11-07 03:59:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-07 10:53:42 -0500 |
commit | 481bed454247538e9f57d4ea37b153ccba24ba7b (patch) | |
tree | bb4198296962c08dbf52e8f377dc27206f621640 /arch/parisc | |
parent | db73e9aa99bf093427b79877f9475392724fd5e5 (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/parisc')
-rw-r--r-- | arch/parisc/kernel/ptrace.c | 50 |
1 files changed, 4 insertions, 46 deletions
diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c index 18130c3748f3..b6fe202a620d 100644 --- a/arch/parisc/kernel/ptrace.c +++ b/arch/parisc/kernel/ptrace.c | |||
@@ -78,52 +78,13 @@ void ptrace_disable(struct task_struct *child) | |||
78 | pa_psw(child)->l = 0; | 78 | pa_psw(child)->l = 0; |
79 | } | 79 | } |
80 | 80 | ||
81 | long sys_ptrace(long request, long pid, long addr, long data) | 81 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
82 | { | 82 | { |
83 | struct task_struct *child; | ||
84 | long ret; | 83 | long ret; |
85 | #ifdef DEBUG_PTRACE | 84 | #ifdef DEBUG_PTRACE |
86 | long oaddr=addr, odata=data; | 85 | long oaddr=addr, odata=data; |
87 | #endif | 86 | #endif |
88 | 87 | ||
89 | lock_kernel(); | ||
90 | ret = -EPERM; | ||
91 | if (request == PTRACE_TRACEME) { | ||
92 | /* are we already being traced? */ | ||
93 | if (current->ptrace & PT_PTRACED) | ||
94 | goto out; | ||
95 | |||
96 | ret = security_ptrace(current->parent, current); | ||
97 | if (ret) | ||
98 | goto out; | ||
99 | |||
100 | /* set the ptrace bit in the process flags. */ | ||
101 | current->ptrace |= PT_PTRACED; | ||
102 | ret = 0; | ||
103 | goto out; | ||
104 | } | ||
105 | |||
106 | ret = -ESRCH; | ||
107 | read_lock(&tasklist_lock); | ||
108 | child = find_task_by_pid(pid); | ||
109 | if (child) | ||
110 | get_task_struct(child); | ||
111 | read_unlock(&tasklist_lock); | ||
112 | if (!child) | ||
113 | goto out; | ||
114 | ret = -EPERM; | ||
115 | if (pid == 1) /* no messing around with init! */ | ||
116 | goto out_tsk; | ||
117 | |||
118 | if (request == PTRACE_ATTACH) { | ||
119 | ret = ptrace_attach(child); | ||
120 | goto out_tsk; | ||
121 | } | ||
122 | |||
123 | ret = ptrace_check_attach(child, request == PTRACE_KILL); | ||
124 | if (ret < 0) | ||
125 | goto out_tsk; | ||
126 | |||
127 | switch (request) { | 88 | switch (request) { |
128 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 89 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
129 | case PTRACE_PEEKDATA: { | 90 | case PTRACE_PEEKDATA: { |
@@ -383,11 +344,11 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
383 | 344 | ||
384 | case PTRACE_GETEVENTMSG: | 345 | case PTRACE_GETEVENTMSG: |
385 | ret = put_user(child->ptrace_message, (unsigned int __user *) data); | 346 | ret = put_user(child->ptrace_message, (unsigned int __user *) data); |
386 | goto out_tsk; | 347 | goto out; |
387 | 348 | ||
388 | default: | 349 | default: |
389 | ret = ptrace_request(child, request, addr, data); | 350 | ret = ptrace_request(child, request, addr, data); |
390 | goto out_tsk; | 351 | goto out; |
391 | } | 352 | } |
392 | 353 | ||
393 | out_wake_notrap: | 354 | out_wake_notrap: |
@@ -396,10 +357,7 @@ out_wake: | |||
396 | wake_up_process(child); | 357 | wake_up_process(child); |
397 | ret = 0; | 358 | ret = 0; |
398 | out_tsk: | 359 | out_tsk: |
399 | put_task_struct(child); | 360 | DBG("arch_ptrace(%ld, %d, %lx, %lx) returning %ld\n", |
400 | out: | ||
401 | unlock_kernel(); | ||
402 | DBG("sys_ptrace(%ld, %d, %lx, %lx) returning %ld\n", | ||
403 | request, pid, oaddr, odata, ret); | 361 | request, pid, oaddr, odata, ret); |
404 | return ret; | 362 | return ret; |
405 | } | 363 | } |