Blame SOURCES/1452368-mpo-7.4.2-clone.2.patch

7dd887
From fb510f4e3dc6c13696bce6d3a79b8cea9b03b044 Mon Sep 17 00:00:00 2001
7dd887
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
7dd887
Date: Mon, 22 May 2017 14:51:53 +0200
7dd887
Subject: [PATCH 1/2] clone.2: document features related to namespaces
7dd887
7dd887
---
7dd887
 man-pages/man2/____clone.2 | 524 ++++++++++++++++++++++++++++-----------------
7dd887
 man-pages/man2/clone.2     | 524 ++++++++++++++++++++++++++++-----------------
7dd887
 2 files changed, 658 insertions(+), 390 deletions(-)
7dd887
7dd887
diff --git a/man-pages/man2/____clone.2 b/man-pages/man2/____clone.2
7dd887
index 56d03cf..edf0994 100644
7dd887
--- a/man-pages/man2/____clone.2
7dd887
+++ b/man-pages/man2/____clone.2
7dd887
@@ -39,50 +39,23 @@
7dd887
 .\" 2008-11-19, mtk, document CLONE_NEWIPC
7dd887
 .\" 2008-11-19, Jens Axboe, mtk, document CLONE_IO
7dd887
 .\"
7dd887
-.\" FIXME Document CLONE_NEWUSER, which is new in 2.6.23
7dd887
-.\"       (also supported for unshare()?)
7dd887
-.\"
7dd887
-.TH CLONE 2 2013-04-16 "Linux" "Linux Programmer's Manual"
7dd887
+.TH CLONE 2 2016-12-12 "Linux" "Linux Programmer's Manual"
7dd887
 .SH NAME
7dd887
 clone, __clone2 \- create a child process
7dd887
 .SH SYNOPSIS
7dd887
 .nf
7dd887
 /* Prototype for the glibc wrapper function */
7dd887
 
7dd887
+.B #define _GNU_SOURCE
7dd887
 .B #include <sched.h>
7dd887
 
7dd887
 .BI "int clone(int (*" "fn" ")(void *), void *" child_stack ,
7dd887
 .BI "          int " flags ", void *" "arg" ", ... "
7dd887
-.BI "          /* pid_t *" ptid ", struct user_desc *" tls \
7dd887
+.BI "          /* pid_t *" ptid ", void *" newtls \
7dd887
 ", pid_t *" ctid " */ );"
7dd887
 
7dd887
-/* Prototype for the raw system call */
7dd887
-
7dd887
-.BI "long clone(unsigned long " flags ", void *" child_stack ,
7dd887
-.BI "          void *" ptid ", void *" ctid ,
7dd887
-.BI "          struct pt_regs *" regs );
7dd887
+/* For the prototype of the raw system call, see NOTES */
7dd887
 .fi
7dd887
-.sp
7dd887
-.in -4n
7dd887
-Feature Test Macro Requirements for glibc wrapper function (see
7dd887
-.BR feature_test_macros (7)):
7dd887
-.in
7dd887
-.sp
7dd887
-.BR clone ():
7dd887
-.ad l
7dd887
-.RS 4
7dd887
-.PD 0
7dd887
-.TP 4
7dd887
-Since glibc 2.14:
7dd887
-_GNU_SOURCE
7dd887
-.TP 4
7dd887
-.\" FIXME See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749
7dd887
-Before glibc 2.14:
7dd887
-_BSD_SOURCE || _SVID_SOURCE
7dd887
-    /* _GNU_SOURCE also suffices */
7dd887
-.PD
7dd887
-.RE
7dd887
-.ad b
7dd887
 .SH DESCRIPTION
7dd887
 .BR clone ()
7dd887
 creates a new process, in a manner similar to
7dd887
@@ -107,7 +80,7 @@ But see the description of
7dd887
 .B CLONE_PARENT
7dd887
 below.)
7dd887
 
7dd887
-The main use of
7dd887
+One use of
7dd887
 .BR clone ()
7dd887
 is to implement threads: multiple threads of control in a program that
7dd887
 run concurrently in a shared memory space.
7dd887
@@ -180,7 +153,7 @@ in order to specify what is shared between the calling process
7dd887
 and the child process:
7dd887
 .TP
7dd887
 .BR CLONE_CHILD_CLEARTID " (since Linux 2.5.49)"
7dd887
-Erase child thread ID at location
7dd887
+Clear (zero) the child thread ID at the location
7dd887
 .I ctid
7dd887
 in child memory when the child exits, and do a wakeup on the futex
7dd887
 at that address.
7dd887
@@ -190,9 +163,12 @@ system call.
7dd887
 This is used by threading libraries.
7dd887
 .TP
7dd887
 .BR CLONE_CHILD_SETTID " (since Linux 2.5.49)"
7dd887
-Store child thread ID at location
7dd887
+Store the child thread ID at the location
7dd887
 .I ctid
7dd887
-in child memory.
7dd887
+in the child's memory.
7dd887
+The store operation completes before
7dd887
+.BR clone ()
7dd887
+returns control to user space.
7dd887
 .TP
7dd887
 .BR CLONE_FILES " (since Linux 2.0)"
7dd887
 If
7dd887
@@ -206,27 +182,31 @@ or changes its associated flags (using the
7dd887
 .BR fcntl (2)
7dd887
 .B F_SETFD
7dd887
 operation), the other process is also affected.
7dd887
+If a process sharing a file descriptor table calls
7dd887
+.BR execve (2),
7dd887
+its file descriptor table is duplicated (unshared).
7dd887
 
7dd887
 If
7dd887
 .B CLONE_FILES
7dd887
 is not set, the child process inherits a copy of all file descriptors
7dd887
 opened in the calling process at the time of
7dd887
 .BR clone ().
7dd887
-(The duplicated file descriptors in the child refer to the
7dd887
-same open file descriptions (see
7dd887
-.BR open (2))
7dd887
-as the corresponding file descriptors in the calling process.)
7dd887
 Subsequent operations that open or close file descriptors,
7dd887
 or change file descriptor flags,
7dd887
 performed by either the calling
7dd887
 process or the child process do not affect the other process.
7dd887
+Note, however,
7dd887
+that the duplicated file descriptors in the child refer to the same open file
7dd887
+descriptions as the corresponding file descriptors in the calling process,
7dd887
+and thus share file offsets and file status flags (see
7dd887
+.BR open (2)).
7dd887
 .TP
7dd887
 .BR CLONE_FS " (since Linux 2.0)"
7dd887
 If
7dd887
 .B CLONE_FS
7dd887
-is set, the caller and the child process share the same file system
7dd887
+is set, the caller and the child process share the same filesystem
7dd887
 information.
7dd887
-This includes the root of the file system, the current
7dd887
+This includes the root of the filesystem, the current
7dd887
 working directory, and the umask.
7dd887
 Any call to
7dd887
 .BR chroot (2),
7dd887
@@ -238,7 +218,7 @@ other process.
7dd887
 
7dd887
 If
7dd887
 .B CLONE_FS
7dd887
-is not set, the child process works on a copy of the file system
7dd887
+is not set, the child process works on a copy of the filesystem
7dd887
 information of the calling process at the time of the
7dd887
 .BR clone ()
7dd887
 call.
