Skip to content

Commit

Permalink
userns: Allow unprivileged users to create new namespaces
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ebiederm committed Nov 20, 2012
1 parent 37657da commit b33c77e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kernel/nsproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ static struct nsproxy *create_new_namespaces(unsigned long flags,
int copy_namespaces(unsigned long flags, struct task_struct *tsk)
{
struct nsproxy *old_ns = tsk->nsproxy;
struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
struct nsproxy *new_ns;
int err = 0;

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

if (!capable(CAP_SYS_ADMIN)) {
if (!ns_capable(user_ns, CAP_SYS_ADMIN)) {
err = -EPERM;
goto out;
}
Expand Down Expand Up @@ -191,7 +192,7 @@ int unshare_nsproxy_namespaces(unsigned long unshare_flags,
CLONE_NEWNET | CLONE_NEWPID)))
return 0;

if (!capable(CAP_SYS_ADMIN))
if (!nsown_capable(CAP_SYS_ADMIN))
return -EPERM;

*new_nsp = create_new_namespaces(unshare_flags, current,
Expand Down

0 comments on commit b33c77e

Please sign in to comment.