]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] de_thread: Don't change our parents and ptrace flags.
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 14 Apr 2006 10:05:55 +0000 (04:05 -0600)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 14 Apr 2006 15:49:19 +0000 (08:49 -0700)
This is two distinct changes.
 - Not changing our real parents.
 - Not changing our ptrace parents.

Not changing our real parents is trivially correct because both tasks
have the same real parents as they are part of a thread group.  Now that
we demote the leader to a thread there is no longer any reason to change
it's parentage.

Not changing our ptrace parents is a user visible change if someone
looks hard enough.  I don't think user space applications will care or
even notice.

In the practical and I think common case a debugger will have attached
to all of the threads using the same ptrace flags.  From my quick skim
of strace and gdb that appears to be the case.  Which if true means
debuggers will not notice a change.

Before this point we have already generated a ptrace event in do_exit
that reports the leaders pid has died so de_thread is visible to a
debugger.  Which means attempting to hide this case by copying flags
around appears excessive.

By not doing anything it avoids all of the weird locking issues between
de_thread and ptrace attach, and removes one case from consideration for
fixing the ptrace locking.

This only addresses Oleg's first concern with ptrace_attach, that of the
problems caused by reparenting.  Oleg's second concern is essentially a
race between ptrace_attach and release_task that causes an oops when we
get to force_sig_specific.  There is nothing special about de_thread
with respect to that race.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/exec.c

index 3234a0c32d5405bdfd8f46f97cd97994e93828ee..4121bb55973933b8a407c6969edba4094dad8022 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -665,9 +665,7 @@ static int de_thread(struct task_struct *tsk)
         * and to assume its PID:
         */
        if (!thread_group_leader(current)) {
-               struct task_struct *parent;
                struct dentry *proc_dentry1, *proc_dentry2;
-               unsigned long ptrace;
 
                /*
                 * Wait for the thread group leader to be a zombie.
@@ -704,22 +702,6 @@ static int de_thread(struct task_struct *tsk)
                 * two threads with a switched PID, and release
                 * the former thread group leader:
                 */
-               ptrace = leader->ptrace;
-               parent = leader->parent;
-               if (unlikely(ptrace) && unlikely(parent == current)) {
-                       /*
-                        * Joker was ptracing his own group leader,
-                        * and now he wants to be his own parent!
-                        * We can't have that.
-                        */
-                       ptrace = 0;
-               }
-
-               ptrace_unlink(current);
-               ptrace_unlink(leader);
-               remove_parent(current);
-               remove_parent(leader);
-
 
                /* Become a process group leader with the old leader's pid.
                 * Note: The old leader also uses thispid until release_task
@@ -732,8 +714,6 @@ static int de_thread(struct task_struct *tsk)
                attach_pid(current, PIDTYPE_SID,  current->signal->session);
                list_add_tail(&current->tasks, &init_task.tasks);
 
-               current->parent = current->real_parent = leader->real_parent;
-               leader->parent = leader->real_parent = child_reaper;
                current->group_leader = current;
                leader->group_leader = current;
 
@@ -742,13 +722,6 @@ static int de_thread(struct task_struct *tsk)
                detach_pid(leader, PIDTYPE_SID);
                list_del_init(&leader->tasks);
 
-               add_parent(current);
-               add_parent(leader);
-               if (ptrace) {
-                       current->ptrace = ptrace;
-                       __ptrace_link(current, parent);
-               }
-
                current->exit_signal = SIGCHLD;
 
                BUG_ON(leader->exit_state != EXIT_ZOMBIE);