diff options
Diffstat (limited to 'arch/x86_64/kernel/ptrace.c')
-rw-r--r-- | arch/x86_64/kernel/ptrace.c | 43 |
1 files changed, 1 insertions, 42 deletions
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c index bbf64b59a21e..a87b6cebe80f 100644 --- a/arch/x86_64/kernel/ptrace.c +++ b/arch/x86_64/kernel/ptrace.c | |||
@@ -313,48 +313,11 @@ static unsigned long getreg(struct task_struct *child, unsigned long regno) | |||
313 | 313 | ||
314 | } | 314 | } |
315 | 315 | ||
316 | asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data) | 316 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
317 | { | 317 | { |
318 | struct task_struct *child; | ||
319 | long i, ret; | 318 | long i, ret; |
320 | unsigned ui; | 319 | unsigned ui; |
321 | 320 | ||
322 | /* This lock_kernel fixes a subtle race with suid exec */ | ||
323 | lock_kernel(); | ||
324 | ret = -EPERM; | ||
325 | if (request == PTRACE_TRACEME) { | ||
326 | /* are we already being traced? */ | ||
327 | if (current->ptrace & PT_PTRACED) | ||
328 | goto out; | ||
329 | ret = security_ptrace(current->parent, current); | ||
330 | if (ret) | ||
331 | goto out; | ||
332 | /* set the ptrace bit in the process flags. */ | ||
333 | current->ptrace |= PT_PTRACED; | ||
334 | ret = 0; | ||
335 | goto out; | ||
336 | } | ||
337 | ret = -ESRCH; | ||
338 | read_lock(&tasklist_lock); | ||
339 | child = find_task_by_pid(pid); | ||
340 | if (child) | ||
341 | get_task_struct(child); | ||
342 | read_unlock(&tasklist_lock); | ||
343 | if (!child) | ||
344 | goto out; | ||
345 | |||
346 | ret = -EPERM; | ||
347 | if (pid == 1) /* you may not mess with init */ | ||
348 | goto out_tsk; | ||
349 | |||
350 | if (request == PTRACE_ATTACH) { | ||
351 | ret = ptrace_attach(child); | ||
352 | goto out_tsk; | ||
353 | } | ||
354 | ret = ptrace_check_attach(child, request == PTRACE_KILL); | ||
355 | if (ret < 0) | ||
356 | goto out_tsk; | ||
357 | |||
358 | switch (request) { | 321 | switch (request) { |
359 | /* when I and D space are separate, these will need to be fixed. */ | 322 | /* when I and D space are separate, these will need to be fixed. */ |
360 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 323 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
@@ -608,10 +571,6 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data | |||
608 | ret = ptrace_request(child, request, addr, data); | 571 | ret = ptrace_request(child, request, addr, data); |
609 | break; | 572 | break; |
610 | } | 573 | } |
611 | out_tsk: | ||
612 | put_task_struct(child); | ||
613 | out: | ||
614 | unlock_kernel(); | ||
615 | return ret; | 574 | return ret; |
616 | } | 575 | } |
617 | 576 | ||