Commit e3bd058f authored by Tejun Heo's avatar Tejun Heo

ptrace: Collapse ptrace_untrace() into __ptrace_unlink()

Remove the extra task_is_traced() check in __ptrace_unlink() and
collapse ptrace_untrace() into __ptrace_unlink().  This is to prepare
for further changes.

While at it, drop the comment on top of ptrace_untrace() and convert
__ptrace_unlink() comment to docbook format.  Detailed comment will be
added by the next patch.

This patch doesn't cause any visible behavior changes.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
parent d79fdd6d
...@@ -37,15 +37,23 @@ void __ptrace_link(struct task_struct *child, struct task_struct *new_parent) ...@@ -37,15 +37,23 @@ void __ptrace_link(struct task_struct *child, struct task_struct *new_parent)
child->parent = new_parent; child->parent = new_parent;
} }
/* /**
* Turn a tracing stop into a normal stop now, since with no tracer there * __ptrace_unlink - unlink ptracee and restore its execution state
* would be no way to wake it up with SIGCONT or SIGKILL. If there was a * @child: ptracee to be unlinked
* signal sent that would resume the child, but didn't because it was in *
* TASK_TRACED, resume it now. * Remove @child from the ptrace list, move it back to the original parent.
* Requires that irqs be disabled. *
* CONTEXT:
* write_lock_irq(tasklist_lock)
*/ */
static void ptrace_untrace(struct task_struct *child) void __ptrace_unlink(struct task_struct *child)
{ {
BUG_ON(!child->ptrace);
child->ptrace = 0;
child->parent = child->real_parent;
list_del_init(&child->ptrace_entry);
spin_lock(&child->sighand->siglock); spin_lock(&child->sighand->siglock);
if (task_is_traced(child)) { if (task_is_traced(child)) {
/* /*
...@@ -69,24 +77,6 @@ static void ptrace_untrace(struct task_struct *child) ...@@ -69,24 +77,6 @@ static void ptrace_untrace(struct task_struct *child)
spin_unlock(&child->sighand->siglock); spin_unlock(&child->sighand->siglock);
} }
/*
* unptrace a task: move it back to its original parent and
* remove it from the ptrace list.
*
* Must be called with the tasklist lock write-held.
*/
void __ptrace_unlink(struct task_struct *child)
{
BUG_ON(!child->ptrace);
child->ptrace = 0;
child->parent = child->real_parent;
list_del_init(&child->ptrace_entry);
if (task_is_traced(child))
ptrace_untrace(child);
}
/* /*
* Check that we have indeed attached to the thing.. * Check that we have indeed attached to the thing..
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment