Skip to content

Commit b33c77e

Browse files
committed
userns: Allow unprivileged users to create new namespaces
If an unprivileged user has the appropriate capabilities in their current user namespace allow the creation of new namespaces. Acked-by: Serge Hallyn <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 37657da commit b33c77e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/nsproxy.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static struct nsproxy *create_new_namespaces(unsigned long flags,
122122
int copy_namespaces(unsigned long flags, struct task_struct *tsk)
123123
{
124124
struct nsproxy *old_ns = tsk->nsproxy;
125+
struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
125126
struct nsproxy *new_ns;
126127
int err = 0;
127128

@@ -134,7 +135,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)
134135
CLONE_NEWPID | CLONE_NEWNET)))
135136
return 0;
136137

137-
if (!capable(CAP_SYS_ADMIN)) {
138+
if (!ns_capable(user_ns, CAP_SYS_ADMIN)) {
138139
err = -EPERM;
139140
goto out;
140141
}
@@ -191,7 +192,7 @@ int unshare_nsproxy_namespaces(unsigned long unshare_flags,
191192
CLONE_NEWNET | CLONE_NEWPID)))
192193
return 0;
193194

194-
if (!capable(CAP_SYS_ADMIN))
195+
if (!nsown_capable(CAP_SYS_ADMIN))
195196
return -EPERM;
196197

197198
*new_nsp = create_new_namespaces(unshare_flags, current,

0 commit comments

Comments
 (0)