7dd887
@@ -258,7 +238,7 @@ If this flag is not set, then (as with
7dd887
 the new process has its own I/O context.
7dd887
 
7dd887
 .\" The following based on text from Jens Axboe
7dd887
-The I/O context is the I/O scope of the disk scheduler (i.e,
7dd887
+The I/O context is the I/O scope of the disk scheduler (i.e.,
7dd887
 what the I/O scheduler uses to model scheduling of a process's I/O).
7dd887
 If processes share the same I/O context,
7dd887
 they are treated as one by the I/O scheduler.
7dd887
@@ -288,7 +268,7 @@ the process is created in the same IPC namespace as
7dd887
 the calling process.
7dd887
 This flag is intended for the implementation of containers.
7dd887
 
7dd887
-An IPC namespace provides an isolated view of System V IPC objects (see
7dd887
+An IPC namespace provides an isolated view of System\ V IPC objects (see
7dd887
 .BR svipc (7))
7dd887
 and (since Linux 2.6.30)
7dd887
 .\" commit 7eafd7c74c3f2e67c27621b987b28397110d643f
7dd887
@@ -308,17 +288,17 @@ When an IPC namespace is destroyed
7dd887
 (i.e., when the last process that is a member of the namespace terminates),
7dd887
 all IPC objects in the namespace are automatically destroyed.
7dd887
 
7dd887
-Use of this flag requires: a kernel configured with the
7dd887
-.B CONFIG_SYSVIPC
7dd887
-and
7dd887
-.B CONFIG_IPC_NS
7dd887
-options and that the process be privileged
7dd887
-.RB ( CAP_SYS_ADMIN ).
7dd887
+Only a privileged process
7dd887
+.RB ( CAP_SYS_ADMIN )
7dd887
+can employ
7dd887
+.BR CLONE_NEWIPC .
7dd887
 This flag can't be specified in conjunction with
7dd887
 .BR CLONE_SYSVSEM .
7dd887
+
7dd887
+For further information on IPC namespaces, see
7dd887
+.BR namespaces (7).
7dd887
 .TP
7dd887
 .BR CLONE_NEWNET " (since Linux 2.6.24)"
7dd887
-.\" FIXME Check when the implementation was completed
7dd887
 (The implementation of this flag was completed only
7dd887
 by about kernel version 2.6.29.)
7dd887
 
7dd887
@@ -326,7 +306,7 @@ If
7dd887
 .B CLONE_NEWNET
7dd887
 is set, then create the process in a new network namespace.
7dd887
 If this flag is not set, then (as with
7dd887
-.BR fork (2)),
7dd887
+.BR fork (2))
7dd887
 the process is created in the same network namespace as
7dd887
 the calling process.
7dd887
 This flag is intended for the implementation of containers.
7dd887
@@ -341,7 +321,7 @@ directory trees, sockets, etc.).
7dd887
 A physical network device can live in exactly one
7dd887
 network namespace.
7dd887
 A virtual network device ("veth") pair provides a pipe-like abstraction
7dd887
-.\" FIXME Add pointer to veth(4) page when it is eventually completed
7dd887
+.\" FIXME . Add pointer to veth(4) page when it is eventually completed
7dd887
 that can be used to create tunnels between network namespaces,
7dd887
 and can be used to create a bridge to a physical network device
7dd887
 in another namespace.
7dd887
@@ -350,54 +330,41 @@ When a network namespace is freed
7dd887
 (i.e., when the last process in the namespace terminates),
7dd887
 its physical network devices are moved back to the
7dd887
 initial network namespace (not to the parent of the process).
7dd887
+For further information on network namespaces, see
7dd887
+.BR namespaces (7).
7dd887
 
7dd887
-Use of this flag requires: a kernel configured with the
7dd887
-.B CONFIG_NET_NS
7dd887
-option and that the process be privileged
7dd887
-.RB ( CAP_SYS_ADMIN ).
7dd887
+Only a privileged process
7dd887
+.RB ( CAP_SYS_ADMIN )
7dd887
+can employ
7dd887
+.BR CLONE_NEWNET .
7dd887
 .TP
7dd887
 .BR CLONE_NEWNS " (since Linux 2.4.19)"
7dd887
-Start the child in a new mount namespace.
7dd887
-
7dd887
-Every process lives in a mount namespace.
7dd887
-The
7dd887
-.I namespace
7dd887
-of a process is the data (the set of mounts) describing the file hierarchy
7dd887
-as seen by that process.
7dd887
-After a
7dd887
-.BR fork (2)
7dd887
-or
7dd887
-.BR clone ()
7dd887
-where the
7dd887
-.B CLONE_NEWNS
7dd887
-flag is not set, the child lives in the same mount
7dd887
-namespace as the parent.
7dd887
-The system calls
7dd887
-.BR mount (2)
7dd887
-and
7dd887
-.BR umount (2)
7dd887
-change the mount namespace of the calling process, and hence affect
7dd887
-all processes that live in the same namespace, but do not affect
7dd887
-processes in a different mount namespace.
7dd887
-
7dd887
-After a
7dd887
-.BR clone ()
7dd887
-where the
7dd887
+If
7dd887
 .B CLONE_NEWNS
7dd887
-flag is set, the cloned child is started in a new mount namespace,
7dd887
+is set, the cloned child is started in a new mount namespace,
7dd887
 initialized with a copy of the namespace of the parent.
7dd887
-
7dd887
-Only a privileged process (one having the \fBCAP_SYS_ADMIN\fP capability)
7dd887
-may specify the
7dd887
+If
7dd887
 .B CLONE_NEWNS
7dd887
-flag.
7dd887
+is not set, the child lives in the same mount
7dd887
+namespace as the parent.
7dd887
+
7dd887
+Only a privileged process
7dd887
+.RB ( CAP_SYS_ADMIN )
7dd887
+can employ
7dd887
+.BR CLONE_NEWNS .
7dd887
 It is not permitted to specify both
7dd887
 .B CLONE_NEWNS
7dd887
 and
7dd887
 .B CLONE_FS
7dd887
+.\" See https://lwn.net/Articles/543273/
7dd887
 in the same
7dd887
 .BR clone ()
7dd887
 call.
7dd887
+
7dd887
+For further information on mount namespaces, see
7dd887
+.BR namespaces (7)
7dd887
+and
7dd887
+.BR mount_namespaces (7).
7dd887
 .TP
7dd887
 .BR CLONE_NEWPID " (since Linux 2.6.24)"
7dd887
 .\" This explanation draws a lot of details from
7dd887
@@ -411,73 +378,74 @@ If
7dd887
 .B CLONE_NEWPID
7dd887
 is set, then create the process in a new PID namespace.
7dd887
 If this flag is not set, then (as with
7dd887
-.BR fork (2)),
7dd887
+.BR fork (2))
7dd887
 the process is created in the same PID namespace as
7dd887
 the calling process.
7dd887
 This flag is intended for the implementation of containers.
7dd887
 
7dd887
-A PID namespace provides an isolated environment for PIDs:
7dd887
-PIDs in a new namespace start at 1,
7dd887
-somewhat like a standalone system, and calls to
7dd887
-.BR fork (2),
7dd887
-.BR vfork (2),
7dd887
+For further information on PID namespaces, see
7dd887
+.BR namespaces (7)
7dd887
+and
7dd887
+.BR pid_namespaces (7).
7dd887
+
7dd887
+Only a privileged process
7dd887
+.RB ( CAP_SYS_ADMIN )
7dd887
+can employ
7dd887
+.BR CLONE_NEWPID .
7dd887
+This flag can't be specified in conjunction with
7dd887
+.BR CLONE_THREAD
7dd887
 or
7dd887
+.BR CLONE_PARENT .
7dd887
+.TP
7dd887
+.BR CLONE_NEWUSER
7dd887
+(This flag first became meaningful for
7dd887
 .BR clone ()
7dd887
-will produce processes with PIDs that are unique within the namespace.
7dd887
+in Linux 2.6.23,
7dd887
+the current
7dd887
+.BR clone ()
7dd887
+semantics were merged in Linux 3.5,
7dd887
+and the final pieces to make the user namespaces completely usable were
7dd887
+merged in Linux 3.8.)
7dd887
 
7dd887
-The first process created in a new namespace
7dd887
-(i.e., the process created using the
7dd887
-.BR CLONE_NEWPID
7dd887
-flag) has the PID 1, and is the "init" process for the namespace.
7dd887
-Children that are orphaned within the namespace will be reparented
7dd887
-to this process rather than
7dd887
-.BR init (8).
7dd887
-Unlike the traditional
7dd887
-.B init
7dd887
-process, the "init" process of a PID namespace can terminate,
7dd887
-and if it does, all of the processes in the namespace are terminated.
7dd887
-
7dd887
-PID namespaces form a hierarchy.
7dd887
-When a new PID namespace is created,
7dd887
-the processes in that namespace are visible
7dd887
-in the PID namespace of the process that created the new namespace;
7dd887
-analogously, if the parent PID namespace is itself
7dd887
-the child of another PID namespace,
7dd887
-then processes in the child and parent PID namespaces will both be
7dd887
-visible in the grandparent PID namespace.
7dd887
-Conversely, the processes in the "child" PID namespace do not see
7dd887
-the processes in the parent namespace.
7dd887
-The existence of a namespace hierarchy means that each process
7dd887
-may now have multiple PIDs:
7dd887
-one for each namespace in which it is visible;
7dd887
-each of these PIDs is unique within the corresponding namespace.
7dd887
-(A call to
7dd887
-.BR getpid (2)
7dd887
-always returns the PID associated with the namespace in which
7dd887
-the process lives.)
7dd887
-
7dd887
-After creating the new namespace,
7dd887
-it is useful for the child to change its root directory
7dd887
-and mount a new procfs instance at
7dd887
-.I /proc
7dd887
-so that tools such as
7dd887
-.BR ps (1)
7dd887
-work correctly.
7dd887
-.\" mount -t proc proc /proc
7dd887
-(If
7dd887
-.BR CLONE_NEWNS
7dd887
-is also included in
7dd887
-.IR flags ,
7dd887
-then it isn't necessary to change the root directory:
7dd887
-a new procfs instance can be mounted directly over
7dd887
-.IR /proc .)
7dd887
+If
7dd887
+.B CLONE_NEWUSER
7dd887
+is set, then create the process in a new user namespace.
7dd887
+If this flag is not set, then (as with
7dd887
+.BR fork (2))
7dd887
+the process is created in the same user namespace as the calling process.
7dd887
+
7dd887
+For further information on user namespaces, see
7dd887
+.BR namespaces (7)
7dd887
+and
7dd887
+.BR user_namespaces (7)
7dd887
+
7dd887
+Before Linux 3.8, use of
7dd887
+.BR CLONE_NEWUSER
7dd887
+required that the caller have three capabilities:
7dd887
+.BR CAP_SYS_ADMIN ,
7dd887
+.BR CAP_SETUID ,
7dd887
+and
7dd887
+.BR CAP_SETGID .
7dd887
+.\" Before Linux 2.6.29, it appears that only CAP_SYS_ADMIN was needed
7dd887
+Starting with Linux 3.8,
7dd887
+no privileges are needed to create a user namespace.
7dd887
 
7dd887
-Use of this flag requires: a kernel configured with the
7dd887
-.B CONFIG_PID_NS
7dd887
-option and that the process be privileged
7dd887
-.RB ( CAP_SYS_ADMIN ).
7dd887
 This flag can't be specified in conjunction with
7dd887
-.BR CLONE_THREAD .
7dd887
+.BR CLONE_THREAD
7dd887
+or
7dd887
+.BR CLONE_PARENT .
7dd887
+For security reasons,
7dd887
+.\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
7dd887
+.\" https://lwn.net/Articles/543273/
7dd887
+.\" The fix actually went into 3.9 and into 3.8.3. However, user namespaces
7dd887
+.\" were, for practical purposes, unusable in earlier 3.8.x because of the
7dd887
+.\" various filesystems that didn't support userns.
7dd887
+.BR CLONE_NEWUSER
7dd887
+cannot be specified in conjunction with
7dd887
+.BR CLONE_FS .
7dd887
+
7dd887
+For further information on user namespaces, see
7dd887
+.BR user_namespaces (7).
7dd887
 .TP
7dd887
 .BR CLONE_NEWUTS " (since Linux 2.6.19)"
7dd887
 If
7dd887
@@ -486,27 +454,29 @@ is set, then create the process in a new UTS namespace,
7dd887
 whose identifiers are initialized by duplicating the identifiers
7dd887
 from the UTS namespace of the calling process.
7dd887
 If this flag is not set, then (as with
7dd887
-.BR fork (2)),
7dd887
+.BR fork (2))
7dd887
 the process is created in the same UTS namespace as
7dd887
 the calling process.
