diff options
Diffstat (limited to 'kernel/nsproxy.c')
| -rw-r--r-- | kernel/nsproxy.c | 19 | 
1 files changed, 17 insertions, 2 deletions
| diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index 49746c81ad8d..782102e59eed 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -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(); | 
