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/alpha | |
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/alpha')
-rw-r--r-- | arch/alpha/kernel/ptrace.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/arch/alpha/kernel/ptrace.c b/arch/alpha/kernel/ptrace.c index bbd37536d14e..9969d212e94d 100644 --- a/arch/alpha/kernel/ptrace.c +++ b/arch/alpha/kernel/ptrace.c | |||
@@ -265,30 +265,16 @@ do_sys_ptrace(long request, long pid, long addr, long data, | |||
265 | lock_kernel(); | 265 | lock_kernel(); |
266 | DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n", | 266 | DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n", |
267 | request, pid, addr, data)); | 267 | request, pid, addr, data)); |
268 | ret = -EPERM; | ||
269 | if (request == PTRACE_TRACEME) { | 268 | if (request == PTRACE_TRACEME) { |
270 | /* are we already being traced? */ | 269 | ret = ptrace_traceme(); |
271 | if (current->ptrace & PT_PTRACED) | ||
272 | goto out_notsk; | ||
273 | ret = security_ptrace(current->parent, current); | ||
274 | if (ret) | ||
275 | goto out_notsk; | ||
276 | /* set the ptrace bit in the process ptrace flags. */ | ||
277 | current->ptrace |= PT_PTRACED; | ||
278 | ret = 0; | ||
279 | goto out_notsk; | 270 | goto out_notsk; |
280 | } | 271 | } |
281 | if (pid == 1) /* you may not mess with init */ | ||
282 | goto out_notsk; | ||
283 | 272 | ||
284 | ret = -ESRCH; | 273 | child = ptrace_get_task_struct(pid); |
285 | read_lock(&tasklist_lock); | 274 | if (IS_ERR(child)) { |
286 | child = find_task_by_pid(pid); | 275 | ret = PTR_ERR(child); |
287 | if (child) | ||
288 | get_task_struct(child); | ||
289 | read_unlock(&tasklist_lock); | ||
290 | if (!child) | ||
291 | goto out_notsk; | 276 | goto out_notsk; |
277 | } | ||
292 | 278 | ||
293 | if (request == PTRACE_ATTACH) { | 279 | if (request == PTRACE_ATTACH) { |
294 | ret = ptrace_attach(child); | 280 | ret = ptrace_attach(child); |