diff options
Diffstat (limited to 'arch/i386/kernel/ptrace.c')
-rw-r--r-- | arch/i386/kernel/ptrace.c | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c index efd11f09c996..5ffbb4b7ad05 100644 --- a/arch/i386/kernel/ptrace.c +++ b/arch/i386/kernel/ptrace.c | |||
@@ -354,49 +354,12 @@ ptrace_set_thread_area(struct task_struct *child, | |||
354 | return 0; | 354 | return 0; |
355 | } | 355 | } |
356 | 356 | ||
357 | asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | 357 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
358 | { | 358 | { |
359 | struct task_struct *child; | ||
360 | struct user * dummy = NULL; | 359 | struct user * dummy = NULL; |
361 | int i, ret; | 360 | int i, ret; |
362 | unsigned long __user *datap = (unsigned long __user *)data; | 361 | unsigned long __user *datap = (unsigned long __user *)data; |
363 | 362 | ||
364 | lock_kernel(); | ||
365 | ret = -EPERM; | ||
366 | if (request == PTRACE_TRACEME) { | ||
367 | /* are we already being traced? */ | ||
368 | if (current->ptrace & PT_PTRACED) | ||
369 | goto out; | ||
370 | ret = security_ptrace(current->parent, current); | ||
371 | if (ret) | ||
372 | goto out; | ||
373 | /* set the ptrace bit in the process flags. */ | ||
374 | current->ptrace |= PT_PTRACED; | ||
375 | ret = 0; | ||
376 | goto out; | ||
377 | } | ||
378 | ret = -ESRCH; | ||
379 | read_lock(&tasklist_lock); | ||
380 | child = find_task_by_pid(pid); | ||
381 | if (child) | ||
382 | get_task_struct(child); | ||
383 | read_unlock(&tasklist_lock); | ||
384 | if (!child) | ||
385 | goto out; | ||
386 | |||
387 | ret = -EPERM; | ||
388 | if (pid == 1) /* you may not mess with init */ | ||
389 | goto out_tsk; | ||
390 | |||
391 | if (request == PTRACE_ATTACH) { | ||
392 | ret = ptrace_attach(child); | ||
393 | goto out_tsk; | ||
394 | } | ||
395 | |||
396 | ret = ptrace_check_attach(child, request == PTRACE_KILL); | ||
397 | if (ret < 0) | ||
398 | goto out_tsk; | ||
399 | |||
400 | switch (request) { | 363 | switch (request) { |
401 | /* when I and D space are separate, these will need to be fixed. */ | 364 | /* when I and D space are separate, these will need to be fixed. */ |
402 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 365 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
@@ -663,10 +626,7 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | |||
663 | ret = ptrace_request(child, request, addr, data); | 626 | ret = ptrace_request(child, request, addr, data); |
664 | break; | 627 | break; |
665 | } | 628 | } |
666 | out_tsk: | 629 | out_tsk: |
667 | put_task_struct(child); | ||
668 | out: | ||
669 | unlock_kernel(); | ||
670 | return ret; | 630 | return ret; |
671 | } | 631 | } |
672 | 632 | ||