]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man2/prctl.2
pldd.1, bpf.2, chdir.2, clone.2, fanotify_init.2, fanotify_mark.2, intro.2, ipc.2...
[thirdparty/man-pages.git] / man2 / prctl.2
index 58f9daeb4a90bcc2193695cd545f7cf03da126c7..fdbea1baa126c29df978968f89dcefafed0fa787 100644 (file)
 .\" 2014-11-10 Dave Hansen, document PR_MPX_{EN,DIS}ABLE_MANAGEMENT
 .\"
 .\"
-.TH PRCTL 2 2016-07-17 "Linux" "Linux Programmer's Manual"
+.TH PRCTL 2 2019-08-02 "Linux" "Linux Programmer's Manual"
 .SH NAME
 prctl \- operations on a process
 .SH SYNOPSIS
 .nf
 .B #include <sys/prctl.h>
-.sp
+.PP
 .BI "int prctl(int " option ", unsigned long " arg2 ", unsigned long " arg3 ,
 .BI "          unsigned long " arg4 ", unsigned long " arg5 );
 .fi
@@ -71,7 +71,8 @@ The first argument can be:
 .TP
 .BR PR_CAP_AMBIENT " (since Linux 4.3)"
 .\" commit 58319057b7847667f0c9585b9de0e8932b0fdb08
-Reads or changes the ambient capability set, according to the value of
+Reads or changes the ambient capability set of the calling thread,
+according to the value of
 .IR arg2 ,
 which must be one of the following:
 .RS
@@ -111,6 +112,15 @@ In all of the above operations,
 and
 .I arg5
 must be specified as 0.
+.IP
+Higher-level interfaces layered on top of the above operations are
+provided in the
+.BR libcap (3)
+library in the form of
+.BR cap_get_ambient (3),
+.BR cap_set_ambient (3),
+and
+.BR cap_reset_ambient (3).
 .TP
 .BR PR_CAPBSET_READ " (since Linux 2.6.25)"
 Return (as the function result) 1 if the capability specified in
@@ -123,11 +133,16 @@ The capability bounding set dictates
 whether the process can receive the capability through a
 file's permitted capability set on a subsequent call to
 .BR execve (2).
-
+.IP
 If the capability specified in
 .I arg2
 is not valid, then the call fails with the error
 .BR EINVAL .
+.IP
+A higher-level interface layered on top of this operation is provided in the
+.BR libcap (3)
+library in the form of
+.BR cap_get_bound (3).
 .TP
 .BR PR_CAPBSET_DROP " (since Linux 2.6.25)"
 If the calling thread has the
@@ -137,7 +152,7 @@ capability within its user namespace, then drop the capability specified by
 from the calling thread's capability bounding set.
 Any children of the calling thread will inherit the newly
 reduced bounding set.
-
+.IP
 The call fails with the error:
 .B EPERM
 if the calling thread does not have the
@@ -149,6 +164,11 @@ does not represent a valid capability; or
 .BR EINVAL
 if file capabilities are not enabled in the kernel,
 in which case bounding sets are not supported.
+.IP
+A higher-level interface layered on top of this operation is provided in the
+.BR libcap (3)
+library in the form of
+.BR cap_drop_bound (3).
 .TP
 .BR PR_SET_CHILD_SUBREAPER " (since Linux 3.4)"
 .\" commit ebec18a6d3aa1e7d84aab16225e87fd25170ec2b
@@ -159,22 +179,42 @@ set the "child subreaper" attribute of the calling process;
 if
 .I arg2
 is zero, unset the attribute.
-
-When a process is marked as a child subreaper,
-all of the children that it creates, and their descendants,
-will be marked as having a subreaper.
-In effect, a subreaper fulfills the role of
+.IP
+A subreaper fulfills the role of
 .BR init (1)
 for its descendant processes.
-Upon termination of a process
-that is orphaned (i.e., its immediate parent has already terminated)
-and marked as having a subreaper,
-the nearest still living ancestor subreaper
+When a process becomes orphaned
+(i.e., its immediate parent terminates)
+then that process will be reparented to
+the nearest still living ancestor subreaper.
+Subsequently, calls to
+.BR getppid ()
+in the orphaned process will now return the PID of the subreaper process,
+and when the orphan terminates, it is the subreaper process that
 will receive a
 .BR SIGCHLD
 signal and will be able to
 .BR wait (2)
 on the process to discover its termination status.
