]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
kill PT_ATTACHED
authorOleg Nesterov <oleg@tv-sign.ru>
Fri, 8 Feb 2008 12:18:58 +0000 (04:18 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Fri, 8 Feb 2008 17:22:26 +0000 (09:22 -0800)
Since the patch

"Fix ptrace_attach()/ptrace_traceme()/de_thread() race"
commit f5b40e363ad6041a96e3da32281d8faa191597b9

we set PT_ATTACHED and change child->parent "atomically" wrt task_list lock.

This means we can remove the checks like "PT_ATTACHED && ->parent != ptracer"
which were needed to catch the "ptrace attach is in progress" case.  We can
also remove the flag itself since nobody else uses it.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Acked-by: Roland McGrath <roland@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/ptrace.h
kernel/exit.c
kernel/ptrace.c
kernel/signal.c

index 6ab80714a9169c67ae116b5e4b0ae9aaceb4620e..ebe0c17039cf0f8dec6d6207da29052463a610d3 100644 (file)
@@ -67,7 +67,6 @@
 #define PT_TRACE_EXEC  0x00000080
 #define PT_TRACE_VFORK_DONE    0x00000100
 #define PT_TRACE_EXIT  0x00000200
-#define PT_ATTACHED    0x00000400      /* parent != real_parent */
 
 #define PT_TRACE_MASK  0x000003f4
 
index eb9934a82fc1a900f29eb751e520603b82f2492f..1f2c15297f2dfb6d8151bd0e19841161c5b49362 100644 (file)
@@ -1514,18 +1514,7 @@ static int wait_task_continued(struct task_struct *p, int noreap,
 
 static inline int my_ptrace_child(struct task_struct *p)
 {
-       if (!(p->ptrace & PT_PTRACED))
-               return 0;
-       if (!(p->ptrace & PT_ATTACHED))
-               return 1;
-       /*
-        * This child was PTRACE_ATTACH'd.  We should be seeing it only if
-        * we are the attacher.  If we are the real parent, this is a race
-        * inside ptrace_attach.  It is waiting for the tasklist_lock,
-        * which we have to switch the parent links, but has already set
-        * the flags in p->ptrace.
-        */
-       return (p->parent != p->real_parent);
+       return p->ptrace & PT_PTRACED;
 }
 
 static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
index 628b03ab88a579c52f9c802440e768c4752ab957..2dc00298e678fbd77016505490f197e56a02a830 100644 (file)
@@ -100,8 +100,7 @@ int ptrace_check_attach(struct task_struct *child, int kill)
         */
        read_lock(&tasklist_lock);
        if ((child->ptrace & PT_PTRACED) && child->parent == current &&
-           (!(child->ptrace & PT_ATTACHED) || child->real_parent != current)
-           && child->signal != NULL) {
+            child->signal != NULL) {
                ret = 0;
                spin_lock_irq(&child->sighand->siglock);
                if (task_is_stopped(child))
@@ -200,8 +199,7 @@ repeat:
                goto bad;
 
        /* Go */
-       task->ptrace |= PT_PTRACED | ((task->real_parent != current)
-                                     ? PT_ATTACHED : 0);
+       task->ptrace |= PT_PTRACED;
        if (capable(CAP_SYS_PTRACE))
                task->ptrace |= PT_PTRACE_CAP;
 
index 5d30ff5618475273c60e6aeb59e7cf092603b9a4..6d6d1ab39e7e3f7dbeea0800a59e336bf4865137 100644 (file)
@@ -1556,11 +1556,6 @@ static inline int may_ptrace_stop(void)
 {
        if (!likely(current->ptrace & PT_PTRACED))
                return 0;
-
-       if (unlikely(current->parent == current->real_parent &&
-                   (current->ptrace & PT_ATTACHED)))
-               return 0;
-
        /*
         * Are we in the middle of do_coredump?
         * If so and our tracer is also part of the coredump stopping