diff options
author | Tejun Heo <tj@kernel.org> | 2011-06-02 05:13:59 -0400 |
---|---|---|
committer | Oleg Nesterov <oleg@redhat.com> | 2011-06-04 12:17:10 -0400 |
commit | 755e276b3326f300585435d2f3876e66e248c476 (patch) | |
tree | 67ee93cf68a1ee0e307c0d8fcd4514a61dcdd697 /kernel | |
parent | a8f072c1d624a627b67f2ace2f0c25d856ef4e54 (diff) |
ptrace: ptrace_check_attach(): rename @kill to @ignore_state and add comments
PTRACE_INTERRUPT is going to be added which should also skip
task_is_traced() check in ptrace_check_attach(). Rename @kill to
@ignore_state and make it bool. Add function comment while at it.
This patch doesn't introduce any behavior difference.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/ptrace.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 134f34cb142b..eb191116edf7 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -97,10 +97,24 @@ void __ptrace_unlink(struct task_struct *child) | |||
97 | spin_unlock(&child->sighand->siglock); | 97 | spin_unlock(&child->sighand->siglock); |
98 | } | 98 | } |
99 | 99 | ||
100 | /* | 100 | /** |
101 | * Check that we have indeed attached to the thing.. | 101 | * ptrace_check_attach - check whether ptracee is ready for ptrace operation |
102 | * @child: ptracee to check for | ||
103 | * @ignore_state: don't check whether @child is currently %TASK_TRACED | ||
104 | * | ||
105 | * Check whether @child is being ptraced by %current and ready for further | ||
106 | * ptrace operations. If @ignore_state is %false, @child also should be in | ||
107 | * %TASK_TRACED state and on return the child is guaranteed to be traced | ||
108 | * and not executing. If @ignore_state is %true, @child can be in any | ||
109 | * state. | ||
110 | * | ||
111 | * CONTEXT: | ||
112 | * Grabs and releases tasklist_lock and @child->sighand->siglock. | ||
113 | * | ||
114 | * RETURNS: | ||
115 | * 0 on success, -ESRCH if %child is not ready. | ||
102 | */ | 116 | */ |
103 | int ptrace_check_attach(struct task_struct *child, int kill) | 117 | int ptrace_check_attach(struct task_struct *child, bool ignore_state) |
104 | { | 118 | { |
105 | int ret = -ESRCH; | 119 | int ret = -ESRCH; |
106 | 120 | ||
@@ -119,13 +133,13 @@ int ptrace_check_attach(struct task_struct *child, int kill) | |||
119 | */ | 133 | */ |
120 | spin_lock_irq(&child->sighand->siglock); | 134 | spin_lock_irq(&child->sighand->siglock); |
121 | WARN_ON_ONCE(task_is_stopped(child)); | 135 | WARN_ON_ONCE(task_is_stopped(child)); |
122 | if (task_is_traced(child) || kill) | 136 | if (task_is_traced(child) || ignore_state) |
123 | ret = 0; | 137 | ret = 0; |
124 | spin_unlock_irq(&child->sighand->siglock); | 138 | spin_unlock_irq(&child->sighand->siglock); |
125 | } | 139 | } |
126 | read_unlock(&tasklist_lock); | 140 | read_unlock(&tasklist_lock); |
127 | 141 | ||
128 | if (!ret && !kill) | 142 | if (!ret && !ignore_state) |
129 | ret = wait_task_inactive(child, TASK_TRACED) ? 0 : -ESRCH; | 143 | ret = wait_task_inactive(child, TASK_TRACED) ? 0 : -ESRCH; |
130 | 144 | ||
131 | /* All systems go.. */ | 145 | /* All systems go.. */ |