+.IP
+The setting of the "child subreaper" attribute
+is not inherited by children created by
+.BR fork (2)
+and
+.BR clone (2).
+The setting is preserved across
+.BR execve (2).
+.IP
+Establishing a subreaper process is useful in session management frameworks
+where a hierarchical group of processes is managed by a subreaper process
+that needs to be informed when one of the processes\(emfor example,
+a double-forked daemon\(emterminates
+(perhaps so that it can restart that process).
+Some
+.BR init (1)
+frameworks (e.g.,
+.BR systemd (1))
+employ a subreaper process for similar reasons.
 .TP
 .BR PR_GET_CHILD_SUBREAPER " (since Linux 3.4)"
 Return the "child subreaper" setting of the caller,
@@ -185,7 +225,7 @@ in the location pointed to by
 Set the state of the "dumpable" flag,
 which determines whether core dumps are produced for the calling process
 upon delivery of a signal whose default behavior is to produce a core dump.
-
+.IP
 In kernels up to and including 2.6.12,
 .I arg2
 must be either 0
@@ -207,7 +247,7 @@ for security reasons, this feature has been removed.
 .I /proc/sys/fs/\:suid_dumpable
 in
 .BR proc (5).)
-
+.IP
 Normally, this flag is set to 1.
 However, it is reset to the current value contained in the file
 .IR /proc/sys/fs/\:suid_dumpable
@@ -223,9 +263,16 @@ The process's filesystem user or group ID is changed (see
 .IP *
 The process executes
 .RB ( execve (2))
-a set-user-ID or set-group-ID program,
-or a program that has capabilities (see
-.BR capabilities (7)).
+a set-user-ID or set-group-ID program, resulting in a change
+of either the effective user ID or the effective group ID.
+.IP *
+The process executes
+.RB ( execve (2))
+a program that has file capabilities (see
+.BR capabilities (7)),
+.\" See kernel/cred.c::commit_creds()
+but only if the permitted capabilities
+gained exceed those already permitted for the process.
 .\" Also certain namespace operations;
 .RE
 .IP
@@ -235,7 +282,7 @@ Processes that are not dumpable can not be attached via
 see
 .BR ptrace (2)
 for further details.
-
+.IP
 If a process is not dumpable,
 the ownership of files in the process's
 .IR /proc/[pid]
@@ -263,109 +310,127 @@ or
 Return the endian-ness of the calling process,
 in the location pointed to by
 .IR "(int\ *) arg2" .
-.\" 9791554b45a2acc28247f66a5fd5bbc212a6b8c8
 .TP
 .BR PR_SET_FP_MODE " (since Linux 4.0, only on MIPS)"
-On MIPS, user land code can be built using ABI which permits linking
-with a code with a more restrictive floating point requirements.
-For example, user land code may be built to target the O32 FPXX ABI
+.\" commit 9791554b45a2acc28247f66a5fd5bbc212a6b8c8
+On the MIPS architecture,
+user-space code can be built using an ABI which permits linking
+with code that has more restrictive floating-point (FP) requirements.
+For example, user-space code may be built to target the O32 FPXX ABI
 and linked with code built for either one of the more restrictive
-FP32 or FP64.
+FP32 or FP64 ABIs.
 When more restrictive code is linked in,
-the overall requirement for the process is to use this more
-restrictive floating point mode.
-Since kernel has no means of knowing in advance
-which mode process should be executed in,
-and having possibility that these restrictions can
-be changed during the process' lifetime,
-the ability to control it from the user space via this option is provided.
-
+the overall requirement for the process is to use the more
+restrictive floating-point mode.
+.IP
+Because the kernel has no means of knowing in advance
+which mode the process should be executed in,
+and because these restrictions can
+change over the lifetime of the process, the
+.B PR_SET_FP_MODE
+operation is provided to allow control of the floating-point mode
+from user space.
+.IP
 .\" https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking
 The
 .I (unsigned int) arg2
-argument is a bit mask describing floating point mode used:
+argument is a bit mask describing the floating-point mode used:
 .RS
 .TP
-.BR PR_FP_MODE_FR " = " "(1 << 0)"
+.BR PR_FP_MODE_FR
 When this bit is
 .I unset
 (so called
 .BR FR=0 " or " FR0
-mode), 32 FP registers are 32-bit wide,
-and 64-bit registers are represented as pair of registers
+mode), the 32 floating-point registers are 32 bits wide,
+and 64-bit registers are represented as pair of registers
 (even- and odd- numbered,
-with even-numbered register containing lower 32 bits,
-and odd-numbered register containing higher 32 bits).
+with the even-numbered register containing the lower 32 bits,
+and the odd-numbered register containing the higher 32 bits).
+.IP
 When this bit is
 .I set
-(on supported hardware), 32 FP registers are 64-bit wide (so called
+(on supported hardware),
+the 32 floating-point registers are 64 bits wide (so called
 .BR FR=1 " or " FR1
-mode)
+mode).
 Note that modern MIPS implementations (MIPS R6 and newer) support
 .B FR=1
 mode only.
-
-Applications that use O32 FP32 ABI can operate only when this bit is
+.IP
+.IP
+Applications that use the O32 FP32 ABI can operate only when this bit is
 .I unset
 .RB ( FR=0 ;
 or they can be used with FRE enabled, see below).
-Applications that use O32 FP64 ABI (and O32 FP64A ABI, which exists for
-providing ability to operate with existing FP32 code; see below) can operate
-only when this bit is
+Applications that use the O32 FP64 ABI
+(and the O32 FP64A ABI, which exists to
+provide the ability to operate with existing FP32 code; see below)
+can operate only when this bit is
 .I set
 .RB ( FR=1 ).