7dd887
 This flag is intended for the implementation of containers.
7dd887
 
7dd887
 A UTS namespace is the set of identifiers returned by
7dd887
 .BR uname (2);
7dd887
-among these, the domain name and the host name can be modified by
7dd887
+among these, the domain name and the hostname can be modified by
7dd887
 .BR setdomainname (2)
7dd887
 and
7dd887
-.BR
7dd887
 .BR sethostname (2),
7dd887
 respectively.
7dd887
 Changes made to the identifiers in a UTS namespace
7dd887
 are visible to all other processes in the same namespace,
7dd887
 but are not visible to processes in other UTS namespaces.
7dd887
 
7dd887
-Use of this flag requires: a kernel configured with the
7dd887
-.B CONFIG_UTS_NS
7dd887
-option and that the process be privileged
7dd887
-.RB ( CAP_SYS_ADMIN ).
7dd887
+Only a privileged process
7dd887
+.RB ( CAP_SYS_ADMIN )
7dd887
+can employ
7dd887
+.BR CLONE_NEWUTS .
7dd887
+
7dd887
+For further information on UTS namespaces, see
7dd887
+.BR namespaces (7).
7dd887
 .TP
7dd887
 .BR CLONE_PARENT " (since Linux 2.3.12)"
7dd887
 If
7dd887
@@ -530,12 +500,15 @@ is set, then the parent of the calling process, rather than the
7dd887
 calling process itself, will be signaled.
7dd887
 .TP
7dd887
 .BR CLONE_PARENT_SETTID " (since Linux 2.5.49)"
7dd887
-Store child thread ID at location
7dd887
+Store the child thread ID at the location
7dd887
 .I ptid
7dd887
-in parent and child memory.
7dd887
+in the parent's memory.
7dd887
 (In Linux 2.5.32-2.5.48 there was a flag
7dd887
 .B CLONE_SETTID
7dd887
 that did this.)
7dd887
+The store operation completes before
7dd887
+.BR clone ()
7dd887
+returns control to user space.
7dd887
 .TP
7dd887
 .BR CLONE_PID " (obsolete)"
7dd887
 If
7dd887
@@ -547,6 +520,7 @@ of not much use.
7dd887
 Since 2.3.21 this flag can be
7dd887
 specified only by the system boot process (PID 0).
7dd887
 It disappeared in Linux 2.5.16.
7dd887
+Since then, the kernel silently ignores it without error.
7dd887
 .TP
7dd887
 .BR CLONE_PTRACE " (since Linux 2.2)"
7dd887
 If
7dd887
@@ -556,11 +530,25 @@ then trace the child also (see
7dd887
 .BR ptrace (2)).
7dd887
 .TP
7dd887
 .BR CLONE_SETTLS " (since Linux 2.5.32)"
7dd887
-The
7dd887
+The TLS (Thread Local Storage) descriptor is set to
7dd887
+.I newtls.
7dd887
+
7dd887
+The interpretation of
7dd887
 .I newtls
7dd887
-argument is the new TLS (Thread Local Storage) descriptor.
7dd887
+and the resulting effect is architecture dependent.
7dd887
+On x86,
7dd887
+.I newtls
7dd887
+is interpreted as a
7dd887
+.IR "struct user_desc *"
7dd887
 (See
7dd887
-.BR set_thread_area (2).)
7dd887
+.BR set_thread_area (2)).
7dd887
+On x86_64 it is the new value to be set for the %fs base register
7dd887
+(See the
7dd887
+.I ARCH_SET_FS
7dd887
+argument to
7dd887
+.BR arch_prctl (2)).
7dd887
+On architectures with a dedicated TLS register, it is the new value
7dd887
+of that register.
7dd887
 .TP
7dd887
 .BR CLONE_SIGHAND " (since Linux 2.0)"
7dd887
 If
7dd887
@@ -612,16 +600,26 @@ from Linux 2.6.25 onward,
7dd887
 and was
7dd887
 .I removed
7dd887
 altogether in Linux 2.6.38.
7dd887
+Since then, the kernel silently ignores it without error.
7dd887
 .\" glibc 2.8 removed this defn from bits/sched.h
7dd887
 .TP
7dd887
 .BR CLONE_SYSVSEM " (since Linux 2.5.10)"
7dd887
 If
7dd887
 .B CLONE_SYSVSEM
7dd887
 is set, then the child and the calling process share
7dd887
-a single list of System V semaphore undo values (see
7dd887
+a single list of System V semaphore adjustment
7dd887
+.RI ( semadj )
7dd887
+values (see
7dd887
 .BR semop (2)).
7dd887
-If this flag is not set, then the child has a separate undo list,
7dd887
-which is initially empty.
7dd887
+In this case, the shared list accumulates
7dd887
+.I semadj
7dd887
+values across all processes sharing the list,
7dd887
+and semaphore adjustments are performed only when the last process
7dd887
+that is sharing the list terminates (or ceases sharing the list using
7dd887
+.BR unshare (2)).
7dd887
+If this flag is not set, then the child has a separate
7dd887
+.I semadj
7dd887
+list that is initially empty.
7dd887
 .TP
7dd887
 .BR CLONE_THREAD " (since Linux 2.4.0-test8)"
7dd887
 If
7dd887
@@ -703,7 +701,12 @@ must also include
7dd887
 .B CLONE_SIGHAND
7dd887
 if
7dd887
 .B CLONE_THREAD
7dd887
-is specified.
7dd887
+is specified
7dd887
+(and note that, since Linux 2.6.0-test6,
7dd887
+.BR CLONE_SIGHAND
7dd887
+also requires
7dd887
+.BR CLONE_VM
7dd887
+to be included).
7dd887
 
7dd887
 Signals may be sent to a thread group as a whole (i.e., a TGID) using
7dd887
 .BR kill (2),
7dd887
@@ -761,7 +764,7 @@ or
7dd887
 
7dd887
 If
7dd887
 .B CLONE_VFORK
7dd887
-is not set then both the calling process and the child are schedulable
7dd887
+is not set, then both the calling process and the child are schedulable
7dd887
 after the call, and an application should not rely on execution occurring
7dd887
 in any particular order.
7dd887
 .TP
7dd887
@@ -786,7 +789,7 @@ space of the calling process at the time of
7dd887
 Memory writes or file mappings/unmappings performed by one of the
7dd887
 processes do not affect the other, as with
7dd887
 .BR fork (2).
7dd887
-.SS The raw system call interface
7dd887
+.SS C library/kernel differences
7dd887
 The raw
7dd887
 .BR clone ()
7dd887
 system call corresponds more closely to
7dd887
@@ -801,16 +804,58 @@ arguments of the
7dd887
 .BR clone ()
7dd887
 wrapper function are omitted.
7dd887
 Furthermore, the argument order changes.
7dd887
-The raw system call interface on x86 and many other architectures is roughly:
7dd887
+In addition, there are variations across architectures.
7dd887
+
7dd887
+The raw system call interface on x86-64 and some other architectures
7dd887
+(including sh, tile, and alpha) is roughly:
7dd887
+
7dd887
 .in +4
7dd887
 .nf
7dd887
+.BI "long clone(unsigned long " flags ", void *" child_stack ,
7dd887
+.BI "           int *" ptid ", int *" ctid ,
7dd887
+.BI "           unsigned long " newtls );
7dd887
+.fi
7dd887
+.in
7dd887
+
7dd887
+On x86-32, and several other common architectures
7dd887
+(including score, ARM, ARM 64, PA-RISC, arc, Power PC, xtensa,
7dd887
+and MIPS),
7dd887
+.\" CONFIG_CLONE_BACKWARDS
7dd887
+the order of the last two arguments is reversed:
7dd887
 
7dd887
+.in +4
7dd887
+.nf
7dd887
 .BI "long clone(unsigned long " flags ", void *" child_stack ,
7dd887
-.BI "           void *" ptid ", void *" ctid ,
7dd887
-.BI "           struct pt_regs *" regs );
7dd887
+.BI "          int *" ptid ", unsigned long " newtls ,
7dd887
+.BI "          int *" ctid );
7dd887
+.fi
7dd887
+.in
7dd887
+
7dd887
+On the cris and s390 architectures,
7dd887
+.\" CONFIG_CLONE_BACKWARDS2
7dd887
+the order of the first two arguments is reversed:
7dd887
 
7dd887
+.in +4
7dd887
+.nf
7dd887
+.BI "long clone(void *" child_stack ", unsigned long " flags ,
7dd887
+.BI "           int *" ptid ", int *" ctid ,
7dd887
+.BI "           unsigned long " newtls );
7dd887
+.fi
7dd887
+.in
7dd887
+
7dd887
+On the microblaze architecture,
7dd887
+.\" CONFIG_CLONE_BACKWARDS3
7dd887
+an additional argument is supplied:
7dd887
+
7dd887
+.in +4
7dd887
+.nf
7dd887
+.BI "long clone(unsigned long " flags ", void *" child_stack ,
7dd887
+.BI "           int " stack_size , "\fR         /* Size of stack */"
7dd887
+.BI "           int *" ptid ", int *" ctid ,
7dd887
+.BI "           unsigned long " newtls );
7dd887
 .fi
7dd887
 .in
7dd887
+
7dd887
 Another difference for the raw system call is that the
7dd887
 .I child_stack
7dd887
 argument may be zero, in which case copy-on-write semantics ensure that the
7dd887
@@ -819,17 +864,13 @@ the stack.
7dd887
 In this case, for correct operation, the
7dd887
 .B CLONE_VM
7dd887
 option should not be specified.
7dd887
-
7dd887
-For some architectures, the order of the arguments for the system call
7dd887
-differs from that shown above.
7dd887
-On the score, microblaze, ARM, ARM 64, PA-RISC, arc, Power PC, xtensa,
7dd887
-and MIPS architectures,
7dd887
-the order of the fourth and fifth arguments is reversed.
7dd887
-On the cris and s390 architectures,
7dd887
-the order of the first and second arguments is reversed.
7dd887
+.\"
7dd887
 .SS blackfin, m68k, and sparc
