aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/ia32
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2006-01-08 04:02:33 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-08 23:13:51 -0500
commit6b9c7ed84837753a436415097063232422e29a35 (patch)
tree6ad59a7bebcec359e08b3a211701781db819450d /arch/x86_64/ia32
parent6b34350f490b2c8508717541ec1fd2bbaadded94 (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/x86_64/ia32')
-rw-r--r--arch/x86_64/ia32/ptrace32.c44
1 files changed, 11 insertions, 33 deletions
diff --git a/arch/x86_64/ia32/ptrace32.c b/arch/x86_64/ia32/ptrace32.c
index 2a925e2af390..5f4cdfa56901 100644
--- a/arch/x86_64/ia32/ptrace32.c
+++ b/arch/x86_64/ia32/ptrace32.c
@@ -196,36 +196,6 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
196 196
197#undef R32 197#undef R32
198 198
199static struct task_struct *find_target(int request, int pid, int *err)
200{
201 struct task_struct *child;
202
203 *err = -EPERM;
204 if (pid == 1)
205 return NULL;
206
207 *err = -ESRCH;
208 read_lock(&tasklist_lock);
209 child = find_task_by_pid(pid);
210 if (child)
211 get_task_struct(child);
212 read_unlock(&tasklist_lock);
213 if (child) {
214 *err = -EPERM;
215 if (child->pid == 1)
216 goto out;
217 *err = ptrace_check_attach(child, request == PTRACE_KILL);
218 if (*err < 0)
219 goto out;
220 return child;
221 }
222 out:
223 if (child)
224 put_task_struct(child);
225 return NULL;
226
227}
228
229asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data) 199asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
230{ 200{
231 struct task_struct *child; 201 struct task_struct *child;
@@ -254,9 +224,16 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
254 break; 224 break;
255 } 225 }
256 226
257 child = find_target(request, pid, &ret); 227 if (request == PTRACE_TRACEME)
258 if (!child) 228 return ptrace_traceme();
259 return ret; 229
230 child = ptrace_get_task_struct(pid);
231 if (IS_ERR(child))
232 return PTR_ERR(child);
233
234 ret = ptrace_check_attach(child, request == PTRACE_KILL);
235 if (ret < 0)
236 goto out;
260 237
261 childregs = (struct pt_regs *)(child->thread.rsp0 - sizeof(struct pt_regs)); 238 childregs = (struct pt_regs *)(child->thread.rsp0 - sizeof(struct pt_regs));
262 239
@@ -373,6 +350,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
373 break; 350 break;
374 } 351 }
375 352
353 out:
376 put_task_struct(child); 354 put_task_struct(child);
377 return ret; 355 return ret;
378} 356}