-Applications that use O32 FPXX ABI can operate in both cases.
+Applications that use the O32 FPXX ABI can operate with either
+.BR FR=0
+or
+.BR FR=1 .
 .TP
-.BR PR_FP_MODE_FRE " = " "(1 << 1)"
-Compatibility with 32-bit FP mode.
+.BR PR_FP_MODE_FRE
+Enable emulation of 32-bit floating-point mode.
 When this mode is enabled,
-it emulates 32-bit FP operations by raising reserved instruction exception
+it emulates 32-bit floating-point operations
+by raising a reserved-instruction exception
 on every instruction that uses 32-bit formats and
-kernel then handles the instruction in software
-(the problem lies in discrepancy of handling odd-numbered registers
-which are high 32 bits of 64-bit registers with even numbers in
+the kernel then handles the instruction in software.
+(The problem lies in the discrepancy of handling odd-numbered registers
+which are the high 32 bits of 64-bit registers with even numbers in
 .B FR=0
-mode and lower 32-bit parts of odd-numbered 64-bit registers in
+mode and the lower 32-bit parts of odd-numbered 64-bit registers in
 .B FR=1
-mode).
-Enabling of this bit is needed when code with O32 FP32 ABI should operate
-with code with compatible O32 FPXX or O32 FP64A ABIs (which require
+mode.)
+Enabling this bit is necessary when code with the O32 FP32 ABI should operate
+with code with compatible the O32 FPXX or O32 FP64A ABIs (which require
 .B FR=1
 FPU mode) or when it is executed on newer hardware (MIPS R6 onwards)
 which lacks
 .B FR=0
-mode support when binary with FP32 ABI is used.
+mode support when a binary with the FP32 ABI is used.
 .IP
-Note that this mode only makes sense when FPU is in 64-bit mode
-.RB ( FR=1 .)
+Note that this mode makes sense only when the FPU is in 64-bit mode
+.RB ( FR=1 ).
 .IP
-Note that usage of emulation inherently has a significant performance hit
+Note that the use of emulation inherently has a significant performance hit
 and should be avoided if possible.
 .RE
 .IP
-Note that for N32/N64 ABI is a different story and
-does not need FPU emulation and always operates in
+In the N32/N64 ABI, 64-bit floating-point mode is always used,
+so FPU emulation is not required and the FPU always operates in
 .B FR=1
 mode.
 .IP
-This option is mainly intended for use by dynamic loader,
-but may be of use by applications in case library loading
-during runtime (via
-.BR dlopen (3),
-for example) is used.
+This option is mainly intended for use by the dynamic linker
+.RB ( ld.so (8)).
 .IP
-Arguments
-.IR arg3 ", " arg4 " and " arg5
+The arguments
+.IR arg3 ,
+.IR arg4 ,
+and
+.IR arg5
 are ignored.
 .TP
 .BR PR_GET_FP_MODE " (since Linux 4.0, only on MIPS)"
-Get current floating point mode (see description for
+Get the current floating-point mode (see the description of
 .B PR_SET_FP_MODE
 for details).
-
-Call returns bit mask which represents current FP mode in case of success.
-Arguments
-.IR arg2 ", " arg3 ", " arg4 " and " arg5
+.IP
+On success,
+the call returns a bit mask which represents the current floating-point mode.
+.IP
+The arguments
+.IR arg2 ,
+.IR arg3 ,
+.IR arg4 ,
+and
+.IR arg5
 are ignored.
 .TP
 .BR PR_SET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)"
@@ -402,29 +467,24 @@ in the location pointed to by
 .IR "(int\ *) arg2" .
 .TP
 .BR PR_SET_KEEPCAPS " (since Linux 2.2.18)"
-Set the state of the thread's "keep capabilities" flag,
-which determines whether the thread's permitted
-capability set is cleared when a change is made to the thread's user IDs
-such that the thread's real UID, effective UID, and saved set-user-ID
-all become nonzero when at least one of them previously had the value 0.
-By default, the permitted capability set is cleared when such a change is made;
-setting the "keep capabilities" flag prevents it from being cleared.
+Set the state of the calling thread's "keep capabilities" flag.
+The effect of this flag is described in
+.BR capabilities (7).
 .I arg2
-must be either 0 (permitted capabilities are cleared)
-or 1 (permitted capabilities are kept).
-(A thread's
-.I effective
-capability set is always cleared when such a credential change is made,
-regardless of the setting of the "keep capabilities" flag.)
+must be either 0 (clear the flag)
+or 1 (set the flag).
 The "keep capabilities" value will be reset to 0 on subsequent calls to
 .BR execve (2).
 .TP
 .BR PR_GET_KEEPCAPS " (since Linux 2.2.18)"
 Return (as the function result) the current state of the calling thread's
 "keep capabilities" flag.
+See
+.BR capabilities (7)
+for a description of this flag.
 .TP
 .BR PR_MCE_KILL " (since Linux 2.6.32)"
-Set the machine check memory corruption kill policy for the current thread.
+Set the machine check memory corruption kill policy for the calling thread.
 If
 .I arg2
 is
@@ -478,9 +538,7 @@ Usually these fields are set by the kernel and dynamic loader (see
 for more information) and a regular application should not use this feature.
 However, there are cases, such as self-modifying programs,
 where a program might find it useful to change its own memory map.
-This feature is available only if the kernel is built with the
-.BR CONFIG_CHECKPOINT_RESTORE
-option enabled.
+.IP
 The calling process must have the
 .BR CAP_SYS_RESOURCE
 capability.
@@ -489,12 +547,23 @@ The value in
 is one of the options below, while
 .I arg3
 provides a new value for the option.
+The
+.I arg4
+and
+.I arg5
+arguments must be zero if unused.
+.IP
+Before Linux 3.10,
+.\" commit 52b3694157e3aa6df871e283115652ec6f2d31e0
+this feature is available only if the kernel is built with the
+.BR CONFIG_CHECKPOINT_RESTORE
+option enabled.
 .RS
 .TP
 .BR PR_SET_MM_START_CODE
 Set the address above which the program text can run.
 The corresponding memory area must be readable and executable,
-but not writable or sharable (see
+but not writable or shareable (see
 .BR mprotect (2)
 and
 .BR mmap (2)
@@ -503,19 +572,19 @@ for more information).
 .BR PR_SET_MM_END_CODE
 Set the address below which the program text can run.
 The corresponding memory area must be readable and executable,
-but not writable or sharable.
+but not writable or shareable.
 .TP
 .BR PR_SET_MM_START_DATA
 Set the address above which initialized and
 uninitialized (bss) data are placed.
 The corresponding memory area must be readable and writable,
-but not executable or sharable.
+but not executable or shareable.
 .TP
 .B PR_SET_MM_END_DATA
 Set the address below which initialized and
 uninitialized (bss) data are placed.
 The corresponding memory area must be readable and writable,
-but not executable or sharable.
+but not executable or shareable.
 .TP
 .BR PR_SET_MM_START_STACK
 Set the start address of the stack.
@@ -540,7 +609,7 @@ value.
 The requirements for the address are the same as for the
 .BR PR_SET_MM_START_BRK
 option.
-.P
+.PP
 The following options are available since Linux 3.5.
 .\" commit fe8c7f5cbf91124987106faa3bdf0c8b955c4cf7
 .TP
@@ -597,11 +666,44 @@ memory area for the ELF
 .IR \.text
 section).
 .IP
-The second limitation is that such transitions can be done only once
-in a process life time.
-Any further attempts will be rejected.
-This should help system administrators monitor unusual
-symbolic-link transitions over all processes running on a system.
+In Linux 4.9 and earlier, the
+.\" commit 3fb4afd9a504c2386b8435028d43283216bf588e
+.BR PR_SET_MM_EXE_FILE
+operation can be performed only once in a process's lifetime;
+attempting to perform the operation a second time results in the error
+.BR EPERM .
+This restriction was enforced for security reasons that were subsequently
+deemed specious,
+and the restriction was removed in Linux 4.10 because some
+user-space applications needed to perform this operation more than once.
+.PP
+The following options are available since Linux 3.18.
+.\" commit f606b77f1a9e362451aca8f81d8f36a3a112139e
+.TP
+.BR PR_SET_MM_MAP
+Provides one-shot access to all the addresses by passing in a
+.I struct prctl_mm_map
+(as defined in \fI<linux/prctl.h>\fP).
+The
+.I arg4
+argument should provide the size of the struct.
+.IP
+This feature is available only if the kernel is built with the
+.BR CONFIG_CHECKPOINT_RESTORE
+option enabled.
+.TP
+.BR PR_SET_MM_MAP_SIZE
+Returns the size of the
+.I struct prctl_mm_map
+the kernel expects.
+This allows user space to find a compatible struct.
+The
+.I arg4
+argument should be a pointer to an unsigned int.
+.IP
+This feature is available only if the kernel is built with the
+.BR CONFIG_CHECKPOINT_RESTORE
+option enabled.
 .RE
 .TP
 .BR PR_MPX_ENABLE_MANAGEMENT ", " PR_MPX_DISABLE_MANAGEMENT " (since Linux 3.19) "
@@ -618,7 +720,7 @@ and
 .IR arg5
 .\" commit e9d1b4f3c60997fe197bf0243cb4a41a44387a88
 arguments must be zero.
-
+.IP
 MPX is a hardware-assisted mechanism for performing bounds checking on
 pointers.
 It consists of a set of registers storing bounds information
@@ -631,7 +733,7 @@ These tables are called "bounds tables" and the MPX
 .BR prctl ()
 operations control
 whether the kernel manages their allocation and freeing.
-
+.IP
 When management is enabled, the kernel will take over allocation
 and freeing of the bounds tables.
 It does this by trapping the #BR exceptions that result
@@ -641,28 +743,32 @@ it allocates the table and populates the bounds directory
 with the location of the new table.
 For freeing, the kernel checks to see if bounds tables are
 present for memory which is not allocated, and frees them if so.
-
+.IP
 Before enabling MPX management using
 .BR PR_MPX_ENABLE_MANAGEMENT ,
 the application must first have allocated a user-space buffer for
 the bounds directory and placed the location of that directory in the
 .I bndcfgu
 register.
-
-These calls will fail if the CPU or kernel does not support MPX.
+.IP
+These calls fail if the CPU or kernel does not support MPX.
 Kernel support for MPX is enabled via the
 .BR CONFIG_X86_INTEL_MPX
 configuration option.
 You can check whether the CPU supports MPX by looking for the 'mpx'
 CPUID bit, like with the following command:
-
-       cat /proc/cpuinfo | grep ' mpx '
-
+.IP
+.in +4n
+.EX
+cat /proc/cpuinfo | grep ' mpx '
+.EE
+.in
+.IP
 A thread may not switch in or out of long (64-bit) mode while MPX is
 enabled.
-
+.IP
 All threads in a process are affected by these calls.
-
+.IP
 The child of a
 .BR fork (2)
 inherits the state of MPX management.
@@ -671,7 +777,7 @@ During
 MPX management is reset to a state as if
 .BR PR_MPX_DISABLE_MANAGEMENT
 had been called.
-
+.IP
 For further information on Intel MPX, see the kernel source file
 .IR Documentation/x86/intel_mpx.txt .
 .TP
@@ -702,9 +808,9 @@ The buffer should allow space for up to 16 bytes;
 the returned string will be null-terminated.
 .TP
 .BR PR_SET_NO_NEW_PRIVS " (since Linux 3.5)"
-Set the calling process's
+Set the calling thread's
 .I no_new_privs
-bit to the value in
+attribute to the value in
 .IR arg2 .
 With
 .I no_new_privs
@@ -716,21 +822,38 @@ that could not have been done without the
 call (for example,
 rendering the set-user-ID and set-group-ID mode bits,
 and file capabilities non-functional).
-Once set, this bit cannot be unset.
-The setting of this bit is inherited by children created by
+Once set, this the
+.I no_new_privs
+attribute cannot be unset.
+The setting of this attribute is inherited by children created by
 .BR fork (2)
 and
 .BR clone (2),
 and preserved across
 .BR execve (2).
-
+.IP
+Since Linux 4.10,
+the value of a thread's
+.I no_new_privs
+attribute can be viewed via the
+.I NoNewPrivs
+field in the
+.IR /proc/[pid]/status
+file.
+.IP
 For more information, see the kernel source file
-.IR Documentation/prctl/no_new_privs.txt .
+.IR Documentation/userspace\-api/no_new_privs.rst
+.\" commit 40fde647ccb0ae8c11d256d271e24d385eed595b
+(or
+.IR Documentation/prctl/no_new_privs.txt
+before Linux 4.13).
+See also
+.BR seccomp (2).
 .TP
 .BR PR_GET_NO_NEW_PRIVS " (since Linux 3.5)"
 Return (as the function result) the value of the
 .I no_new_privs
-bit for the current process.
+attribute for the calling thread.
 A value of 0 indicates the regular
 .BR execve (2)
 behavior.
@@ -739,20 +862,12 @@ A value of 1 indicates
 will operate in the privilege-restricting mode described above.
 .TP
 .BR PR_SET_PDEATHSIG " (since Linux 2.1.57)"
-Set the parent death signal
+Set the parent-death signal
 of the calling process to \fIarg2\fP (either a signal value
 in the range 1..maxsig, or 0 to clear).
 This is the signal that the calling process will get when its
 parent dies.
-This value is cleared for the child of a
-.BR fork (2)
-and (since Linux 2.4.36 / 2.6.23)
-when executing a set-user-ID or set-group-ID binary,
-or a binary that has associated capabilities (see
-.BR capabilities (7)).
-This value is preserved across
-.BR execve (2).
-
+.IP
 .IR Warning :
 .\" https://bugzilla.kernel.org/show_bug.cgi?id=43300
 the "parent" in this case is considered to be the
@@ -762,6 +877,38 @@ In other words, the signal will be sent when that thread terminates
 (via, for example,
 .BR pthread_exit (3)),
 rather than after all of the threads in the parent process terminate.
+.IP
+The parent-death signal is sent upon subsequent termination of the parent
+thread and also upon termination of each subreaper process
+(see the description of
+.B PR_SET_CHILD_SUBREAPER
+above) to which the caller is subsequently reparented.
+If the parent thread and all ancestor subreapers have already terminated
+by the time of the
+.BR PR_SET_PDEATHSIG
+operation, then no parent-death signal is sent to the caller.
+.IP
+The parent-death signal is process-directed (see
+.BR signal (7))
+and, if the child installs a handler using the
+.BR sigaction (2)
+.B SA_SIGINFO
+flag, the
+.I si_pid
+field of the
+.I siginfo_t
+argument of the handler contains the PID of the terminating parent process.
+.IP
+The parent-death signal setting is cleared for the child of a
+.BR fork (2).
+It is also
+(since Linux 2.4.36 / 2.6.23)
+.\" commit d2d56c5f51028cb9f3d800882eb6f4cbd3f9099f
+cleared when executing a set-user-ID or set-group-ID binary,
+or a binary that has associated capabilities (see
+.BR capabilities (7));
+otherwise, this value is preserved across
+.BR execve (2).
 .TP
 .BR PR_GET_PDEATHSIG " (since Linux 2.3.15)"
 Return the current value of the parent process death signal,
@@ -792,9 +939,13 @@ is
 .BR PR_SET_PTRACER_ANY ,
 the ptrace restrictions introduced by Yama are effectively disabled for the
 calling process.
-
+.IP
 For further information, see the kernel source file
-.IR Documentation/security/Yama.txt .
+.IR Documentation/admin\-guide/LSM/Yama.rst
+.\" commit 90bb766440f2147486a2acc3e793d7b8348b0c22
+(or
+.IR Documentation/security/Yama.txt
+before Linux 4.13).
 .TP
 .BR PR_SET_SECCOMP " (since Linux 2.6.23)"
 .\" See http://thread.gmane.org/gmane.linux.kernel/542632
@@ -806,12 +957,12 @@ The more recent
 .BR seccomp (2)
 system call provides a superset of the functionality of
 .BR PR_SET_SECCOMP .
-
+.IP
 The seccomp mode is selected via
 .IR arg2 .
 (The seccomp constants are defined in
 .IR <linux/seccomp.h> .)
-
+.IP
 With
 .IR arg2
 set to
@@ -834,7 +985,7 @@ This operation is available only
 if the kernel is configured with
 .B CONFIG_SECCOMP
 enabled.
-
+.IP
 With
 .IR arg2
 set to
@@ -849,7 +1000,7 @@ arbitrary system calls and system call arguments.
 This mode is available only if the kernel is configured with
 .B CONFIG_SECCOMP_FILTER
 enabled.
-
+.IP
 If
 .BR SECCOMP_MODE_FILTER
 filters permit
@@ -864,9 +1015,13 @@ If the filters permit
 .BR prctl ()
 calls, then additional filters can be added;
 they are run in order until the first non-allow result is seen.
-
+.IP
 For further information, see the kernel source file
-.IR Documentation/prctl/seccomp_filter.txt .
+.IR Documentation/userspace\-api/seccomp_filter.rst
+.\" commit c061f33f35be0ccc80f4b8e0aea5dfd2ed7e01a3
+(or
+.IR Documentation/prctl/seccomp_filter.txt
+before Linux 4.13).
 .TP
 .BR PR_GET_SECCOMP " (since Linux 2.6.23)"
 Return (as the function result)
@@ -885,7 +1040,7 @@ This operation is available only
 if the kernel is configured with
 .B CONFIG_SECCOMP
 enabled.
-
+.IP
 Since Linux 3.8, the
 .IR Seccomp
 field of the
@@ -906,6 +1061,106 @@ the "securebits" flags of the calling thread.
 See
 .BR capabilities (7).
 .TP
+.BR PR_GET_SPECULATION_CTRL " (since Linux 4.17)"
+Returns the state of the speculation misfeature specified in
+.IR arg2 .
+Currently, the only permitted value for this argument is
+.BR PR_SPEC_STORE_BYPASS
+(otherwise the call fails with the error
+.BR ENODEV ).
+.IP
+The return value uses bits 0-3 with the following meaning:
+.RS
+.TP
+.BR PR_SPEC_PRCTL
+Mitigation can be controlled per thread by
+.B PR_SET_SPECULATION_CTRL
+.TP
+.BR PR_SPEC_ENABLE
+The speculation feature is enabled, mitigation is disabled.
+.TP
+.BR PR_SPEC_DISABLE
+The speculation feature is disabled, mitigation is enabled
+.TP
+.BR PR_SPEC_FORCE_DISABLE
+Same as
+.B PR_SPEC_DISABLE
+but cannot be undone.
+.RE
+.IP
+If all bits are 0,
+then the CPU is not affected by the speculation misfeature.
+.IP
+If
+.B PR_SPEC_PRCTL
+is set, then per-thread control of the mitigation is available.
+If not set,
+.BR prctl ()
+for the speculation misfeature will fail.
+.IP
+The
+.IR arg3 ,
+.IR arg4 ,
+and
+.I arg5
+arguments must be specified as 0; otherwise the call fails with the error
+.BR EINVAL .
+.TP
+.BR PR_SET_SPECULATION_CTRL " (since Linux 4.17)"
+.\" commit b617cfc858161140d69cc0b5cc211996b557a1c7
+.\" commit 356e4bfff2c5489e016fdb925adbf12a1e3950ee
+Sets the state of the speculation misfeature specified in
+.IR arg2 .
+Currently, the only permitted value for this argument is
+.B PR_SPEC_STORE_BYPASS
+(otherwise the call fails with the error
+.BR ENODEV ).
+This setting is a per-thread attribute.
+The
+.IR arg3
+argument is used to hand in the control value,
+which is one of the following:
+.RS
+.TP
+.BR PR_SPEC_ENABLE
+The speculation feature is enabled, mitigation is disabled.
+.TP
+.BR PR_SPEC_DISABLE
+The speculation feature is disabled, mitigation is enabled
+.TP
+.BR PR_SPEC_FORCE_DISABLE
+Same as
+.B PR_SPEC_DISABLE
+but cannot be undone.
+A subsequent
+.B
+prctl(..., PR_SPEC_ENABLE)
+will fail with the error
+.BR EPERM .
+.RE
+.IP
+Any other value in
+.IR arg3
+will result in the call failing with the error
+.BR ERANGE .
+.IP
+The
+.I arg4
+and
+.I arg5
+arguments must be specified as 0; otherwise the call fails with the error
+.BR EINVAL .
+.IP
+The speculation feature can also be controlled by the
+.B spec_store_bypass_disable
+boot parameter.
+This parameter may enforce a read-only policy which will result in the
+.BR prctl (2)
+call failing with the error
+.BR ENXIO .
+For further details, see the kernel source file
+.IR Documentation/admin-guide/kernel-parameters.txt .
+.TP
 .BR PR_SET_THP_DISABLE " (since Linux 3.15)"
 .\" commit a0715cc22601e8830ace98366c0c2bd8da52af52
 Set the state of the "THP disable" flag for the calling thread.
@@ -935,7 +1190,7 @@ For more information on performance counters, see the Linux kernel source file
 Originally called
 .BR PR_TASK_PERF_COUNTERS_DISABLE ;
 .\" commit 1d1c7ddbfab358445a542715551301b7fc363e28
-renamed (with same numerical value)
+renamed (retaining the same numerical value)
 in Linux 2.6.32.
 .\"
 .TP
@@ -971,6 +1226,12 @@ flag, in the location pointed to by
 This feature is available only if the kernel is built with the
 .BR CONFIG_CHECKPOINT_RESTORE
 option enabled.
+Note that since the
+.BR prctl ()
+system call does not have a compat implementation for
+the AMD64 x32 and MIPS n32 ABIs,
+and the kernel writes out a pointer using the kernel's pointer size,
+this operation expects a user-space buffer of 8 (not 4) bytes on these ABIs.
 .TP
 .BR PR_SET_TIMERSLACK " (since Linux 2.6.28)"
 .\" See https://lwn.net/Articles/369549/
@@ -978,24 +1239,25 @@ option enabled.
 Each thread has two associated timer slack values:
 a "default" value, and a "current" value.
 This operation sets the "current" timer slack value for the calling thread.
+.I arg2
+is an unsigned long value, then maximum "current" value is ULONG_MAX and
+the minimum "current" value is 1.
 If the nanosecond value supplied in
 .IR arg2
 is greater than zero, then the "current" value is set to this value.
 If
 .I arg2
-is less than or equal to zero,
-.\" It seems that it's not possible to set the timer slack to zero;
-.\" The minimum value is 1? Seems a little strange.
+is equal to zero,
 the "current" timer slack is reset to the
 thread's "default" timer slack value.
-
+.IP
 The "current" timer slack is used by the kernel to group timer expirations
 for the calling thread that are close to one another;
 as a consequence, timer expirations for the thread may be
 up to the specified number of nanoseconds late (but will never expire early).
 Grouping timer expirations can help reduce system power consumption
 by minimizing CPU wake-ups.
-
+.IP
 The timer expirations affected by timer slack are those set by
 .BR select (2),
 .BR pselect (2),
@@ -1015,11 +1277,11 @@ and
 .BR pthread_rwlock_timedwrlock (3),
 and
 .BR sem_timedwait (3)).
