On a CLONE_THREAD, target->real_parent == current->real_parent and not
current. New threads would loop forever here.

Fix utrace_attach_delay() to work correctly with new threads.

Signed-off-by: Ananth N Mavinakayanahalli <ana...@in.ibm.com>
---
 kernel/utrace.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: utrace-6mar/kernel/utrace.c
===================================================================
--- utrace-6mar.orig/kernel/utrace.c
+++ utrace-6mar/kernel/utrace.c
@@ -123,12 +123,15 @@ static inline bool exclude_utrace(struct
  */
 static inline int utrace_attach_delay(struct task_struct *target)
 {
-       if ((target->flags & PF_STARTING) && target->real_parent != current)
-               do {
-                       schedule_timeout_interruptible(1);
-                       if (signal_pending(current))
-                               return -ERESTARTNOINTR;
-               } while (target->flags & PF_STARTING);
+       if ((target->flags & PF_STARTING) && target->real_parent != current) {
+               if (target->real_parent != current->real_parent) {
+                       do {
+                               schedule_timeout_interruptible(1);
+                               if (signal_pending(current))
+                                       return -ERESTARTNOINTR;
+                       } while (target->flags & PF_STARTING);
+               }
+       }
 
        return 0;
 }

Reply via email to