]> git.baikalelectronics.ru Git - kernel.git/commit
nsfs: Add an ioctl() to return owner UID of a userns
authorMichael Kerrisk (man-pages) <mtk.manpages@gmail.com>
Wed, 25 Jan 2017 01:04:15 +0000 (14:04 +1300)
committerEric W. Biederman <ebiederm@xmission.com>
Fri, 3 Feb 2017 01:35:43 +0000 (14:35 +1300)
commitc403a15a369233b77d211a760507e4da8eb43f22
tree17b13fb4290e9e4af97b1557b35d57fbb8099103
parente4835ffe11de028b08e723992dc7fe72a2fc2465
nsfs: Add an ioctl() to return owner UID of a userns

I'd like to write code that discovers the user namespace hierarchy on a
running system, and also shows who owns the various user namespaces.
Currently, there is no way of getting the owner UID of a user namespace.
Therefore, this patch adds a new NS_GET_CREATOR_UID ioctl() that fetches
the UID (as seen in the user namespace of the caller) of the creator of
the user namespace referred to by the specified file descriptor.

If the supplied file descriptor does not refer to a user namespace,
the operation fails with the error EINVAL. If the owner UID does
not have a mapping in the caller's user namespace return the
overflow UID as that appears easier to deal with in practice
in user-space applications.

-- EWB Changed the handling of unmapped UIDs from -EOVERFLOW
   back to the overflow uid.  Per conversation with
   Michael Kerrisk after examining his test code.

Acked-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Michael Kerrisk <mtk-manpages@gmail.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
fs/nsfs.c
include/uapi/linux/nsfs.h