userns: Document what the invariant required for safe unprivileged mappings.
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 5 Dec 2014 23:51:47 +0000 (17:51 -0600)
committersungmin ha <sungmin82.ha@samsung.com>
Wed, 18 Mar 2015 04:51:57 +0000 (13:51 +0900)
The rule is simple.  Don't allow anything that wouldn't be allowed
without unprivileged mappings.

It was previously overlooked that establishing gid mappings would
allow dropping groups and potentially gaining permission to files and
directories that had lesser permissions for a specific group than for
all other users.

This is the rule needed to fix CVE-2014-8989 and prevent any other
security issues with new_idmap_permitted.

The reason for this rule is that the unix permission model is old and
there are programs out there somewhere that take advantage of every
little corner of it.  So allowing a uid or gid mapping to be
established without privielge that would allow anything that would not
be allowed without that mapping will result in expectations from some
code somewhere being violated.  Violated expectations about the
behavior of the OS is a long way to say a security issue.

Change-Id: Ie252e664106ad68dd27602af46436c32b6539361
Cc: stable@vger.kernel.org
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
kernel/user_namespace.c

index 13fb1134ba582e49c8aa3643feada72a2b0dae8b..eef9c004abc18bf6d16bbd431b669d90b5d64e5d 100644 (file)
@@ -799,7 +799,9 @@ static bool new_idmap_permitted(const struct file *file,
                                struct user_namespace *ns, int cap_setid,
                                struct uid_gid_map *new_map)
 {
-       /* Allow mapping to your own filesystem ids */
+       /* Don't allow mappings that would allow anything that wouldn't
+        * be allowed without the establishment of unprivileged mappings.
+        */
        if ((new_map->nr_extents == 1) && (new_map->extent[0].count == 1)) {
                u32 id = new_map->extent[0].lower_first;
                if (cap_setid == CAP_SETUID) {