diff options
author | Christoph Hellwig <hch@lst.de> | 2006-01-08 04:02:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-08 23:13:51 -0500 |
commit | 6b9c7ed84837753a436415097063232422e29a35 (patch) | |
tree | 6ad59a7bebcec359e08b3a211701781db819450d /arch/sparc64/kernel/ptrace.c | |
parent | 6b34350f490b2c8508717541ec1fd2bbaadded94 (diff) |
[PATCH] use ptrace_get_task_struct in various places
The ptrace_get_task_struct() helper that I added as part of the ptrace
consolidation is useful in variety of places that currently opencode it.
Switch them to the common helpers.
Add a ptrace_traceme() helper that needs to be explicitly called, and simplify
the ptrace_get_task_struct() interface. We don't need the request argument
now, and we return the task_struct directly, using ERR_PTR() for error
returns. It's a bit more code in the callers, but we have two sane routines
that do one thing well now.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/sparc64/kernel/ptrace.c')
-rw-r--r-- | arch/sparc64/kernel/ptrace.c | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/arch/sparc64/kernel/ptrace.c b/arch/sparc64/kernel/ptrace.c index 774ecbb8a031..84d3df2264cb 100644 --- a/arch/sparc64/kernel/ptrace.c +++ b/arch/sparc64/kernel/ptrace.c | |||
@@ -198,39 +198,15 @@ asmlinkage void do_ptrace(struct pt_regs *regs) | |||
198 | } | 198 | } |
199 | #endif | 199 | #endif |
200 | if (request == PTRACE_TRACEME) { | 200 | if (request == PTRACE_TRACEME) { |
201 | int ret; | 201 | ret = ptrace_traceme(); |
202 | |||
203 | /* are we already being traced? */ | ||
204 | if (current->ptrace & PT_PTRACED) { | ||
205 | pt_error_return(regs, EPERM); | ||
206 | goto out; | ||
207 | } | ||
208 | ret = security_ptrace(current->parent, current); | ||
209 | if (ret) { | ||
210 | pt_error_return(regs, -ret); | ||
211 | goto out; | ||
212 | } | ||
213 | |||
214 | /* set the ptrace bit in the process flags. */ | ||
215 | current->ptrace |= PT_PTRACED; | ||
216 | pt_succ_return(regs, 0); | 202 | pt_succ_return(regs, 0); |
217 | goto out; | 203 | goto out; |
218 | } | 204 | } |
219 | #ifndef ALLOW_INIT_TRACING | ||
220 | if (pid == 1) { | ||
221 | /* Can't dork with init. */ | ||
222 | pt_error_return(regs, EPERM); | ||
223 | goto out; | ||
224 | } | ||
225 | #endif | ||
226 | read_lock(&tasklist_lock); | ||
227 | child = find_task_by_pid(pid); | ||
228 | if (child) | ||
229 | get_task_struct(child); | ||
230 | read_unlock(&tasklist_lock); | ||
231 | 205 | ||
232 | if (!child) { | 206 | child = ptrace_get_task_struct(pid); |
233 | pt_error_return(regs, ESRCH); | 207 | if (IS_ERR(child)) { |
208 | ret = PTR_ERR(child); | ||
209 | pt_error_return(regs, -ret); | ||
234 | goto out; | 210 | goto out; |
235 | } | 211 | } |
236 | 212 | ||