-
+.IP
 Timer slack is not applied to threads that are scheduled under
 a real-time scheduling policy (see
 .BR sched_setscheduler (2)).
-
+.IP
 When a new thread is created,
 the two timer slack values are made the same as the "current" value
 of the creating thread.
@@ -1030,9 +1292,11 @@ The timer slack values of
 .IR init
 (PID 1), the ancestor of all processes,
 are 50,000 nanoseconds (50 microseconds).
-The timer slack values are preserved across
+The timer slack value is inherited by a child created via
+.BR fork(2),
+and is preserved across
 .BR execve (2).
-
+.IP
 Since Linux 4.6, the "current" timer slack value of any process
 can be examined and changed via the file
 .IR /proc/[pid]/timerslack_ns .
@@ -1043,7 +1307,8 @@ See
 Return (as the function result)
 the "current" timer slack value of the calling thread.
 .TP
-.BR PR_SET_TIMING " (since Linux 2.6.0-test4)"
+.BR PR_SET_TIMING " (since Linux 2.6.0)"
+.\" Precisely: Linux 2.6.0-test4
 Set whether to use (normal, traditional) statistical process timing or
 accurate timestamp-based process timing, by passing
 .B PR_TIMING_STATISTICAL
@@ -1060,7 +1325,8 @@ is not currently implemented
 .\" and looking at the patch history, it appears
 .\" that it never did anything.
 .TP
