diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/fork.c | 3 | ||||
-rw-r--r-- | kernel/nsproxy.c | 15 |
2 files changed, 15 insertions, 3 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 33f12f48684a..5e67f90a1694 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1608,7 +1608,8 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) | |||
1608 | err = -EINVAL; | 1608 | err = -EINVAL; |
1609 | if (unshare_flags & ~(CLONE_THREAD|CLONE_FS|CLONE_NEWNS|CLONE_SIGHAND| | 1609 | if (unshare_flags & ~(CLONE_THREAD|CLONE_FS|CLONE_NEWNS|CLONE_SIGHAND| |
1610 | CLONE_VM|CLONE_FILES|CLONE_SYSVSEM| | 1610 | CLONE_VM|CLONE_FILES|CLONE_SYSVSEM| |
1611 | CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWUSER)) | 1611 | CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWUSER| |
1612 | CLONE_NEWNET)) | ||
1612 | goto bad_unshare_out; | 1613 | goto bad_unshare_out; |
1613 | 1614 | ||
1614 | if ((err = unshare_thread(unshare_flags))) | 1615 | if ((err = unshare_thread(unshare_flags))) |
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index a4fb7d46971f..f1decd21a534 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/mnt_namespace.h> | 20 | #include <linux/mnt_namespace.h> |
21 | #include <linux/utsname.h> | 21 | #include <linux/utsname.h> |
22 | #include <linux/pid_namespace.h> | 22 | #include <linux/pid_namespace.h> |
23 | #include <net/net_namespace.h> | ||
23 | 24 | ||
24 | static struct kmem_cache *nsproxy_cachep; | 25 | static struct kmem_cache *nsproxy_cachep; |
25 | 26 | ||
@@ -98,8 +99,17 @@ static struct nsproxy *create_new_namespaces(unsigned long flags, | |||
98 | goto out_user; | 99 | goto out_user; |
99 | } | 100 | } |
100 | 101 | ||
102 | new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns); | ||
103 | if (IS_ERR(new_nsp->net_ns)) { | ||
104 | err = PTR_ERR(new_nsp->net_ns); | ||
105 | goto out_net; | ||
106 | } | ||
107 | |||
101 | return new_nsp; | 108 | return new_nsp; |
102 | 109 | ||
110 | out_net: | ||
111 | if (new_nsp->user_ns) | ||
112 | put_user_ns(new_nsp->user_ns); | ||
103 | out_user: | 113 | out_user: |
104 | if (new_nsp->pid_ns) | 114 | if (new_nsp->pid_ns) |
105 | put_pid_ns(new_nsp->pid_ns); | 115 | put_pid_ns(new_nsp->pid_ns); |
@@ -132,7 +142,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) | |||
132 | 142 | ||
133 | get_nsproxy(old_ns); | 143 | get_nsproxy(old_ns); |
134 | 144 | ||
135 | if (!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER))) | 145 | if (!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER | CLONE_NEWNET))) |
136 | return 0; | 146 | return 0; |
137 | 147 | ||
138 | if (!capable(CAP_SYS_ADMIN)) { | 148 | if (!capable(CAP_SYS_ADMIN)) { |
@@ -164,6 +174,7 @@ void free_nsproxy(struct nsproxy *ns) | |||
164 | put_pid_ns(ns->pid_ns); | 174 | put_pid_ns(ns->pid_ns); |
165 | if (ns->user_ns) | 175 | if (ns->user_ns) |
166 | put_user_ns(ns->user_ns); | 176 | put_user_ns(ns->user_ns); |
177 | put_net(ns->net_ns); | ||
167 | kmem_cache_free(nsproxy_cachep, ns); | 178 | kmem_cache_free(nsproxy_cachep, ns); |
168 | } | 179 | } |
169 | 180 | ||
@@ -177,7 +188,7 @@ int unshare_nsproxy_namespaces(unsigned long unshare_flags, | |||
177 | int err = 0; | 188 | int err = 0; |
178 | 189 | ||
179 | if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | | 190 | if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | |
180 | CLONE_NEWUSER))) | 191 | CLONE_NEWUSER | CLONE_NEWNET))) |
181 | return 0; | 192 | return 0; |
182 | 193 | ||
183 | if (!capable(CAP_SYS_ADMIN)) | 194 | if (!capable(CAP_SYS_ADMIN)) |