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/powerpc/kernel/ptrace32.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/powerpc/kernel/ptrace32.c')
-rw-r--r-- | arch/powerpc/kernel/ptrace32.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/arch/powerpc/kernel/ptrace32.c b/arch/powerpc/kernel/ptrace32.c index 61762640b877..826ee3d056de 100644 --- a/arch/powerpc/kernel/ptrace32.c +++ b/arch/powerpc/kernel/ptrace32.c | |||
@@ -45,33 +45,19 @@ long compat_sys_ptrace(int request, int pid, unsigned long addr, | |||
45 | unsigned long data) | 45 | unsigned long data) |
46 | { | 46 | { |
47 | struct task_struct *child; | 47 | struct task_struct *child; |
48 | int ret = -EPERM; | 48 | int ret; |
49 | 49 | ||
50 | lock_kernel(); | 50 | lock_kernel(); |
51 | if (request == PTRACE_TRACEME) { | 51 | if (request == PTRACE_TRACEME) { |
52 | /* are we already being traced? */ | 52 | ret = ptrace_traceme(); |
53 | if (current->ptrace & PT_PTRACED) | ||
54 | goto out; | ||
55 | ret = security_ptrace(current->parent, current); | ||
56 | if (ret) | ||
57 | goto out; | ||
58 | /* set the ptrace bit in the process flags. */ | ||
59 | current->ptrace |= PT_PTRACED; | ||
60 | ret = 0; | ||
61 | goto out; | 53 | goto out; |
62 | } | 54 | } |
63 | ret = -ESRCH; | ||
64 | read_lock(&tasklist_lock); | ||
65 | child = find_task_by_pid(pid); | ||
66 | if (child) | ||
67 | get_task_struct(child); | ||
68 | read_unlock(&tasklist_lock); | ||
69 | if (!child) | ||
70 | goto out; | ||
71 | 55 | ||
72 | ret = -EPERM; | 56 | child = ptrace_get_task_struct(pid); |
73 | if (pid == 1) /* you may not mess with init */ | 57 | if (IS_ERR(child)) { |
74 | goto out_tsk; | 58 | ret = PTR_ERR(child); |
59 | goto out; | ||
60 | } | ||
75 | 61 | ||
76 | if (request == PTRACE_ATTACH) { | 62 | if (request == PTRACE_ATTACH) { |
77 | ret = ptrace_attach(child); | 63 | ret = ptrace_attach(child); |