-.BR PR_GET_TIMING " (since Linux 2.6.0-test4)"
+.BR PR_GET_TIMING " (since Linux 2.6.0)"
+.\" Precisely: Linux 2.6.0-test4
 Return (as the function result) which process timing method is currently
 in use.
 .TP
@@ -1085,20 +1351,33 @@ in the location pointed to by
 .TP
 .B PR_SET_UNALIGN
 (Only on: ia64, since Linux 2.3.48; parisc, since Linux 2.6.15;
-PowerPC, since Linux 2.6.18; Alpha, since Linux 2.6.22)
+PowerPC, since Linux 2.6.18; Alpha, since Linux 2.6.22;
+.\" sh: 94ea5e449ae834af058ef005d16a8ad44fcf13d6
+.\" tile: 2f9ac29eec71a696cb0dcc5fb82c0f8d4dac28c9
+sh, since Linux 2.6.34; tile, since Linux 3.12)
 Set unaligned access control bits to \fIarg2\fP.
 Pass
 \fBPR_UNALIGN_NOPRINT\fP to silently fix up unaligned user accesses,
 or \fBPR_UNALIGN_SIGBUS\fP to generate
 .B SIGBUS
 on unaligned user access.
+Alpha also supports an additional flag with the value
+of 4 and no corresponding named constant,
+which instructs kernel to not fix up
+unaligned accesses (it is analogous to providing the
+.BR UAC_NOFIX
+flag in
+.BR SSI_NVPAIRS
+operation of the
+.BR setsysinfo ()
+system call on Tru64).
 .TP
 .B PR_GET_UNALIGN
 (see
 .B PR_SET_UNALIGN
 for information on versions and architectures)
 Return unaligned access control bits, in the location pointed to by
