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/s390/kernel | |
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/s390/kernel')
-rw-r--r-- | arch/s390/kernel/ptrace.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c index 8ecda6d66de4..cc02232aa96e 100644 --- a/arch/s390/kernel/ptrace.c +++ b/arch/s390/kernel/ptrace.c | |||
@@ -712,35 +712,18 @@ sys_ptrace(long request, long pid, long addr, long data) | |||
712 | int ret; | 712 | int ret; |
713 | 713 | ||
714 | lock_kernel(); | 714 | lock_kernel(); |
715 | |||
716 | if (request == PTRACE_TRACEME) { | 715 | if (request == PTRACE_TRACEME) { |
717 | /* are we already being traced? */ | 716 | ret = ptrace_traceme(); |
718 | ret = -EPERM; | 717 | goto out; |
719 | if (current->ptrace & PT_PTRACED) | ||
720 | goto out; | ||
721 | ret = security_ptrace(current->parent, current); | ||
722 | if (ret) | ||
723 | goto out; | ||
724 | /* set the ptrace bit in the process flags. */ | ||
725 | current->ptrace |= PT_PTRACED; | ||
726 | goto out; | ||
727 | } | 718 | } |
728 | 719 | ||
729 | ret = -EPERM; | 720 | child = ptrace_get_task_struct(pid); |
730 | if (pid == 1) /* you may not mess with init */ | 721 | if (IS_ERR(child)) { |
731 | goto out; | 722 | ret = PTR_ERR(child); |
732 | |||
733 | ret = -ESRCH; | ||
734 | read_lock(&tasklist_lock); | ||
735 | child = find_task_by_pid(pid); | ||
736 | if (child) | ||
737 | get_task_struct(child); | ||
738 | read_unlock(&tasklist_lock); | ||
739 | if (!child) | ||
740 | goto out; | 723 | goto out; |
724 | } | ||
741 | 725 | ||
742 | ret = do_ptrace(child, request, addr, data); | 726 | ret = do_ptrace(child, request, addr, data); |
743 | |||
744 | put_task_struct(child); | 727 | put_task_struct(child); |
745 | out: | 728 | out: |
746 | unlock_kernel(); | 729 | unlock_kernel(); |