Merge tag 'md/4.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md
[GitHub/MotorolaMobilityLLC/kernel-slsi.git] / kernel / pid_namespace.c
index de461aa0bf9acc933254d34ae2ced925f45eefbc..74a5a7255b4d9cb473cc7708d851c64402cca942 100644 (file)
@@ -277,7 +277,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
         * if reparented.
         */
        for (;;) {
-               set_current_state(TASK_UNINTERRUPTIBLE);
+               set_current_state(TASK_INTERRUPTIBLE);
                if (pid_ns->nr_hashed == init_pids)
                        break;
                schedule();
@@ -374,6 +374,29 @@ static struct ns_common *pidns_get(struct task_struct *task)
        return ns ? &ns->ns : NULL;
 }
 
+static struct ns_common *pidns_for_children_get(struct task_struct *task)
+{
+       struct pid_namespace *ns = NULL;
+
+       task_lock(task);
+       if (task->nsproxy) {
+               ns = task->nsproxy->pid_ns_for_children;
+               get_pid_ns(ns);
+       }
+       task_unlock(task);
+
+       if (ns) {
+               read_lock(&tasklist_lock);
+               if (!ns->child_reaper) {
+                       put_pid_ns(ns);
+                       ns = NULL;
+               }
+               read_unlock(&tasklist_lock);
+       }
+
+       return ns ? &ns->ns : NULL;
+}
+
 static void pidns_put(struct ns_common *ns)
 {
        put_pid_ns(to_pid_ns(ns));
@@ -443,6 +466,17 @@ const struct proc_ns_operations pidns_operations = {
        .get_parent     = pidns_get_parent,
 };
 
+const struct proc_ns_operations pidns_for_children_operations = {
+       .name           = "pid_for_children",
+       .real_ns_name   = "pid",
+       .type           = CLONE_NEWPID,
+       .get            = pidns_for_children_get,
+       .put            = pidns_put,
+       .install        = pidns_install,
+       .owner          = pidns_owner,
+       .get_parent     = pidns_get_parent,
+};
+
 static __init int pid_namespaces_init(void)
 {
        pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC);