fork(): disable CLONE_PARENT for init
authorSukadev Bhattiprolu <[email protected]>
Wed, 23 Sep 2009 22:57:20 +0000 (15:57 -0700)
committerLinus Torvalds <[email protected]>
Thu, 24 Sep 2009 14:21:04 +0000 (07:21 -0700)
When global or container-init processes use CLONE_PARENT, they create a
multi-rooted process tree.  Besides siblings of global init remain as
zombies on exit since they are not reaped by their parent (swapper).  So
prevent global and container-inits from creating siblings.

Signed-off-by: Sukadev Bhattiprolu <[email protected]>
Acked-by: Eric W. Biederman <[email protected]>
Acked-by: Roland McGrath <[email protected]>
Cc: Oren Laadan <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Serge Hallyn <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
kernel/fork.c

index 51ad0b0b72664ad327c042c33272e90630ec932b..b51fd2ccb2f11b7685db06f1063b7c6a5e030ac9 100644 (file)
@@ -979,6 +979,16 @@ static struct task_struct *copy_process(unsigned long clone_flags,
        if ((clone_flags & CLONE_SIGHAND) && !(clone_flags & CLONE_VM))
                return ERR_PTR(-EINVAL);
 
+       /*
+        * Siblings of global init remain as zombies on exit since they are
+        * not reaped by their parent (swapper). To solve this and to avoid
+        * multi-rooted process trees, prevent global and container-inits
+        * from creating siblings.
+        */
+       if ((clone_flags & CLONE_PARENT) &&
+                               current->signal->flags & SIGNAL_UNKILLABLE)
+               return ERR_PTR(-EINVAL);
+
        retval = security_task_create(clone_flags);
        if (retval)
                goto fork_out;