-.IR "(int\ *) arg2" .
+.IR "(unsigned int\ *) arg2" .
 .SH RETURN VALUE
 On success,
 .BR PR_GET_DUMPABLE ,
@@ -1380,6 +1659,12 @@ and
 .IR arg3
 does not specify a valid capability.
 .TP
+.B ENODEV
+.I option
+was
+.BR PR_SET_SPECULATION_CTRL
+the kernel or CPU does not support the requested speculation misfeature.
+.TP
 .B ENXIO
 .I option
 was
@@ -1389,13 +1674,22 @@ or
 and the kernel or the CPU does not support MPX management.
 Check that the kernel and processor have MPX support.
 .TP
+.B ENXIO
+.I option
+was
+.BR PR_SET_SPECULATION_CTRL
+implies that the control of the selected speculation misfeature is not possible.
+See
+.BR PR_GET_SPECULATION_CTRL
+for the bit fields to determine which option is available.
+.TP
 .B EOPNOTSUPP
 .I option
 is
 .B PR_SET_FP_MODE
 and
 .I arg2
-has invalid or unsupported value.
+has an invalid or unsupported value.
 .TP
 .B EPERM
 .I option
@@ -1412,9 +1706,17 @@ or tried to set a flag whose corresponding locked flag was set
 .B EPERM
 .I option
 is