7dd887
+.\" Mike Frysinger noted in a 2013 mail:
7dd887
+.\"     these arches don't define __ARCH_WANT_SYS_CLONE:
7dd887
+.\"     blackfin ia64 m68k sparc
7dd887
 The argument-passing conventions on
7dd887
-blackfin, m68k, and sparc are different from descriptions above.
7dd887
+blackfin, m68k, and sparc are different from the descriptions above.
7dd887
 For details, see the kernel (and glibc) source.
7dd887
 .SS ia64
7dd887
 On ia64, a different interface is used:
7dd887
@@ -883,7 +924,8 @@ will be set appropriately.
7dd887
 .SH ERRORS
7dd887
 .TP
7dd887
 .B EAGAIN
7dd887
-Too many processes are already running.
7dd887
+Too many processes are already running; see
7dd887
+.BR fork (2).
7dd887
 .TP
7dd887
 .B EINVAL
7dd887
 .B CLONE_SIGHAND
7dd887
@@ -908,6 +950,7 @@ was not.
7dd887
 .\" (Since Linux 2.6.0-test6.)
7dd887
 .TP
7dd887
 .B EINVAL
7dd887
+.\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
7dd887
 Both
7dd887
 .B CLONE_FS
7dd887
 and
7dd887
@@ -915,6 +958,14 @@ and
7dd887
 were specified in
7dd887
 .IR flags .
7dd887
 .TP
7dd887
+.BR EINVAL " (since Linux 3.9)"
7dd887
+Both
7dd887
+.B CLONE_NEWUSER
7dd887
+and
7dd887
+.B CLONE_FS
7dd887
+were specified in
7dd887
+.IR flags .
7dd887
+.TP
7dd887
 .B EINVAL
7dd887
 Both
7dd887
 .B CLONE_NEWIPC
7dd887
@@ -924,18 +975,25 @@ were specified in
7dd887
 .IR flags .
7dd887
 .TP
7dd887
 .B EINVAL
7dd887
-Both
7dd887
+One (or both) of
7dd887
 .BR CLONE_NEWPID
7dd887
-and
7dd887
+or
7dd887
+.BR CLONE_NEWUSER
7dd887
+and one (or both) of
7dd887
 .BR CLONE_THREAD
7dd887
+or
7dd887
+.BR CLONE_PARENT
7dd887
 were specified in
7dd887
 .IR flags .
7dd887
 .TP
7dd887
 .B EINVAL
7dd887
-Returned by
7dd887
+Returned by the glibc
7dd887
 .BR clone ()
7dd887
-when a zero value is specified for
7dd887
-.IR child_stack .
7dd887
+wrapper function when
7dd887
+.IR fn
7dd887
+or
7dd887
+.IR child_stack
7dd887
+is specified as NULL.
7dd887
 .TP
7dd887
 .B EINVAL
7dd887
 .BR CLONE_NEWIPC
7dd887
@@ -971,11 +1029,48 @@ but the kernel was not configured with the
7dd887
 .B CONFIG_UTS
7dd887
 option.
7dd887
 .TP
7dd887
+.B EINVAL
7dd887
+.I child_stack
7dd887
+is not aligned to a suitable boundary for this architecture.
7dd887
+For example, on aarch64,
7dd887
+.I child_stack
7dd887
+must be a multiple of 16.
7dd887
+.TP
7dd887
 .B ENOMEM
7dd887
 Cannot allocate sufficient memory to allocate a task structure for the
7dd887
 child, or to copy those parts of the caller's context that need to be
7dd887
 copied.
7dd887
 .TP
7dd887
+.BR ENOSPC " (since Linux 3.7)"
7dd887
+.\" commit f2302505775fd13ba93f034206f1e2a587017929
7dd887
+.B CLONE_NEWPID
7dd887
+was specified in flags,
7dd887
+but the limit on the nesting depth of PID namespaces
7dd887
+would have been exceeded; see
7dd887
+.BR pid_namespaces (7).
7dd887
+.TP
7dd887
+.BR ENOSPC " (since Linux 4.9; beforehand " EUSERS )
7dd887
+.B CLONE_NEWUSER
7dd887
+was specified in
7dd887
+.IR flags ,
7dd887
+and the call would cause the limit on the number of
7dd887
+nested user namespaces to be exceeded.
7dd887
+See
7dd887
+.BR user_namespaces (7).
7dd887
+
7dd887
+From Linux 3.11 to Linux 4.8, the error diagnosed in this case was
7dd887
+.BR EUSERS .
7dd887
+.TP
7dd887
+.BR ENOSPC " (since Linux 4.9)"
7dd887
+One of the values in
7dd887
+.I flags
7dd887
+specified the creation of a new user namespace,
7dd887
+but doing so would have caused the limit defined by the corresponding file in
7dd887
+.IR /proc/sys/user
7dd887
+to be exceeded.
7dd887
+For further details, see
7dd887
+.BR namespaces (7).
7dd887
+.TP
7dd887
 .B EPERM
7dd887
 .BR CLONE_NEWIPC ,
7dd887
 .BR CLONE_NEWNET ,
7dd887
@@ -989,22 +1084,62 @@ was specified by an unprivileged process (process without \fBCAP_SYS_ADMIN\fP).
7dd887
 .B CLONE_PID
7dd887
 was specified by a process other than process 0.
7dd887
 .TP
7dd887
+.B EPERM
7dd887
+.BR CLONE_NEWUSER
7dd887
+was specified in
7dd887
+.IR flags ,
7dd887
+but either the effective user ID or the effective group ID of the caller
7dd887
+does not have a mapping in the parent namespace (see
7dd887
+.BR user_namespaces (7)).
7dd887
+.TP
7dd887
+.BR EPERM " (since Linux 3.9)"
7dd887
+.\" commit 3151527ee007b73a0ebd296010f1c0454a919c7d
7dd887
+.B CLONE_NEWUSER
7dd887
+was specified in
7dd887
+.I flags
7dd887
+and the caller is in a chroot environment
7dd887
+.\" FIXME What is the rationale for this restriction?
7dd887
+(i.e., the caller's root directory does not match the root directory
7dd887
+of the mount namespace in which it resides).
7dd887
+.TP
7dd887
 .BR ERESTARTNOINTR " (since Linux 2.6.17)"
7dd887
+.\" commit 4a2c7a7837da1b91468e50426066d988050e4d56
7dd887
 System call was interrupted by a signal and will be restarted.
7dd887
 (This can be seen only during a trace.)
7dd887
-.SH VERSIONS
7dd887
-There is no entry for
7dd887
-.BR clone ()
7dd887
-in libc5.
7dd887
-glibc2 provides
7dd887
-.BR clone ()
7dd887
-as described in this manual page.
7dd887
+.TP
7dd887
+.BR EUSERS " (Linux 3.11 to Linux 4.8)"
7dd887
+.B CLONE_NEWUSER
7dd887
+was specified in
7dd887
+.IR flags ,
7dd887
+and the limit on the number of nested user namespaces would be exceeded.
7dd887
+See the discussion of the
7dd887
+.BR ENOSPC
7dd887
+error above.
7dd887
+.\" .SH VERSIONS
7dd887
+.\" There is no entry for
7dd887
+.\" .BR clone ()
7dd887
+.\" in libc5.
7dd887
+.\" glibc2 provides
7dd887
+.\" .BR clone ()
7dd887
+.\" as described in this manual page.
7dd887
 .SH CONFORMING TO
7dd887
 .BR clone ()
7dd887
 is Linux-specific and should not be used in programs
7dd887
 intended to be portable.
7dd887
 .SH NOTES
7dd887
-In the kernel 2.4.x series,
7dd887
+The
7dd887
+.BR kcmp (2)
7dd887
+system call can be used to test whether two processes share various
7dd887
+resources such as a file descriptor table,
7dd887
+System V semaphore undo operations, or a virtual address space.
7dd887
+
7dd887
+
7dd887
+Handlers registered using
7dd887
+.BR pthread_atfork (3)
7dd887
+are not executed during a call to
7dd887
+.BR clone ().
7dd887
+
7dd887
+In the Linux 2.4.x series,
7dd887
 .B CLONE_THREAD
7dd887
 generally does not make the parent of the new thread the same
7dd887
 as the parent of the calling process.
7dd887
@@ -1012,14 +1147,13 @@ However, for kernel versions 2.4.7 to 2.4.18 the
7dd887
 .B CLONE_THREAD
7dd887
 flag implied the
7dd887
 .B CLONE_PARENT
7dd887
-flag (as in kernel 2.6).
7dd887
+flag (as in Linux 2.6.0 and later).
7dd887
 
7dd887
 For a while there was
7dd887
 .B CLONE_DETACHED
7dd887
 (introduced in 2.5.32):
7dd887
 parent wants no child-exit signal.
7dd887
-In 2.6.2 the need to give this
7dd887
-together with
7dd887
+In Linux 2.6.2, the need to give this flag together with
7dd887
 .B CLONE_THREAD
7dd887
 disappeared.
7dd887
 This flag is still defined, but has no effect.
7dd887
@@ -1088,7 +1222,6 @@ To get the truth, it may be necessary to use code such as the following:
7dd887
 .\" https://bugzilla.redhat.com/show_bug.cgi?id=417521
7dd887
 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=6910
7dd887
 .SH EXAMPLE
7dd887
-.SS Create a child that executes in a separate UTS namespace
7dd887
 The following program demonstrates the use of
7dd887
 .BR clone ()
7dd887
 to create a child process that executes in a separate UTS namespace.
7dd887
@@ -1098,7 +1231,7 @@ making it possible to see that the hostname
7dd887
 differs in the UTS namespaces of the parent and child.
7dd887
 For an example of the use of this program, see
7dd887
 .BR setns (2).
7dd887
-
7dd887
+.SS Program source
7dd887
 .nf
7dd887
 #define _GNU_SOURCE
7dd887
 #include <sys/wait.h>
