]> git.baikalelectronics.ru Git - kernel.git/commit
userns: also map extents in the reverse map to kernel IDs
authorJann Horn <jannh@google.com>
Mon, 5 Nov 2018 19:55:09 +0000 (20:55 +0100)
committerEric W. Biederman <ebiederm@xmission.com>
Thu, 8 Nov 2018 05:51:16 +0000 (23:51 -0600)
commit12e650fc04501fd4abf7e21805b78af1ac975dc7
tree9720c07318f1c5591dd3fb67a9bfdc80efc1f2da
parentf630c74755763954e46ada22cb887770a3c4fdd4
userns: also map extents in the reverse map to kernel IDs

The current logic first clones the extent array and sorts both copies, then
maps the lower IDs of the forward mapping into the lower namespace, but
doesn't map the lower IDs of the reverse mapping.

This means that code in a nested user namespace with >5 extents will see
incorrect IDs. It also breaks some access checks, like
inode_owner_or_capable() and privileged_wrt_inode_uidgid(), so a process
can incorrectly appear to be capable relative to an inode.

To fix it, we have to make sure that the "lower_first" members of extents
in both arrays are translated; and we have to make sure that the reverse
map is sorted *after* the translation (since otherwise the translation can
break the sorting).

This is CVE-2018-18955.

Fixes: 6ae1479669e7 ("userns: bump idmap limits to 340")
Cc: stable@vger.kernel.org
Signed-off-by: Jann Horn <jannh@google.com>
Tested-by: Eric W. Biederman <ebiederm@xmission.com>
Reviewed-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
kernel/user_namespace.c