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/um/kernel | |
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/um/kernel')
-rw-r--r-- | arch/um/kernel/ptrace.c | 50 |
1 files changed, 2 insertions, 48 deletions
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c index 71af4d503899..98e09395c093 100644 --- a/arch/um/kernel/ptrace.c +++ b/arch/um/kernel/ptrace.c | |||
@@ -43,53 +43,10 @@ void ptrace_disable(struct task_struct *child) | |||
43 | extern int peek_user(struct task_struct * child, long addr, long data); | 43 | extern int peek_user(struct task_struct * child, long addr, long data); |
44 | extern int poke_user(struct task_struct * child, long addr, long data); | 44 | extern int poke_user(struct task_struct * child, long addr, long data); |
45 | 45 | ||
46 | long sys_ptrace(long request, long pid, long addr, long data) | 46 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
47 | { | 47 | { |
48 | struct task_struct *child; | ||
49 | int i, ret; | 48 | int i, ret; |
50 | 49 | ||
51 | lock_kernel(); | ||
52 | ret = -EPERM; | ||
53 | if (request == PTRACE_TRACEME) { | ||
54 | /* are we already being traced? */ | ||
55 | if (current->ptrace & PT_PTRACED) | ||
56 | goto out; | ||
57 | |||
58 | ret = security_ptrace(current->parent, current); | ||
59 | if (ret) | ||
60 | goto out; | ||
61 | |||
62 | /* set the ptrace bit in the process flags. */ | ||
63 | current->ptrace |= PT_PTRACED; | ||
64 | ret = 0; | ||
65 | goto out; | ||
66 | } | ||
67 | ret = -ESRCH; | ||
68 | read_lock(&tasklist_lock); | ||
69 | child = find_task_by_pid(pid); | ||
70 | if (child) | ||
71 | get_task_struct(child); | ||
72 | read_unlock(&tasklist_lock); | ||
73 | if (!child) | ||
74 | goto out; | ||
75 | |||
76 | ret = -EPERM; | ||
77 | if (pid == 1) /* you may not mess with init */ | ||
78 | goto out_tsk; | ||
79 | |||
80 | if (request == PTRACE_ATTACH) { | ||
81 | ret = ptrace_attach(child); | ||
82 | goto out_tsk; | ||
83 | } | ||
84 | |||
85 | #ifdef SUBACH_PTRACE_SPECIAL | ||
86 | SUBARCH_PTRACE_SPECIAL(child,request,addr,data); | ||
87 | #endif | ||
88 | |||
89 | ret = ptrace_check_attach(child, request == PTRACE_KILL); | ||
90 | if (ret < 0) | ||
91 | goto out_tsk; | ||
92 | |||
93 | switch (request) { | 50 | switch (request) { |
94 | /* when I and D space are separate, these will need to be fixed. */ | 51 | /* when I and D space are separate, these will need to be fixed. */ |
95 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 52 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
@@ -282,10 +239,7 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
282 | ret = ptrace_request(child, request, addr, data); | 239 | ret = ptrace_request(child, request, addr, data); |
283 | break; | 240 | break; |
284 | } | 241 | } |
285 | out_tsk: | 242 | |
286 | put_task_struct(child); | ||
287 | out: | ||
288 | unlock_kernel(); | ||
289 | return ret; | 243 | return ret; |
290 | } | 244 | } |
291 | 245 | ||