7dd887
@@ -1198,6 +1331,7 @@ main(int argc, char *argv[])
7dd887
 .BR unshare (2),
7dd887
 .BR wait (2),
7dd887
 .BR capabilities (7),
7dd887
+.BR namespaces (7),
7dd887
 .BR pthreads (7)
7dd887
 .SH COLOPHON
7dd887
 This page is part of release 3.53 of the Linux
7dd887
diff --git a/man-pages/man2/clone.2 b/man-pages/man2/clone.2
7dd887
index d9ffe3e..d053b0e 100644
7dd887
--- a/man-pages/man2/clone.2
7dd887
+++ b/man-pages/man2/clone.2
7dd887
@@ -39,50 +39,23 @@
7dd887
 .\" 2008-11-19, mtk, document CLONE_NEWIPC
7dd887
 .\" 2008-11-19, Jens Axboe, mtk, document CLONE_IO
7dd887
 .\"
7dd887
-.\" FIXME Document CLONE_NEWUSER, which is new in 2.6.23
7dd887
-.\"       (also supported for unshare()?)
7dd887
-.\"
7dd887
-.TH CLONE 2 2013-04-16 "Linux" "Linux Programmer's Manual"
7dd887
+.TH CLONE 2 2016-12-12 "Linux" "Linux Programmer's Manual"
7dd887
 .SH NAME
7dd887
 clone, __clone2 \- create a child process
7dd887
 .SH SYNOPSIS
7dd887
 .nf
7dd887
 /* Prototype for the glibc wrapper function */
7dd887
 
7dd887
+.B #define _GNU_SOURCE
7dd887
 .B #include <sched.h>
7dd887
 
7dd887
 .BI "int clone(int (*" "fn" ")(void *), void *" child_stack ,
7dd887
 .BI "          int " flags ", void *" "arg" ", ... "
7dd887
-.BI "          /* pid_t *" ptid ", struct user_desc *" tls \
7dd887
+.BI "          /* pid_t *" ptid ", void *" newtls \
7dd887
 ", pid_t *" ctid " */ );"
7dd887
 
7dd887
-/* Prototype for the raw system call */
7dd887
-
7dd887
-.BI "long clone(unsigned long " flags ", void *" child_stack ,
7dd887
-.BI "          void *" ptid ", void *" ctid ,
7dd887
-.BI "          struct pt_regs *" regs );
7dd887
+/* For the prototype of the raw system call, see NOTES */
7dd887
 .fi
7dd887
-.sp
7dd887
-.in -4n
7dd887
-Feature Test Macro Requirements for glibc wrapper function (see
7dd887
-.BR feature_test_macros (7)):
7dd887
-.in
7dd887
-.sp
7dd887
-.BR clone ():
7dd887
-.ad l
7dd887
-.RS 4
7dd887
-.PD 0
7dd887
-.TP 4
7dd887
-Since glibc 2.14:
7dd887
-_GNU_SOURCE
7dd887
-.TP 4
7dd887
-.\" FIXME See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749
7dd887
-Before glibc 2.14:
7dd887
-_BSD_SOURCE || _SVID_SOURCE
7dd887
-    /* _GNU_SOURCE also suffices */
7dd887
-.PD
7dd887
-.RE
7dd887
-.ad b
7dd887
 .SH DESCRIPTION
7dd887
 .BR clone ()
7dd887
 creates a new process, in a manner similar to
7dd887
@@ -107,7 +80,7 @@ But see the description of
7dd887
 .B CLONE_PARENT
7dd887
 below.)
7dd887
 
7dd887
-The main use of
7dd887
+One use of
7dd887
 .BR clone ()
7dd887
 is to implement threads: multiple threads of control in a program that
7dd887
 run concurrently in a shared memory space.
7dd887
@@ -180,7 +153,7 @@ in order to specify what is shared between the calling process
7dd887
 and the child process:
7dd887
 .TP
7dd887
 .BR CLONE_CHILD_CLEARTID " (since Linux 2.5.49)"
7dd887
-Erase child thread ID at location
7dd887
+Clear (zero) the child thread ID at the location
7dd887
 .I ctid
7dd887
 in child memory when the child exits, and do a wakeup on the futex
7dd887
 at that address.
7dd887
@@ -190,9 +163,12 @@ system call.
7dd887
 This is used by threading libraries.
7dd887
 .TP
7dd887
 .BR CLONE_CHILD_SETTID " (since Linux 2.5.49)"
7dd887
-Store child thread ID at location
7dd887
+Store the child thread ID at the location
7dd887
 .I ctid
7dd887
-in child memory.
7dd887
+in the child's memory.
7dd887
+The store operation completes before
7dd887
+.BR clone ()
7dd887
+returns control to user space.
7dd887
 .TP
7dd887
 .BR CLONE_FILES " (since Linux 2.0)"
7dd887
 If
7dd887
@@ -206,27 +182,31 @@ or changes its associated flags (using the
7dd887
 .BR fcntl (2)
7dd887
 .B F_SETFD
7dd887
 operation), the other process is also affected.
7dd887
+If a process sharing a file descriptor table calls
7dd887
+.BR execve (2),
7dd887
+its file descriptor table is duplicated (unshared).
7dd887
 
7dd887
 If
7dd887
 .B CLONE_FILES
7dd887
 is not set, the child process inherits a copy of all file descriptors
7dd887
 opened in the calling process at the time of
7dd887
 .BR clone ().
7dd887
-(The duplicated file descriptors in the child refer to the
7dd887
-same open file descriptions (see
7dd887
-.BR open (2))
7dd887
-as the corresponding file descriptors in the calling process.)
7dd887
 Subsequent operations that open or close file descriptors,
7dd887
 or change file descriptor flags,
7dd887
 performed by either the calling
7dd887
 process or the child process do not affect the other process.
7dd887
+Note, however,
7dd887
+that the duplicated file descriptors in the child refer to the same open file
7dd887
+descriptions as the corresponding file descriptors in the calling process,
7dd887
+and thus share file offsets and file status flags (see
7dd887
+.BR open (2)).
7dd887
 .TP
7dd887
 .BR CLONE_FS " (since Linux 2.0)"
7dd887
 If
7dd887
 .B CLONE_FS
7dd887
-is set, the caller and the child process share the same file system
7dd887
+is set, the caller and the child process share the same filesystem
7dd887
 information.
7dd887
-This includes the root of the file system, the current
7dd887
+This includes the root of the filesystem, the current
7dd887
 working directory, and the umask.
7dd887
 Any call to
7dd887
 .BR chroot (2),
7dd887
@@ -238,7 +218,7 @@ other process.
7dd887
 
7dd887
 If
7dd887
 .B CLONE_FS
7dd887
-is not set, the child process works on a copy of the file system
7dd887
+is not set, the child process works on a copy of the filesystem
7dd887
 information of the calling process at the time of the
7dd887
 .BR clone ()
7dd887
 call.
