Commit 41c21e351e79004dbb4efa4bc14a53a7e0af38c5

Authored by Andy Lutomirski
1 parent e3211c120a

userns: Changing any namespace id mappings should require privileges

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>

Showing 1 changed file with 3 additions and 3 deletions Side-by-side Diff

kernel/user_namespace.c
... ... @@ -613,10 +613,10 @@
613 613 if (map->nr_extents != 0)
614 614 goto out;
615 615  
616   - /* Require the appropriate privilege CAP_SETUID or CAP_SETGID
617   - * over the user namespace in order to set the id mapping.
  616 + /*
  617 + * Adjusting namespace settings requires capabilities on the target.
618 618 */
619   - if (cap_valid(cap_setid) && !ns_capable(ns, cap_setid))
  619 + if (cap_valid(cap_setid) && !file_ns_capable(file, ns, CAP_SYS_ADMIN))
620 620 goto out;
621 621  
622 622 /* Get a buffer */