+.BR PR_SET_SPECULATION_CTRL
+wherein the speculation was disabled with
+.B PR_SPEC_FORCE_DISABLE
+and caller tried to enable it again.
+.TP
+.B EPERM
+.I option
+is
 .BR PR_SET_KEEPCAPS ,
 and the caller's
-.B SECURE_KEEP_CAPS_LOCKED
+.B SECBIT_KEEP_CAPS_LOCKED
 flag is set
 (see
 .BR capabilities (7)).
@@ -1449,6 +1751,28 @@ is not present in the process's permitted and inheritable capability sets,
 or the
 .B PR_CAP_AMBIENT_LOWER
 securebit has been set.
+.TP
+.B ERANGE
+.I option
+was
+.BR PR_SET_SPECULATION_CTRL
+and
+.IR arg3
+is neither
+.BR PR_SPEC_ENABLE ,
+.BR PR_SPEC_DISABLE ,
+nor
+.BR PR_SPEC_FORCE_DISABLE .
+.TP
+.B EINVAL
+.I option
+was
+.BR PR_GET_SPECULATION_CTRL
+or
+.BR PR_SET_SPECULATION_CTRL
+and unused arguments to
+.BR prctl ()
+are not 0.
 .SH VERSIONS
 The
 .BR prctl ()
@@ -1461,9 +1785,13 @@ IRIX has a
 system call (also introduced in Linux 2.1.44
 as irix_prctl on the MIPS architecture),
 with prototype
-.sp
+.PP
+.in +4n
+.EX
 .BI "ptrdiff_t prctl(int " option ", int " arg2 ", int " arg3 );
-.sp
+.EE
+.in
+.PP
 and options to get the maximum number of processes per user,
 get the maximum number of processors the calling process can use,
 find out whether a specified process is currently blocked,