7dd887
@@ -258,7 +238,7 @@ If this flag is not set, then (as with
7dd887
 the new process has its own I/O context.
7dd887
 
7dd887
 .\" The following based on text from Jens Axboe
7dd887
-The I/O context is the I/O scope of the disk scheduler (i.e,
7dd887
+The I/O context is the I/O scope of the disk scheduler (i.e.,
7dd887
 what the I/O scheduler uses to model scheduling of a process's I/O).
7dd887
 If processes share the same I/O context,
7dd887
 they are treated as one by the I/O scheduler.
7dd887
@@ -288,7 +268,7 @@ the process is created in the same IPC namespace as
7dd887
 the calling process.
7dd887
 This flag is intended for the implementation of containers.
7dd887
 
7dd887
-An IPC namespace provides an isolated view of System V IPC objects (see
7dd887
+An IPC namespace provides an isolated view of System\ V IPC objects (see
7dd887
 .BR svipc (7))
7dd887
 and (since Linux 2.6.30)
7dd887
 .\" commit 7eafd7c74c3f2e67c27621b987b28397110d643f
7dd887
@@ -308,17 +288,17 @@ When an IPC namespace is destroyed
7dd887
 (i.e., when the last process that is a member of the namespace terminates),
7dd887
 all IPC objects in the namespace are automatically destroyed.
7dd887
 
7dd887
-Use of this flag requires: a kernel configured with the
7dd887
-.B CONFIG_SYSVIPC
7dd887
-and
7dd887
-.B CONFIG_IPC_NS
7dd887
-options and that the process be privileged
7dd887
-.RB ( CAP_SYS_ADMIN ).
7dd887
+Only a privileged process
7dd887
+.RB ( CAP_SYS_ADMIN )
7dd887
+can employ
7dd887
+.BR CLONE_NEWIPC .
7dd887
 This flag can't be specified in conjunction with
7dd887
 .BR CLONE_SYSVSEM .
7dd887
+
7dd887
+For further information on IPC namespaces, see
7dd887
+.BR namespaces (7).
7dd887
 .TP
7dd887
 .BR CLONE_NEWNET " (since Linux 2.6.24)"
7dd887
-.\" FIXME Check when the implementation was completed
7dd887
 (The implementation of this flag was completed only
7dd887
 by about kernel version 2.6.29.)
7dd887
 
7dd887
@@ -326,7 +306,7 @@ If
7dd887
 .B CLONE_NEWNET
7dd887
 is set, then create the process in a new network namespace.
7dd887
 If this flag is not set, then (as with
7dd887
-.BR fork (2)),
7dd887
+.BR fork (2))
7dd887
 the process is created in the same network namespace as
7dd887
 the calling process.
7dd887
 This flag is intended for the implementation of containers.
7dd887
@@ -341,7 +321,7 @@ directory trees, sockets, etc.).
7dd887
 A physical network device can live in exactly one
7dd887
 network namespace.
7dd887
 A virtual network device ("veth") pair provides a pipe-like abstraction
7dd887
-.\" FIXME Add pointer to veth(4) page when it is eventually completed
7dd887
+.\" FIXME . Add pointer to veth(4) page when it is eventually completed
7dd887
 that can be used to create tunnels between network namespaces,
7dd887
 and can be used to create a bridge to a physical network device
7dd887
 in another namespace.
7dd887
@@ -350,54 +330,41 @@ When a network namespace is freed
7dd887
 (i.e., when the last process in the namespace terminates),
7dd887
 its physical network devices are moved back to the
7dd887
 initial network namespace (not to the parent of the process).
7dd887
+For further information on network namespaces, see
7dd887
+.BR namespaces (7).
7dd887
 
7dd887
-Use of this flag requires: a kernel configured with the
7dd887
-.B CONFIG_NET_NS
7dd887
-option and that the process be privileged
7dd887
-.RB ( CAP_SYS_ADMIN ).
7dd887
+Only a privileged process
7dd887
+.RB ( CAP_SYS_ADMIN )
7dd887
+can employ
7dd887
+.BR CLONE_NEWNET .
7dd887
 .TP
7dd887
 .BR CLONE_NEWNS " (since Linux 2.4.19)"
7dd887
-Start the child in a new mount namespace.
7dd887
-
7dd887
-Every process lives in a mount namespace.
7dd887
-The
7dd887
-.I namespace
7dd887
-of a process is the data (the set of mounts) describing the file hierarchy
7dd887
-as seen by that process.
7dd887
-After a
7dd887
-.BR fork (2)
7dd887
-or
7dd887
-.BR clone ()
7dd887
-where the
7dd887
-.B CLONE_NEWNS
7dd887
-flag is not set, the child lives in the same mount
7dd887
-namespace as the parent.
7dd887
-The system calls
7dd887
-.BR mount (2)
7dd887
-and
7dd887
-.BR umount (2)
7dd887
-change the mount namespace of the calling process, and hence affect
7dd887
-all processes that live in the same namespace, but do not affect
7dd887
-processes in a different mount namespace.
7dd887
-
7dd887
-After a
7dd887
-.BR clone ()
7dd887
-where the
7dd887
+If
7dd887
 .B CLONE_NEWNS
7dd887
-flag is set, the cloned child is started in a new mount namespace,
7dd887
+is set, the cloned child is started in a new mount namespace,
7dd887
 initialized with a copy of the namespace of the parent.
7dd887
-
7dd887
-Only a privileged process (one having the \fBCAP_SYS_ADMIN\fP capability)
7dd887
-may specify the
7dd887
+If
7dd887
 .B CLONE_NEWNS
7dd887
-flag.
7dd887
+is not set, the child lives in the same mount
7dd887
+namespace as the parent.
7dd887
+
7dd887
+Only a privileged process
7dd887
+.RB ( CAP_SYS_ADMIN )
7dd887
+can employ
7dd887
+.BR CLONE_NEWNS .
7dd887
 It is not permitted to specify both
7dd887
 .B CLONE_NEWNS
7dd887
 and
7dd887
 .B CLONE_FS
7dd887
+.\" See https://lwn.net/Articles/543273/
7dd887
 in the same
7dd887
 .BR clone ()
7dd887
 call.
7dd887
+
7dd887
+For further information on mount namespaces, see
7dd887
+.BR namespaces (7)
7dd887
+and
7dd887
+.BR mount_namespaces (7).
7dd887
 .TP
7dd887
 .BR CLONE_NEWPID " (since Linux 2.6.24)"
7dd887
 .\" This explanation draws a lot of details from
7dd887
@@ -411,73 +378,74 @@ If
7dd887
 .B CLONE_NEWPID
7dd887
 is set, then create the process in a new PID namespace.
7dd887
 If this flag is not set, then (as with
7dd887
-.BR fork (2)),
7dd887
+.BR fork (2))
7dd887
 the process is created in the same PID namespace as
7dd887
 the calling process.
7dd887
 This flag is intended for the implementation of containers.
7dd887
 
7dd887
-A PID namespace provides an isolated environment for PIDs:
7dd887
-PIDs in a new namespace start at 1,
7dd887
-somewhat like a standalone system, and calls to
7dd887
-.BR fork (2),
7dd887
-.BR vfork (2),
7dd887
+For further information on PID namespaces, see
7dd887
+.BR namespaces (7)
7dd887
+and
7dd887
+.BR pid_namespaces (7).
7dd887
+
7dd887
+Only a privileged process
7dd887
+.RB ( CAP_SYS_ADMIN )
7dd887
+can employ
7dd887
+.BR CLONE_NEWPID .
7dd887
+This flag can't be specified in conjunction with
7dd887
+.BR CLONE_THREAD
7dd887
 or
7dd887
+.BR CLONE_PARENT .
7dd887
+.TP
7dd887
+.BR CLONE_NEWUSER
7dd887
+(This flag first became meaningful for
7dd887
 .BR clone ()
7dd887
-will produce processes with PIDs that are unique within the namespace.
7dd887
+in Linux 2.6.23,
7dd887
+the current
7dd887
+.BR clone ()
7dd887
+semantics were merged in Linux 3.5,
7dd887
+and the final pieces to make the user namespaces completely usable were
7dd887
+merged in Linux 3.8.)
7dd887
 
7dd887
-The first process created in a new namespace
7dd887
-(i.e., the process created using the
7dd887
-.BR CLONE_NEWPID
7dd887
-flag) has the PID 1, and is the "init" process for the namespace.
7dd887
-Children that are orphaned within the namespace will be reparented
7dd887
-to this process rather than
7dd887
-.BR init (8).
7dd887
-Unlike the traditional
7dd887
-.B init
7dd887
-process, the "init" process of a PID namespace can terminate,
7dd887
-and if it does, all of the processes in the namespace are terminated.
7dd887
-
7dd887
-PID namespaces form a hierarchy.
7dd887
-When a new PID namespace is created,
7dd887
-the processes in that namespace are visible
7dd887
-in the PID namespace of the process that created the new namespace;
7dd887
-analogously, if the parent PID namespace is itself
7dd887
-the child of another PID namespace,
7dd887
-then processes in the child and parent PID namespaces will both be
7dd887
-visible in the grandparent PID namespace.
7dd887
-Conversely, the processes in the "child" PID namespace do not see
7dd887
-the processes in the parent namespace.
7dd887
-The existence of a namespace hierarchy means that each process
7dd887
-may now have multiple PIDs:
7dd887
-one for each namespace in which it is visible;
7dd887
-each of these PIDs is unique within the corresponding namespace.
7dd887
-(A call to
7dd887
-.BR getpid (2)
7dd887
-always returns the PID associated with the namespace in which
7dd887
-the process lives.)
7dd887
-
7dd887
-After creating the new namespace,
7dd887
-it is useful for the child to change its root directory
7dd887
-and mount a new procfs instance at
7dd887
-.I /proc
7dd887
-so that tools such as
7dd887
-.BR ps (1)
7dd887
-work correctly.
7dd887
-.\" mount -t proc proc /proc
7dd887
-(If
7dd887
-.BR CLONE_NEWNS
7dd887
-is also included in
7dd887
-.IR flags ,
7dd887
-then it isn't necessary to change the root directory:
7dd887
-a new procfs instance can be mounted directly over
7dd887
-.IR /proc .)
7dd887
+If
7dd887
+.B CLONE_NEWUSER
7dd887
+is set, then create the process in a new user namespace.
7dd887
+If this flag is not set, then (as with
7dd887
+.BR fork (2))
7dd887
+the process is created in the same user namespace as the calling process.
7dd887
+
7dd887
+For further information on user namespaces, see
7dd887
+.BR namespaces (7)
7dd887
+and
7dd887
+.BR user_namespaces (7)
7dd887
+
7dd887
+Before Linux 3.8, use of
7dd887
+.BR CLONE_NEWUSER
7dd887
+required that the caller have three capabilities:
7dd887
+.BR CAP_SYS_ADMIN ,
7dd887
+.BR CAP_SETUID ,
7dd887
+and
7dd887
+.BR CAP_SETGID .
7dd887
+.\" Before Linux 2.6.29, it appears that only CAP_SYS_ADMIN was needed
7dd887
+Starting with Linux 3.8,
7dd887
+no privileges are needed to create a user namespace.
7dd887
 
7dd887
-Use of this flag requires: a kernel configured with the
7dd887
-.B CONFIG_PID_NS
7dd887
-option and that the process be privileged
7dd887
-.RB ( CAP_SYS_ADMIN ).
7dd887
 This flag can't be specified in conjunction with
7dd887
-.BR CLONE_THREAD .
7dd887
+.BR CLONE_THREAD
7dd887
+or
7dd887
+.BR CLONE_PARENT .
7dd887
+For security reasons,
7dd887
+.\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
7dd887
+.\" https://lwn.net/Articles/543273/
7dd887
+.\" The fix actually went into 3.9 and into 3.8.3. However, user namespaces
7dd887
+.\" were, for practical purposes, unusable in earlier 3.8.x because of the
7dd887
+.\" various filesystems that didn't support userns.
7dd887
+.BR CLONE_NEWUSER
7dd887
+cannot be specified in conjunction with
7dd887
+.BR CLONE_FS .
7dd887
+
7dd887
+For further information on user namespaces, see
7dd887
+.BR user_namespaces (7).
7dd887
 .TP
7dd887
 .BR CLONE_NEWUTS " (since Linux 2.6.19)"
7dd887
 If
7dd887
@@ -486,27 +454,29 @@ is set, then create the process in a new UTS namespace,
7dd887
 whose identifiers are initialized by duplicating the identifiers
7dd887
 from the UTS namespace of the calling process.
7dd887
 If this flag is not set, then (as with
7dd887
-.BR fork (2)),
7dd887
+.BR fork (2))
7dd887
 the process is created in the same UTS namespace as
7dd887
 the calling process.
7dd887
 This flag is intended for the implementation of containers.
7dd887
 
7dd887
 A UTS namespace is the set of identifiers returned by
7dd887
 .BR uname (2);
7dd887
-among these, the domain name and the host name can be modified by
7dd887
+among these, the domain name and the hostname can be modified by
7dd887
 .BR setdomainname (2)
7dd887
 and
7dd887
-.BR
7dd887
 .BR sethostname (2),
