x86/smpboot: Init apic mapping before usage
[cascardo/linux.git] / kernel / nsproxy.c
index 49746c8..782102e 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/proc_ns.h>
 #include <linux/file.h>
 #include <linux/syscalls.h>
+#include <linux/cgroup.h>
 
 static struct kmem_cache *nsproxy_cachep;
 
@@ -39,6 +40,9 @@ struct nsproxy init_nsproxy = {
 #ifdef CONFIG_NET
        .net_ns                 = &init_net,
 #endif
+#ifdef CONFIG_CGROUPS
+       .cgroup_ns              = &init_cgroup_ns,
+#endif
 };
 
 static inline struct nsproxy *create_nsproxy(void)
@@ -92,6 +96,13 @@ static struct nsproxy *create_new_namespaces(unsigned long flags,
                goto out_pid;
        }
 
+       new_nsp->cgroup_ns = copy_cgroup_ns(flags, user_ns,
+                                           tsk->nsproxy->cgroup_ns);
+       if (IS_ERR(new_nsp->cgroup_ns)) {
+               err = PTR_ERR(new_nsp->cgroup_ns);
+               goto out_cgroup;
+       }
+
        new_nsp->net_ns = copy_net_ns(flags, user_ns, tsk->nsproxy->net_ns);
        if (IS_ERR(new_nsp->net_ns)) {
                err = PTR_ERR(new_nsp->net_ns);
@@ -101,6 +112,8 @@ static struct nsproxy *create_new_namespaces(unsigned long flags,
        return new_nsp;
 
 out_net:
+       put_cgroup_ns(new_nsp->cgroup_ns);
+out_cgroup:
        if (new_nsp->pid_ns_for_children)
                put_pid_ns(new_nsp->pid_ns_for_children);
 out_pid:
@@ -128,7 +141,8 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)
        struct nsproxy *new_ns;
 
        if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
-                             CLONE_NEWPID | CLONE_NEWNET)))) {
+                             CLONE_NEWPID | CLONE_NEWNET |
+                             CLONE_NEWCGROUP)))) {
                get_nsproxy(old_ns);
                return 0;
        }
@@ -165,6 +179,7 @@ void free_nsproxy(struct nsproxy *ns)
                put_ipc_ns(ns->ipc_ns);
        if (ns->pid_ns_for_children)
                put_pid_ns(ns->pid_ns_for_children);
+       put_cgroup_ns(ns->cgroup_ns);
        put_net(ns->net_ns);
        kmem_cache_free(nsproxy_cachep, ns);
 }
@@ -180,7 +195,7 @@ int unshare_nsproxy_namespaces(unsigned long unshare_flags,
        int err = 0;
 
        if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
-                              CLONE_NEWNET | CLONE_NEWPID)))
+                              CLONE_NEWNET | CLONE_NEWPID | CLONE_NEWCGROUP)))
                return 0;
 
        user_ns = new_cred ? new_cred->user_ns : current_user_ns();