Skip to content

Commit

Permalink
userns: Changing any namespace id mappings should require privileges
Browse files Browse the repository at this point in the history
Changing uid/gid/projid mappings doesn't change your id within the
namespace; it reconfigures the namespace.  Unprivileged programs should
*not* be able to write these files.  (We're also checking the privileges
on the wrong task.)

Given the write-once nature of these files and the other security
checks, this is likely impossible to usefully exploit.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
  • Loading branch information
Andy Lutomirski committed Apr 15, 2013
1 parent e3211c1 commit 41c21e3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/user_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,10 @@ static ssize_t map_write(struct file *file, const char __user *buf,
if (map->nr_extents != 0)
goto out;

/* Require the appropriate privilege CAP_SETUID or CAP_SETGID
* over the user namespace in order to set the id mapping.
/*
* Adjusting namespace settings requires capabilities on the target.
*/
if (cap_valid(cap_setid) && !ns_capable(ns, cap_setid))
if (cap_valid(cap_setid) && !file_ns_capable(file, ns, CAP_SYS_ADMIN))
goto out;

/* Get a buffer */
Expand Down

0 comments on commit 41c21e3

Please sign in to comment.