7dd887
 respectively.
7dd887
 Changes made to the identifiers in a UTS namespace
7dd887
 are visible to all other processes in the same namespace,
7dd887
 but are not visible to processes in other UTS namespaces.
7dd887
 
7dd887
-Use of this flag requires: a kernel configured with the
7dd887
-.B CONFIG_UTS_NS
7dd887
-option and that the process be privileged
7dd887
-.RB ( CAP_SYS_ADMIN ).
7dd887
+Only a privileged process
7dd887
+.RB ( CAP_SYS_ADMIN )
7dd887
+can employ
7dd887
+.BR CLONE_NEWUTS .
7dd887
+
7dd887
+For further information on UTS namespaces, see
7dd887
+.BR namespaces (7).
7dd887
 .TP
7dd887
 .BR CLONE_PARENT " (since Linux 2.3.12)"
7dd887
 If
7dd887
@@ -530,12 +500,15 @@ is set, then the parent of the calling process, rather than the
7dd887
 calling process itself, will be signaled.
7dd887
 .TP
7dd887
 .BR CLONE_PARENT_SETTID " (since Linux 2.5.49)"
7dd887
-Store child thread ID at location
7dd887
+Store the child thread ID at the location
7dd887
 .I ptid
7dd887
-in parent and child memory.
7dd887
+in the parent's memory.
7dd887
 (In Linux 2.5.32-2.5.48 there was a flag
7dd887
 .B CLONE_SETTID
7dd887
 that did this.)
7dd887
+The store operation completes before
7dd887
+.BR clone ()
7dd887
+returns control to user space.
7dd887
 .TP
7dd887
 .BR CLONE_PID " (obsolete)"
7dd887
 If
7dd887
@@ -547,6 +520,7 @@ of not much use.
7dd887
 Since 2.3.21 this flag can be
7dd887
 specified only by the system boot process (PID 0).
7dd887
 It disappeared in Linux 2.5.16.
7dd887
+Since then, the kernel silently ignores it without error.
7dd887
 .TP
7dd887
 .BR CLONE_PTRACE " (since Linux 2.2)"
7dd887
 If
7dd887
@@ -556,11 +530,25 @@ then trace the child also (see
7dd887
 .BR ptrace (2)).
7dd887
 .TP
7dd887
 .BR CLONE_SETTLS " (since Linux 2.5.32)"
7dd887
-The
7dd887
+The TLS (Thread Local Storage) descriptor is set to
7dd887
+.I newtls.
7dd887
+
7dd887
+The interpretation of
7dd887
 .I newtls
7dd887
-argument is the new TLS (Thread Local Storage) descriptor.
7dd887
+and the resulting effect is architecture dependent.
7dd887
+On x86,
7dd887
+.I newtls
7dd887
+is interpreted as a
7dd887
+.IR "struct user_desc *"
7dd887
 (See
7dd887
-.BR set_thread_area (2).)
7dd887
+.BR set_thread_area (2)).
7dd887
+On x86_64 it is the new value to be set for the %fs base register
7dd887
+(See the
7dd887
+.I ARCH_SET_FS
7dd887
+argument to
7dd887
+.BR arch_prctl (2)).
7dd887
+On architectures with a dedicated TLS register, it is the new value
7dd887
+of that register.
7dd887
 .TP
7dd887
 .BR CLONE_SIGHAND " (since Linux 2.0)"
7dd887
 If
7dd887
@@ -612,16 +600,26 @@ from Linux 2.6.25 onward,
7dd887
 and was
7dd887
 .I removed
7dd887
 altogether in Linux 2.6.38.
7dd887
+Since then, the kernel silently ignores it without error.
7dd887
 .\" glibc 2.8 removed this defn from bits/sched.h
7dd887
 .TP
7dd887
 .BR CLONE_SYSVSEM " (since Linux 2.5.10)"
7dd887
 If
7dd887
 .B CLONE_SYSVSEM
7dd887
 is set, then the child and the calling process share
7dd887
-a single list of System V semaphore undo values (see
7dd887
+a single list of System V semaphore adjustment
7dd887
+.RI ( semadj )
7dd887
+values (see
7dd887
 .BR semop (2)).
7dd887
-If this flag is not set, then the child has a separate undo list,
7dd887
-which is initially empty.
7dd887
+In this case, the shared list accumulates
7dd887
+.I semadj
7dd887
+values across all processes sharing the list,
7dd887
+and semaphore adjustments are performed only when the last process
7dd887
+that is sharing the list terminates (or ceases sharing the list using
7dd887
+.BR unshare (2)).
7dd887
+If this flag is not set, then the child has a separate
7dd887
+.I semadj
7dd887
+list that is initially empty.
7dd887
 .TP
7dd887
 .BR CLONE_THREAD " (since Linux 2.4.0-test8)"
7dd887
 If
7dd887
@@ -703,7 +701,12 @@ must also include
7dd887
 .B CLONE_SIGHAND
7dd887
 if
7dd887
 .B CLONE_THREAD
7dd887
-is specified.
7dd887
+is specified
7dd887
+(and note that, since Linux 2.6.0-test6,
7dd887
+.BR CLONE_SIGHAND
7dd887
+also requires
7dd887
+.BR CLONE_VM
7dd887
+to be included).
7dd887
 
7dd887
 Signals may be sent to a thread group as a whole (i.e., a TGID) using
7dd887
 .BR kill (2),
7dd887
@@ -761,7 +764,7 @@ or
7dd887
 
7dd887
 If
7dd887
 .B CLONE_VFORK
7dd887
-is not set then both the calling process and the child are schedulable
7dd887
+is not set, then both the calling process and the child are schedulable
7dd887
 after the call, and an application should not rely on execution occurring
7dd887
 in any particular order.
7dd887
 .TP
7dd887
@@ -786,7 +789,7 @@ space of the calling process at the time of
7dd887
 Memory writes or file mappings/unmappings performed by one of the
7dd887
 processes do not affect the other, as with
7dd887
 .BR fork (2).
7dd887
-.SS The raw system call interface
7dd887
+.SS C library/kernel differences
7dd887
 The raw
7dd887
 .BR clone ()
7dd887
 system call corresponds more closely to
7dd887
@@ -801,16 +804,58 @@ arguments of the
7dd887
 .BR clone ()
7dd887
 wrapper function are omitted.
7dd887
 Furthermore, the argument order changes.
7dd887
-The raw system call interface on x86 and many other architectures is roughly:
7dd887
+In addition, there are variations across architectures.
7dd887
+
7dd887
+The raw system call interface on x86-64 and some other architectures
7dd887
+(including sh, tile, and alpha) is roughly:
7dd887
+
7dd887
 .in +4
7dd887
 .nf
7dd887
+.BI "long clone(unsigned long " flags ", void *" child_stack ,
7dd887
+.BI "           int *" ptid ", int *" ctid ,
7dd887
+.BI "           unsigned long " newtls );
7dd887
+.fi
7dd887
+.in
7dd887
+
7dd887
+On x86-32, and several other common architectures
7dd887
+(including score, ARM, ARM 64, PA-RISC, arc, Power PC, xtensa,
7dd887
+and MIPS),
7dd887
+.\" CONFIG_CLONE_BACKWARDS
7dd887
+the order of the last two arguments is reversed:
7dd887
 
7dd887
+.in +4
7dd887
+.nf
7dd887
 .BI "long clone(unsigned long " flags ", void *" child_stack ,
7dd887
-.BI "           void *" ptid ", void *" ctid ,
7dd887
-.BI "           struct pt_regs *" regs );
7dd887
+.BI "          int *" ptid ", unsigned long " newtls ,
7dd887
+.BI "          int *" ctid );
7dd887
+.fi
7dd887
+.in
7dd887
+
7dd887
+On the cris and s390 architectures,
7dd887
+.\" CONFIG_CLONE_BACKWARDS2
7dd887
+the order of the first two arguments is reversed:
7dd887
 
7dd887
+.in +4
7dd887
+.nf
7dd887
+.BI "long clone(void *" child_stack ", unsigned long " flags ,
7dd887
+.BI "           int *" ptid ", int *" ctid ,
7dd887
+.BI "           unsigned long " newtls );
7dd887
+.fi
7dd887
+.in
7dd887
+
7dd887
+On the microblaze architecture,
7dd887
+.\" CONFIG_CLONE_BACKWARDS3
7dd887
+an additional argument is supplied:
7dd887
+
7dd887
+.in +4
7dd887
+.nf
7dd887
+.BI "long clone(unsigned long " flags ", void *" child_stack ,
7dd887
+.BI "           int " stack_size , "\fR         /* Size of stack */"
7dd887
+.BI "           int *" ptid ", int *" ctid ,
7dd887
+.BI "           unsigned long " newtls );
7dd887
 .fi
7dd887
 .in
7dd887
+
7dd887
 Another difference for the raw system call is that the
7dd887
 .I child_stack
7dd887
 argument may be zero, in which case copy-on-write semantics ensure that the
7dd887
@@ -819,17 +864,13 @@ the stack.
7dd887
 In this case, for correct operation, the
7dd887
 .B CLONE_VM
7dd887
 option should not be specified.
7dd887
-
7dd887
-For some architectures, the order of the arguments for the system call
7dd887
-differs from that shown above.
7dd887
-On the score, microblaze, ARM, ARM 64, PA-RISC, arc, Power PC, xtensa,
7dd887
-and MIPS architectures,
7dd887
-the order of the fourth and fifth arguments is reversed.
7dd887
-On the cris and s390 architectures,
7dd887
-the order of the first and second arguments is reversed.
7dd887
+.\"
7dd887
 .SS blackfin, m68k, and sparc
7dd887
+.\" Mike Frysinger noted in a 2013 mail:
7dd887
+.\"     these arches don't define __ARCH_WANT_SYS_CLONE:
7dd887
+.\"     blackfin ia64 m68k sparc
7dd887
 The argument-passing conventions on
