1USER_NAMESPACES(7)         Linux Programmer's Manual        USER_NAMESPACES(7)
2
3
4

NAME

6       user_namespaces - overview of Linux user namespaces
7

DESCRIPTION

9       For an overview of namespaces, see namespaces(7).
10
11       User namespaces isolate security-related identifiers and attributes, in
12       particular, user IDs and  group  IDs  (see  credentials(7)),  the  root
13       directory,  keys  (see  keyrings(7)),  and  capabilities (see capabili‐
14       ties(7)).  A process's user and group IDs can be different  inside  and
15       outside  a  user namespace.  In particular, a process can have a normal
16       unprivileged user ID outside a user namespace while at  the  same  time
17       having a user ID of 0 inside the namespace; in other words, the process
18       has full privileges for operations inside the user  namespace,  but  is
19       unprivileged for operations outside the namespace.
20
21   Nested namespaces, namespace membership
22       User  namespaces can be nested; that is, each user namespace—except the
23       initial ("root") namespace—has a parent user namespace,  and  can  have
24       zero  or  more child user namespaces.  The parent user namespace is the
25       user namespace of the process that creates the  user  namespace  via  a
26       call to unshare(2) or clone(2) with the CLONE_NEWUSER flag.
27
28       The  kernel imposes (since version 3.11) a limit of 32 nested levels of
29       user namespaces.  Calls to unshare(2) or clone(2) that would cause this
30       limit to be exceeded fail with the error EUSERS.
31
32       Each process is a member of exactly one user namespace.  A process cre‐
33       ated via fork(2) or clone(2) without the CLONE_NEWUSER flag is a member
34       of  the  same  user namespace as its parent.  A single-threaded process
35       can  join  another  user  namespace  with  setns(2)  if  it   has   the
36       CAP_SYS_ADMIN  in that namespace; upon doing so, it gains a full set of
37       capabilities in that namespace.
38
39       A call to clone(2) or unshare(2) with the CLONE_NEWUSER flag makes  the
40       new  child process (for clone(2)) or the caller (for unshare(2)) a mem‐
41       ber of the new user namespace created by the call.
42
43       The NS_GET_PARENT ioctl(2)  operation  can  be  used  to  discover  the
44       parental relationship between user namespaces; see ioctl_ns(2).
45
46   Capabilities
47       The  child  process  created  by  clone(2)  with the CLONE_NEWUSER flag
48       starts out with a complete set of capabilities in the new  user  names‐
49       pace.   Likewise,  a  process  that  creates a new user namespace using
50       unshare(2) or joins an existing user namespace using setns(2)  gains  a
51       full  set  of  capabilities in that namespace.  On the other hand, that
52       process has no capabilities in the parent (in the case of clone(2))  or
53       previous  (in the case of unshare(2) and setns(2)) user namespace, even
54       if the new namespace is created or joined by the  root  user  (i.e.,  a
55       process with user ID 0 in the root namespace).
56
57       Note that a call to execve(2) will cause a process's capabilities to be
58       recalculated in the usual  way  (see  capabilities(7)).   Consequently,
59       unless the process has a user ID of 0 within the namespace, or the exe‐
60       cutable file has a nonempty inheritable capabilities mask, the  process
61       will