userns: Don't let unprivileged users trick privileged users into setting the id_map
authorEric W. Biederman <ebiederm@xmission.com>
Sun, 14 Apr 2013 20:47:02 +0000 (13:47 -0700)
committerAndy Lutomirski <luto@amacapital.net>
Mon, 15 Apr 2013 01:11:14 +0000 (18:11 -0700)
commit6708075f104c3c9b04b23336bb0366ca30c3931b
tree4e99cf865cea3d809bfadda9eec45dcf29454bee
parent6c4c4d4bdaff7ec0b7b26da67d741f639727c934
userns: Don't let unprivileged users trick privileged users into setting the id_map

When we require privilege for setting /proc/<pid>/uid_map or
/proc/<pid>/gid_map no longer allow an unprivileged user to
open the file and pass it to a privileged program to write
to the file.

Instead when privilege is required require both the opener and the
writer to have the necessary capabilities.

I have tested this code and verified that setting /proc/<pid>/uid_map
fails when an unprivileged user opens the file and a privielged user
attempts to set the mapping, that unprivileged users can still map
their own id, and that a privileged users can still setup an arbitrary
mapping.

Reported-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
kernel/user_namespace.c