7dd887
-blackfin, m68k, and sparc are different from descriptions above.
7dd887
+blackfin, m68k, and sparc are different from the descriptions above.
7dd887
 For details, see the kernel (and glibc) source.
7dd887
 .SS ia64
7dd887
 On ia64, a different interface is used:
7dd887
@@ -883,7 +924,8 @@ will be set appropriately.
7dd887
 .SH ERRORS
7dd887
 .TP
7dd887
 .B EAGAIN
7dd887
-Too many processes are already running.
7dd887
+Too many processes are already running; see
7dd887
+.BR fork (2).
7dd887
 .TP
7dd887
 .B EINVAL
7dd887
 .B CLONE_SIGHAND
7dd887
@@ -908,6 +950,7 @@ was not.
7dd887
 .\" (Since Linux 2.6.0-test6.)
7dd887
 .TP
7dd887
 .B EINVAL
7dd887
+.\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
7dd887
 Both
7dd887
 .B CLONE_FS
7dd887
 and
7dd887
@@ -915,6 +958,14 @@ and
7dd887
 were specified in
7dd887
 .IR flags .
7dd887
 .TP
7dd887
+.BR EINVAL " (since Linux 3.9)"
7dd887
+Both
7dd887
+.B CLONE_NEWUSER
7dd887
+and
7dd887
+.B CLONE_FS
7dd887
+were specified in
7dd887
+.IR flags .
7dd887
+.TP
7dd887
 .B EINVAL
7dd887
 Both
7dd887
 .B CLONE_NEWIPC
7dd887
@@ -924,18 +975,25 @@ were specified in
7dd887
 .IR flags .
7dd887
 .TP
7dd887
 .B EINVAL
7dd887
-Both
7dd887
+One (or both) of
7dd887
 .BR CLONE_NEWPID
7dd887
-and
7dd887
+or
7dd887
+.BR CLONE_NEWUSER
7dd887
+and one (or both) of
7dd887
 .BR CLONE_THREAD
7dd887
+or
7dd887
+.BR CLONE_PARENT
7dd887
 were specified in
7dd887
 .IR flags .
7dd887
 .TP
7dd887
 .B EINVAL
7dd887
-Returned by
7dd887
+Returned by the glibc
7dd887
 .BR clone ()
7dd887
-when a zero value is specified for
7dd887
-.IR child_stack .
7dd887
+wrapper function when
7dd887
+.IR fn
7dd887
+or
7dd887
+.IR child_stack
7dd887
+is specified as NULL.
7dd887
 .TP
7dd887
 .B EINVAL
7dd887
 .BR CLONE_NEWIPC
7dd887
@@ -971,11 +1029,48 @@ but the kernel was not configured with the
7dd887
 .B CONFIG_UTS
7dd887
 option.
7dd887
 .TP
7dd887
+.B EINVAL
7dd887
+.I child_stack
7dd887
+is not aligned to a suitable boundary for this architecture.
7dd887
+For example, on aarch64,
7dd887
+.I child_stack
7dd887
+must be a multiple of 16.
7dd887
+.TP
7dd887
 .B ENOMEM
7dd887
 Cannot allocate sufficient memory to allocate a task structure for the
7dd887
 child, or to copy those parts of the caller's context that need to be
7dd887
 copied.
7dd887
 .TP
7dd887
+.BR ENOSPC " (since Linux 3.7)"
7dd887
+.\" commit f2302505775fd13ba93f034206f1e2a587017929
7dd887
+.B CLONE_NEWPID
7dd887
+was specified in flags,
7dd887
+but the limit on the nesting depth of PID namespaces
7dd887
+would have been exceeded; see
7dd887
+.BR pid_namespaces (7).
7dd887
+.TP
7dd887
+.BR ENOSPC " (since Linux 4.9; beforehand " EUSERS )
7dd887
+.B CLONE_NEWUSER
7dd887
+was specified in
7dd887
+.IR flags ,
7dd887
+and the call would cause the limit on the number of
7dd887
+nested user namespaces to be exceeded.
7dd887
+See
7dd887
+.BR user_namespaces (7).
7dd887
+
7dd887
+From Linux 3.11 to Linux 4.8, the error diagnosed in this case was
7dd887
+.BR EUSERS .
7dd887
+.TP
7dd887
+.BR ENOSPC " (since Linux 4.9)"
7dd887
+One of the values in
7dd887
+.I flags
7dd887
+specified the creation of a new user namespace,
7dd887
+but doing so would have caused the limit defined by the corresponding file in
7dd887
+.IR /proc/sys/user
7dd887
+to be exceeded.
7dd887
+For further details, see
7dd887
+.BR namespaces (7).
7dd887
+.TP
7dd887
 .B EPERM
7dd887
 .BR CLONE_NEWIPC ,
7dd887
 .BR CLONE_NEWNET ,
7dd887
@@ -989,22 +1084,62 @@ was specified by an unprivileged process (process without \fBCAP_SYS_ADMIN\fP).
7dd887
 .B CLONE_PID
7dd887
 was specified by a process other than process 0.
7dd887
 .TP
7dd887
+.B EPERM
7dd887
+.BR CLONE_NEWUSER
7dd887
+was specified in
7dd887
+.IR flags ,
7dd887
+but either the effective user ID or the effective group ID of the caller
7dd887
+does not have a mapping in the parent namespace (see
7dd887
+.BR user_namespaces (7)).
7dd887
+.TP
7dd887
+.BR EPERM " (since Linux 3.9)"
7dd887
+.\" commit 3151527ee007b73a0ebd296010f1c0454a919c7d
7dd887
+.B CLONE_NEWUSER
7dd887
+was specified in
7dd887
+.I flags
7dd887
+and the caller is in a chroot environment
7dd887
+.\" FIXME What is the rationale for this restriction?
7dd887
+(i.e., the caller's root directory does not match the root directory
7dd887
+of the mount namespace in which it resides).
7dd887
+.TP
7dd887
 .BR ERESTARTNOINTR " (since Linux 2.6.17)"
7dd887
+.\" commit 4a2c7a7837da1b91468e50426066d988050e4d56
7dd887
 System call was interrupted by a signal and will be restarted.
7dd887
 (This can be seen only during a trace.)
7dd887
-.SH VERSIONS
7dd887
-There is no entry for
7dd887
-.BR clone ()
7dd887
-in libc5.
7dd887
-glibc2 provides
7dd887
-.BR clone ()
7dd887
-as described in this manual page.
7dd887
+.TP
7dd887
+.BR EUSERS " (Linux 3.11 to Linux 4.8)"
7dd887
+.B CLONE_NEWUSER
7dd887
+was specified in
7dd887
+.IR flags ,
7dd887
+and the limit on the number of nested user namespaces would be exceeded.
7dd887
+See the discussion of the
7dd887
+.BR ENOSPC
7dd887
+error above.
7dd887
+.\" .SH VERSIONS
7dd887
+.\" There is no entry for
7dd887
+.\" .BR clone ()
7dd887
+.\" in libc5.
7dd887
+.\" glibc2 provides
7dd887
+.\" .BR clone ()
7dd887
+.\" as described in this manual page.
7dd887
 .SH CONFORMING TO
7dd887
 .BR clone ()
7dd887
 is Linux-specific and should not be used in programs
7dd887
 intended to be portable.
7dd887
 .SH NOTES
7dd887
-In the kernel 2.4.x series,
7dd887
+The
7dd887
+.BR kcmp (2)
7dd887
+system call can be used to test whether two processes share various
7dd887
+resources such as a file descriptor table,
7dd887
+System V semaphore undo operations, or a virtual address space.
7dd887
+
7dd887
+
7dd887
+Handlers registered using
7dd887
+.BR pthread_atfork (3)
7dd887
+are not executed during a call to
7dd887
+.BR clone ().
7dd887
+
7dd887
+In the Linux 2.4.x series,
7dd887
 .B CLONE_THREAD
7dd887
 generally does not make the parent of the new thread the same
7dd887
 as the parent of the calling process.
7dd887
@@ -1012,14 +1147,13 @@ However, for kernel versions 2.4.7 to 2.4.18 the
7dd887
 .B CLONE_THREAD
7dd887
 flag implied the
7dd887
 .B CLONE_PARENT
7dd887
-flag (as in kernel 2.6).
7dd887
+flag (as in Linux 2.6.0 and later).
7dd887
 
7dd887
 For a while there was
7dd887
 .B CLONE_DETACHED
7dd887
 (introduced in 2.5.32):
7dd887
 parent wants no child-exit signal.
7dd887
-In 2.6.2 the need to give this
7dd887
-together with
7dd887
+In Linux 2.6.2, the need to give this flag together with
7dd887
 .B CLONE_THREAD
7dd887
 disappeared.
7dd887
 This flag is still defined, but has no effect.
7dd887
@@ -1071,7 +1205,6 @@ To get the truth, it may be necessary to use code such as the following:
7dd887
 .\" https://bugzilla.redhat.com/show_bug.cgi?id=417521
7dd887
 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=6910
7dd887
 .SH EXAMPLE
7dd887
-.SS Create a child that executes in a separate UTS namespace
7dd887
 The following program demonstrates the use of
7dd887
 .BR clone ()
7dd887
 to create a child process that executes in a separate UTS namespace.
7dd887
@@ -1081,7 +1214,7 @@ making it possible to see that the hostname
7dd887
 differs in the UTS namespaces of the parent and child.
7dd887
 For an example of the use of this program, see
7dd887
 .BR setns (2).
7dd887
-
7dd887
+.SS Program source
7dd887
 .nf
7dd887
 #define _GNU_SOURCE
7dd887
 #include <sys/wait.h>
7dd887
@@ -1181,6 +1314,7 @@ main(int argc, char *argv[])
7dd887
 .BR unshare (2),
7dd887
 .BR wait (2),
7dd887
 .BR capabilities (7),
7dd887
+.BR namespaces (7),
7dd887
 .BR pthreads (7)
7dd887
 .SH COLOPHON
7dd887
 This page is part of release 3.53 of the Linux
7dd887
-- 
7dd887
2.7.4
7dd887