ioctl_userfaultfd.2, madvise.2, memfd_create.2, migrate_pages.2, mmap.2, shmget.2...
[man-pages.git] / man2 / prctl.2
blob34eec04bfe5b0bd3dd29ea43611a181183b21f76
1 .\" Copyright (C) 1998 Andries Brouwer (aeb@cwi.nl)
2 .\" and Copyright (C) 2002, 2006, 2008, 2012, 2013 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" and Copyright Guillem Jover <guillem@hadrons.org>
4 .\" and Copyright (C) 2014 Dave Hansen / Intel
5 .\"
6 .\" %%%LICENSE_START(VERBATIM)
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
10 .\"
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
15 .\"
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein.  The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
22 .\" professionally.
23 .\"
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" %%%LICENSE_END
27 .\"
28 .\" Modified Thu Nov 11 04:19:42 MET 1999, aeb: added PR_GET_PDEATHSIG
29 .\" Modified 27 Jun 02, Michael Kerrisk
30 .\"     Added PR_SET_DUMPABLE, PR_GET_DUMPABLE,
31 .\"     PR_SET_KEEPCAPS, PR_GET_KEEPCAPS
32 .\" Modified 2006-08-30 Guillem Jover <guillem@hadrons.org>
33 .\"     Updated Linux versions where the options where introduced.
34 .\"     Added PR_SET_TIMING, PR_GET_TIMING, PR_SET_NAME, PR_GET_NAME,
35 .\"     PR_SET_UNALIGN, PR_GET_UNALIGN, PR_SET_FPEMU, PR_GET_FPEMU,
36 .\"     PR_SET_FPEXC, PR_GET_FPEXC
37 .\" 2008-04-29 Serge Hallyn, Document PR_CAPBSET_READ and PR_CAPBSET_DROP
38 .\" 2008-06-13 Erik Bosman, <ejbosman@cs.vu.nl>
39 .\"     Document PR_GET_TSC and PR_SET_TSC.
40 .\" 2008-06-15 mtk, Document PR_SET_SECCOMP, PR_GET_SECCOMP
41 .\" 2009-10-03 Andi Kleen, document PR_MCE_KILL
42 .\" 2012-04 Cyrill Gorcunov, Document PR_SET_MM
43 .\" 2012-04-25 Michael Kerrisk, Document PR_TASK_PERF_EVENTS_DISABLE and
44 .\"                             PR_TASK_PERF_EVENTS_ENABLE
45 .\" 2012-09-20 Kees Cook, update PR_SET_SECCOMP for mode 2
46 .\" 2012-09-20 Kees Cook, document PR_SET_NO_NEW_PRIVS, PR_GET_NO_NEW_PRIVS
47 .\" 2012-10-25 Michael Kerrisk, Document PR_SET_TIMERSLACK and
48 .\"                             PR_GET_TIMERSLACK
49 .\" 2013-01-10 Kees Cook, document PR_SET_PTRACER
50 .\" 2012-02-04 Michael Kerrisk, document PR_{SET,GET}_CHILD_SUBREAPER
51 .\" 2014-11-10 Dave Hansen, document PR_MPX_{EN,DIS}ABLE_MANAGEMENT
52 .\"
53 .\"
54 .TH PRCTL 2 2018-02-02 "Linux" "Linux Programmer's Manual"
55 .SH NAME
56 prctl \- operations on a process
57 .SH SYNOPSIS
58 .nf
59 .B #include <sys/prctl.h>
60 .PP
61 .BI "int prctl(int " option ", unsigned long " arg2 ", unsigned long " arg3 ,
62 .BI "          unsigned long " arg4 ", unsigned long " arg5 );
63 .fi
64 .SH DESCRIPTION
65 .BR prctl ()
66 is called with a first argument describing what to do
67 (with values defined in \fI<linux/prctl.h>\fP), and further
68 arguments with a significance depending on the first one.
69 The first argument can be:
70 .\"
71 .TP
72 .BR PR_CAP_AMBIENT " (since Linux 4.3)"
73 .\" commit 58319057b7847667f0c9585b9de0e8932b0fdb08
74 Reads or changes the ambient capability set of the calling thread,
75 according to the value of
76 .IR arg2 ,
77 which must be one of the following:
78 .RS
79 .\"
80 .TP
81 .B PR_CAP_AMBIENT_RAISE
82 The capability specified in
83 .I arg3
84 is added to the ambient set.
85 The specified capability must already be present in
86 both the permitted and the inheritable sets of the process.
87 This operation is not permitted if the
88 .B SECBIT_NO_CAP_AMBIENT_RAISE
89 securebit is set.
90 .TP
91 .B PR_CAP_AMBIENT_LOWER
92 The capability specified in
93 .I arg3
94 is removed from the ambient set.
95 .TP
96 .B PR_CAP_AMBIENT_IS_SET
97 The
98 .BR prctl ()
99 call returns 1 if the capability in
100 .I arg3
101 is in the ambient set and 0 if it is not.
103 .BR PR_CAP_AMBIENT_CLEAR_ALL
104 All capabilities will be removed from the ambient set.
105 This operation requires setting
106 .I arg3
107 to zero.
110 In all of the above operations,
111 .I arg4
113 .I arg5
114 must be specified as 0.
116 Higher-level interfaces layered on top of the above operations are
117 provided in the
118 .BR libcap (3)
119 library in the form of
120 .BR cap_get_ambient (3),
121 .BR cap_set_ambient (3),
123 .BR cap_reset_ambient (3).
125 .BR PR_CAPBSET_READ " (since Linux 2.6.25)"
126 Return (as the function result) 1 if the capability specified in
127 .I arg2
128 is in the calling thread's capability bounding set,
129 or 0 if it is not.
130 (The capability constants are defined in
131 .IR <linux/capability.h> .)
132 The capability bounding set dictates
133 whether the process can receive the capability through a
134 file's permitted capability set on a subsequent call to
135 .BR execve (2).
137 If the capability specified in
138 .I arg2
139 is not valid, then the call fails with the error
140 .BR EINVAL .
142 A higher-level interface layered on top of this operation is provided in the
143 .BR libcap (3)
144 library in the form of
145 .BR cap_get_bound (3).
147 .BR PR_CAPBSET_DROP " (since Linux 2.6.25)"
148 If the calling thread has the
149 .B CAP_SETPCAP
150 capability within its user namespace, then drop the capability specified by
151 .I arg2
152 from the calling thread's capability bounding set.
153 Any children of the calling thread will inherit the newly
154 reduced bounding set.
156 The call fails with the error:
157 .B EPERM
158 if the calling thread does not have the
159 .BR CAP_SETPCAP ;
160 .BR EINVAL
162 .I arg2
163 does not represent a valid capability; or
164 .BR EINVAL
165 if file capabilities are not enabled in the kernel,
166 in which case bounding sets are not supported.
168 A higher-level interface layered on top of this operation is provided in the
169 .BR libcap (3)
170 library in the form of
171 .BR cap_drop_bound (3).
173 .BR PR_SET_CHILD_SUBREAPER " (since Linux 3.4)"
174 .\" commit ebec18a6d3aa1e7d84aab16225e87fd25170ec2b
176 .I arg2
177 is nonzero,
178 set the "child subreaper" attribute of the calling process;
180 .I arg2
181 is zero, unset the attribute.
183 A subreaper fulfills the role of
184 .BR init (1)
185 for its descendant processes.
186 When a process becomes orphaned
187 (i.e., its immediate parent terminates)
188 then that process will be reparented to
189 the nearest still living ancestor subreaper.
190 Subsequently, calls to
191 .BR getppid ()
192 in the orphaned process will now return the PID of the subreaper process,
193 and when the orphan terminates, it is the subreaper process that
194 will receive a
195 .BR SIGCHLD
196 signal and will be able to
197 .BR wait (2)
198 on the process to discover its termination status.
200 The setting of this bit is not inherited by children created by
201 .BR fork (2)
203 .BR clone (2).
204 The setting is preserved across
205 .BR execve (2).
207 Establishing a subreaper process is useful in session management frameworks
208 where a hierarchical group of processes is managed by a subreaper process
209 that needs to be informed when one of the processes\(emfor example,
210 a double-forked daemon\(emterminates
211 (perhaps so that it can restart that process).
212 Some
213 .BR init (1)
214 frameworks (e.g.,
215 .BR systemd (1))
216 employ a subreaper process for similar reasons.
218 .BR PR_GET_CHILD_SUBREAPER " (since Linux 3.4)"
219 Return the "child subreaper" setting of the caller,
220 in the location pointed to by
221 .IR "(int\ *) arg2" .
223 .BR PR_SET_DUMPABLE " (since Linux 2.3.20)"
224 Set the state of the "dumpable" flag,
225 which determines whether core dumps are produced for the calling process
226 upon delivery of a signal whose default behavior is to produce a core dump.
228 In kernels up to and including 2.6.12,
229 .I arg2
230 must be either 0
231 .RB ( SUID_DUMP_DISABLE ,
232 process is not dumpable) or 1
233 .RB ( SUID_DUMP_USER ,
234 process is dumpable).
235 Between kernels 2.6.13 and 2.6.17,
236 .\" commit abf75a5033d4da7b8a7e92321d74021d1fcfb502
237 the value 2 was also permitted,
238 which caused any binary which normally would not be dumped
239 to be dumped readable by root only;
240 for security reasons, this feature has been removed.
241 .\" See http://marc.theaimsgroup.com/?l=linux-kernel&m=115270289030630&w=2
242 .\" Subject:    Fix prctl privilege escalation (CVE-2006-2451)
243 .\" From:       Marcel Holtmann <marcel () holtmann ! org>
244 .\" Date:       2006-07-12 11:12:00
245 (See also the description of
246 .I /proc/sys/fs/\:suid_dumpable
248 .BR proc (5).)
250 Normally, this flag is set to 1.
251 However, it is reset to the current value contained in the file
252 .IR /proc/sys/fs/\:suid_dumpable
253 (which by default has the value 0),
254 in the following circumstances:
255 .\" See kernel/cred.c::commit_creds() (Linux 3.18 sources)
257 .IP * 3
258 The process's effective user or group ID is changed.
259 .IP *
260 The process's filesystem user or group ID is changed (see
261 .BR credentials (7)).
262 .IP *
263 The process executes
264 .RB ( execve (2))
265 a set-user-ID or set-group-ID program, resulting in a change
266 of either the effective user ID or the effective group ID.
267 .IP *
268 The process executes
269 .RB ( execve (2))
270 a program that has file capabilities (see
271 .BR capabilities (7)),
272 .\" See kernel/cred.c::commit_creds()
273 but only if the permitted capabilities
274 gained exceed those already permitted for the process.
275 .\" Also certain namespace operations;
278 Processes that are not dumpable can not be attached via
279 .BR ptrace (2)
280 .BR PTRACE_ATTACH ;
282 .BR ptrace (2)
283 for further details.
285 If a process is not dumpable,
286 the ownership of files in the process's
287 .IR /proc/[pid]
288 directory is affected as described in
289 .BR proc (5).
291 .BR PR_GET_DUMPABLE " (since Linux 2.3.20)"
292 Return (as the function result) the current state of the calling
293 process's dumpable flag.
294 .\" Since Linux 2.6.13, the dumpable flag can have the value 2,
295 .\" but in 2.6.13 PR_GET_DUMPABLE simply returns 1 if the dumpable
296 .\" flags has a nonzero value.  This was fixed in 2.6.14.
298 .BR PR_SET_ENDIAN " (since Linux 2.6.18, PowerPC only)"
299 Set the endian-ness of the calling process to the value given
300 in \fIarg2\fP, which should be one of the following:
301 .\" Respectively 0, 1, 2
302 .BR PR_ENDIAN_BIG ,
303 .BR PR_ENDIAN_LITTLE ,
305 .B PR_ENDIAN_PPC_LITTLE
306 (PowerPC pseudo little endian).
308 .BR PR_GET_ENDIAN " (since Linux 2.6.18, PowerPC only)"
309 Return the endian-ness of the calling process,
310 in the location pointed to by
311 .IR "(int\ *) arg2" .
313 .BR PR_SET_FP_MODE " (since Linux 4.0, only on MIPS)"
314 .\" commit 9791554b45a2acc28247f66a5fd5bbc212a6b8c8
315 On the MIPS architecture,
316 user-space code can be built using an ABI which permits linking
317 with code that has more restrictive floating-point (FP) requirements.
318 For example, user-space code may be built to target the O32 FPXX ABI
319 and linked with code built for either one of the more restrictive
320 FP32 or FP64 ABIs.
321 When more restrictive code is linked in,
322 the overall requirement for the process is to use the more
323 restrictive floating-point mode.
325 Because the kernel has no means of knowing in advance
326 which mode the process should be executed in,
327 and because these restrictions can
328 change over the lifetime of the process, the
329 .B PR_SET_FP_MODE
330 operation is provided to allow control of the floating-point mode
331 from user space.
333 .\" https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking
335 .I (unsigned int) arg2
336 argument is a bit mask describing the floating-point mode used:
339 .BR PR_FP_MODE_FR
340 When this bit is
341 .I unset
342 (so called
343 .BR FR=0 " or " FR0
344 mode), the 32 floating-point registers are 32 bits wide,
345 and 64-bit registers are represented as a pair of registers
346 (even- and odd- numbered,
347 with the even-numbered register containing the lower 32 bits,
348 and the odd-numbered register containing the higher 32 bits).
350 When this bit is
351 .I set
352 (on supported hardware),
353 the 32 floating-point registers are 64 bits wide (so called
354 .BR FR=1 " or " FR1
355 mode).
356 Note that modern MIPS implementations (MIPS R6 and newer) support
357 .B FR=1
358 mode only.
361 Applications that use the O32 FP32 ABI can operate only when this bit is
362 .I unset
363 .RB ( FR=0 ;
364 or they can be used with FRE enabled, see below).
365 Applications that use the O32 FP64 ABI
366 (and the O32 FP64A ABI, which exists to
367 provide the ability to operate with existing FP32 code; see below)
368 can operate only when this bit is
369 .I set
370 .RB ( FR=1 ).
371 Applications that use the O32 FPXX ABI can operate with either
372 .BR FR=0
374 .BR FR=1 .
376 .BR PR_FP_MODE_FRE
377 Enable emulation of 32-bit floating-point mode.
378 When this mode is enabled,
379 it emulates 32-bit floating-point operations
380 by raising a reserved-instruction exception
381 on every instruction that uses 32-bit formats and
382 the kernel then handles the instruction in software.
383 (The problem lies in the discrepancy of handling odd-numbered registers
384 which are the high 32 bits of 64-bit registers with even numbers in
385 .B FR=0
386 mode and the lower 32-bit parts of odd-numbered 64-bit registers in
387 .B FR=1
388 mode.)
389 Enabling this bit is necessary when code with the O32 FP32 ABI should operate
390 with code with compatible the O32 FPXX or O32 FP64A ABIs (which require
391 .B FR=1
392 FPU mode) or when it is executed on newer hardware (MIPS R6 onwards)
393 which lacks
394 .B FR=0
395 mode support when a binary with the FP32 ABI is used.
397 Note that this mode makes sense only when the FPU is in 64-bit mode
398 .RB ( FR=1 ).
400 Note that the use of emulation inherently has a significant performance hit
401 and should be avoided if possible.
404 In the N32/N64 ABI, 64-bit floating-point mode is always used,
405 so FPU emulation is not required and the FPU always operates in
406 .B FR=1
407 mode.
409 This option is mainly intended for use by the dynamic linker
410 .RB ( ld.so (8)).
412 The arguments
413 .IR arg3 ,
414 .IR arg4 ,
416 .IR arg5
417 are ignored.
419 .BR PR_GET_FP_MODE " (since Linux 4.0, only on MIPS)"
420 Get the current floating-point mode (see the description of
421 .B PR_SET_FP_MODE
422 for details).
424 On success,
425 the call returns a bit mask which represents the current floating-point mode.
427 The arguments
428 .IR arg2 ,
429 .IR arg3 ,
430 .IR arg4 ,
432 .IR arg5
433 are ignored.
435 .BR PR_SET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)"
436 Set floating-point emulation control bits to \fIarg2\fP.
437 Pass
438 .B PR_FPEMU_NOPRINT
439 to silently emulate floating-point operation accesses, or
440 .B PR_FPEMU_SIGFPE
441 to not emulate floating-point operations and send
442 .B SIGFPE
443 instead.
445 .BR PR_GET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)"
446 Return floating-point emulation control bits,
447 in the location pointed to by
448 .IR "(int\ *) arg2" .
450 .BR PR_SET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)"
451 Set floating-point exception mode to \fIarg2\fP.
452 Pass \fBPR_FP_EXC_SW_ENABLE\fP to use FPEXC for FP exception enables,
453 \fBPR_FP_EXC_DIV\fP for floating-point divide by zero,
454 \fBPR_FP_EXC_OVF\fP for floating-point overflow,
455 \fBPR_FP_EXC_UND\fP for floating-point underflow,
456 \fBPR_FP_EXC_RES\fP for floating-point inexact result,
457 \fBPR_FP_EXC_INV\fP for floating-point invalid operation,
458 \fBPR_FP_EXC_DISABLED\fP for FP exceptions disabled,
459 \fBPR_FP_EXC_NONRECOV\fP for async nonrecoverable exception mode,
460 \fBPR_FP_EXC_ASYNC\fP for async recoverable exception mode,
461 \fBPR_FP_EXC_PRECISE\fP for precise exception mode.
463 .BR PR_GET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)"
464 Return floating-point exception mode,
465 in the location pointed to by
466 .IR "(int\ *) arg2" .
468 .BR PR_SET_KEEPCAPS " (since Linux 2.2.18)"
469 Set the state of the calling thread's "keep capabilities" flag.
470 The effect if this flag is described in
471 .BR capabilities (7).
472 .I arg2
473 must be either 0 (clear the flag)
474 or 1 (set the flag).
475 The "keep capabilities" value will be reset to 0 on subsequent calls to
476 .BR execve (2).
478 .BR PR_GET_KEEPCAPS " (since Linux 2.2.18)"
479 Return (as the function result) the current state of the calling thread's
480 "keep capabilities" flag.
482 .BR capabilities (7)
483 for a description of this flag.
485 .BR PR_MCE_KILL " (since Linux 2.6.32)"
486 Set the machine check memory corruption kill policy for the calling thread.
488 .I arg2
490 .BR PR_MCE_KILL_CLEAR ,
491 clear the thread memory corruption kill policy and use the system-wide default.
492 (The system-wide default is defined by
493 .IR /proc/sys/vm/memory_failure_early_kill ;
495 .BR proc (5).)
497 .I arg2
499 .BR PR_MCE_KILL_SET ,
500 use a thread-specific memory corruption kill policy.
501 In this case,
502 .I arg3
503 defines whether the policy is
504 .I early kill
505 .RB ( PR_MCE_KILL_EARLY ),
506 .I late kill
507 .RB ( PR_MCE_KILL_LATE ),
508 or the system-wide default
509 .RB ( PR_MCE_KILL_DEFAULT ).
510 Early kill means that the thread receives a
511 .B SIGBUS
512 signal as soon as hardware memory corruption is detected inside
513 its address space.
514 In late kill mode, the process is killed only when it accesses a corrupted page.
516 .BR sigaction (2)
517 for more information on the
518 .BR SIGBUS
519 signal.
520 The policy is inherited by children.
521 The remaining unused
522 .BR prctl ()
523 arguments must be zero for future compatibility.
525 .BR PR_MCE_KILL_GET " (since Linux 2.6.32)"
526 Return the current per-process machine check kill policy.
527 All unused
528 .BR prctl ()
529 arguments must be zero.
531 .BR PR_SET_MM " (since Linux 3.3)"
532 .\" commit 028ee4be34a09a6d48bdf30ab991ae933a7bc036
533 Modify certain kernel memory map descriptor fields
534 of the calling process.
535 Usually these fields are set by the kernel and dynamic loader (see
536 .BR ld.so (8)
537 for more information) and a regular application should not use this feature.
538 However, there are cases, such as self-modifying programs,
539 where a program might find it useful to change its own memory map.
541 The calling process must have the
542 .BR CAP_SYS_RESOURCE
543 capability.
544 The value in
545 .I arg2
546 is one of the options below, while
547 .I arg3
548 provides a new value for the option.
550 .I arg4
552 .I arg5
553 arguments must be zero if unused.
555 Before Linux 3.10,
556 .\" commit 52b3694157e3aa6df871e283115652ec6f2d31e0
557 this feature is available only if the kernel is built with the
558 .BR CONFIG_CHECKPOINT_RESTORE
559 option enabled.
562 .BR PR_SET_MM_START_CODE
563 Set the address above which the program text can run.
564 The corresponding memory area must be readable and executable,
565 but not writable or shareable (see
566 .BR mprotect (2)
568 .BR mmap (2)
569 for more information).
571 .BR PR_SET_MM_END_CODE
572 Set the address below which the program text can run.
573 The corresponding memory area must be readable and executable,
574 but not writable or shareable.
576 .BR PR_SET_MM_START_DATA
577 Set the address above which initialized and
578 uninitialized (bss) data are placed.
579 The corresponding memory area must be readable and writable,
580 but not executable or shareable.
582 .B PR_SET_MM_END_DATA
583 Set the address below which initialized and
584 uninitialized (bss) data are placed.
585 The corresponding memory area must be readable and writable,
586 but not executable or shareable.
588 .BR PR_SET_MM_START_STACK
589 Set the start address of the stack.
590 The corresponding memory area must be readable and writable.
592 .BR PR_SET_MM_START_BRK
593 Set the address above which the program heap can be expanded with
594 .BR brk (2)
595 call.
596 The address must be greater than the ending address of
597 the current program data segment.
598 In addition, the combined size of the resulting heap and
599 the size of the data segment can't exceed the
600 .BR RLIMIT_DATA
601 resource limit (see
602 .BR setrlimit (2)).
604 .BR PR_SET_MM_BRK
605 Set the current
606 .BR brk (2)
607 value.
608 The requirements for the address are the same as for the
609 .BR PR_SET_MM_START_BRK
610 option.
612 The following options are available since Linux 3.5.
613 .\" commit fe8c7f5cbf91124987106faa3bdf0c8b955c4cf7
615 .BR PR_SET_MM_ARG_START
616 Set the address above which the program command line is placed.
618 .BR PR_SET_MM_ARG_END
619 Set the address below which the program command line is placed.
621 .BR PR_SET_MM_ENV_START
622 Set the address above which the program environment is placed.
624 .BR PR_SET_MM_ENV_END
625 Set the address below which the program environment is placed.
627 The address passed with
628 .BR PR_SET_MM_ARG_START ,
629 .BR PR_SET_MM_ARG_END ,
630 .BR PR_SET_MM_ENV_START ,
632 .BR PR_SET_MM_ENV_END
633 should belong to a process stack area.
634 Thus, the corresponding memory area must be readable, writable, and
635 (depending on the kernel configuration) have the
636 .BR MAP_GROWSDOWN
637 attribute set (see
638 .BR mmap (2)).
640 .BR PR_SET_MM_AUXV
641 Set a new auxiliary vector.
643 .I arg3
644 argument should provide the address of the vector.
646 .I arg4
647 is the size of the vector.
649 .BR PR_SET_MM_EXE_FILE
650 .\" commit b32dfe377102ce668775f8b6b1461f7ad428f8b6
651 Supersede the
652 .IR /proc/pid/exe
653 symbolic link with a new one pointing to a new executable file
654 identified by the file descriptor provided in
655 .I arg3
656 argument.
657 The file descriptor should be obtained with a regular
658 .BR open (2)
659 call.
661 To change the symbolic link, one needs to unmap all existing
662 executable memory areas, including those created by the kernel itself
663 (for example the kernel usually creates at least one executable
664 memory area for the ELF
665 .IR \.text
666 section).
668 In Linux 4.9 and earlier, the
669 .\" commit 3fb4afd9a504c2386b8435028d43283216bf588e
670 .BR PR_SET_MM_EXE_FILE
671 operation can be performed only once in a process's lifetime;
672 attempting to perform the operation a second time results in the error
673 .BR EPERM .
674 This restriction was enforced for security reasons that were subsequently
675 deemed specious,
676 and the restriction was removed in Linux 4.10 because some
677 user-space applications needed to perform this operation more than once.
679 The following options are available since Linux 3.18.
680 .\" commit f606b77f1a9e362451aca8f81d8f36a3a112139e
682 .BR PR_SET_MM_MAP
683 Provides one-shot access to all the addresses by passing in a
684 .I struct prctl_mm_map
685 (as defined in \fI<linux/prctl.h>\fP).
687 .I arg4
688 argument should provide the size of the struct.
690 This feature is available only if the kernel is built with the
691 .BR CONFIG_CHECKPOINT_RESTORE
692 option enabled.
694 .BR PR_SET_MM_MAP_SIZE
695 Returns the size of the
696 .I struct prctl_mm_map
697 the kernel expects.
698 This allows user space to find a compatible struct.
700 .I arg4
701 argument should be a pointer to an unsigned int.
703 This feature is available only if the kernel is built with the
704 .BR CONFIG_CHECKPOINT_RESTORE
705 option enabled.
708 .BR PR_MPX_ENABLE_MANAGEMENT ", " PR_MPX_DISABLE_MANAGEMENT " (since Linux 3.19) "
709 .\" commit fe3d197f84319d3bce379a9c0dc17b1f48ad358c
710 .\" See also http://lwn.net/Articles/582712/
711 .\" See also https://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler
712 Enable or disable kernel management of Memory Protection eXtensions (MPX)
713 bounds tables.
715 .IR arg2 ,
716 .IR arg3 ,
717 .IR arg4 ,
719 .IR arg5
720 .\" commit e9d1b4f3c60997fe197bf0243cb4a41a44387a88
721 arguments must be zero.
723 MPX is a hardware-assisted mechanism for performing bounds checking on
724 pointers.
725 It consists of a set of registers storing bounds information
726 and a set of special instruction prefixes that tell the CPU on which
727 instructions it should do bounds enforcement.
728 There is a limited number of these registers and
729 when there are more pointers than registers,
730 their contents must be "spilled" into a set of tables.
731 These tables are called "bounds tables" and the MPX
732 .BR prctl ()
733 operations control
734 whether the kernel manages their allocation and freeing.
736 When management is enabled, the kernel will take over allocation
737 and freeing of the bounds tables.
738 It does this by trapping the #BR exceptions that result
739 at first use of missing bounds tables and
740 instead of delivering the exception to user space,
741 it allocates the table and populates the bounds directory
742 with the location of the new table.
743 For freeing, the kernel checks to see if bounds tables are
744 present for memory which is not allocated, and frees them if so.
746 Before enabling MPX management using
747 .BR PR_MPX_ENABLE_MANAGEMENT ,
748 the application must first have allocated a user-space buffer for
749 the bounds directory and placed the location of that directory in the
750 .I bndcfgu
751 register.
753 These calls fail if the CPU or kernel does not support MPX.
754 Kernel support for MPX is enabled via the
755 .BR CONFIG_X86_INTEL_MPX
756 configuration option.
757 You can check whether the CPU supports MPX by looking for the 'mpx'
758 CPUID bit, like with the following command:
760         cat /proc/cpuinfo | grep ' mpx '
762 A thread may not switch in or out of long (64-bit) mode while MPX is
763 enabled.
765 All threads in a process are affected by these calls.
767 The child of a
768 .BR fork (2)
769 inherits the state of MPX management.
770 During
771 .BR execve (2),
772 MPX management is reset to a state as if
773 .BR PR_MPX_DISABLE_MANAGEMENT
774 had been called.
776 For further information on Intel MPX, see the kernel source file
777 .IR Documentation/x86/intel_mpx.txt .
779 .BR PR_SET_NAME " (since Linux 2.6.9)"
780 Set the name of the calling thread,
781 using the value in the location pointed to by
782 .IR "(char\ *) arg2" .
783 The name can be up to 16 bytes long,
784 .\" TASK_COMM_LEN in include/linux/sched.h
785 including the terminating null byte.
786 (If the length of the string, including the terminating null byte,
787 exceeds 16 bytes, the string is silently truncated.)
788 This is the same attribute that can be set via
789 .BR pthread_setname_np (3)
790 and retrieved using
791 .BR pthread_getname_np (3).
792 The attribute is likewise accessible via
793 .IR /proc/self/task/[tid]/comm ,
794 where
795 .I tid
796 is the name of the calling thread.
798 .BR PR_GET_NAME " (since Linux 2.6.11)"
799 Return the name of the calling thread,
800 in the buffer pointed to by
801 .IR "(char\ *) arg2" .
802 The buffer should allow space for up to 16 bytes;
803 the returned string will be null-terminated.
805 .BR PR_SET_NO_NEW_PRIVS " (since Linux 3.5)"
806 Set the calling thread's
807 .I no_new_privs
808 bit to the value in
809 .IR arg2 .
810 With
811 .I no_new_privs
812 set to 1,
813 .BR execve (2)
814 promises not to grant privileges to do anything
815 that could not have been done without the
816 .BR execve (2)
817 call (for example,
818 rendering the set-user-ID and set-group-ID mode bits,
819 and file capabilities non-functional).
820 Once set, this bit cannot be unset.
821 The setting of this bit is inherited by children created by
822 .BR fork (2)
824 .BR clone (2),
825 and preserved across
826 .BR execve (2).
828 Since Linux 4.10,
829 the value of a thread's
830 .I no_new_privs
831 bit can be viewed via the
832 .I NoNewPrivs
833 field in the
834 .IR /proc/[pid]/status
835 file.
837 For more information, see the kernel source file
838 .IR Documentation/userspace\-api/no_new_privs.rst
839 .\" commit 40fde647ccb0ae8c11d256d271e24d385eed595b
841 .IR Documentation/prctl/no_new_privs.txt
842 before Linux 4.13).
843 See also
844 .BR seccomp (2).
846 .BR PR_GET_NO_NEW_PRIVS " (since Linux 3.5)"
847 Return (as the function result) the value of the
848 .I no_new_privs
849 bit for the calling thread.
850 A value of 0 indicates the regular
851 .BR execve (2)
852 behavior.
853 A value of 1 indicates
854 .BR execve (2)
855 will operate in the privilege-restricting mode described above.
857 .BR PR_SET_PDEATHSIG " (since Linux 2.1.57)"
858 Set the parent death signal
859 of the calling process to \fIarg2\fP (either a signal value
860 in the range 1..maxsig, or 0 to clear).
861 This is the signal that the calling process will get when its
862 parent dies.
863 This value is cleared for the child of a
864 .BR fork (2)
865 and (since Linux 2.4.36 / 2.6.23)
866 when executing a set-user-ID or set-group-ID binary,
867 or a binary that has associated capabilities (see
868 .BR capabilities (7)).
869 This value is preserved across
870 .BR execve (2).
872 .IR Warning :
873 .\" https://bugzilla.kernel.org/show_bug.cgi?id=43300
874 the "parent" in this case is considered to be the
875 .I thread
876 that created this process.
877 In other words, the signal will be sent when that thread terminates
878 (via, for example,
879 .BR pthread_exit (3)),
880 rather than after all of the threads in the parent process terminate.
882 .BR PR_GET_PDEATHSIG " (since Linux 2.3.15)"
883 Return the current value of the parent process death signal,
884 in the location pointed to by
885 .IR "(int\ *) arg2" .
887 .BR PR_SET_PTRACER " (since Linux 3.4)"
888 .\" commit 2d514487faf188938a4ee4fb3464eeecfbdcf8eb
889 .\" commit bf06189e4d14641c0148bea16e9dd24943862215
890 This is meaningful only when the Yama LSM is enabled and in mode 1
891 ("restricted ptrace", visible via
892 .IR /proc/sys/kernel/yama/ptrace_scope ).
893 When a "ptracer process ID" is passed in \fIarg2\fP,
894 the caller is declaring that the ptracer process can
895 .BR ptrace (2)
896 the calling process as if it were a direct process ancestor.
897 Each
898 .B PR_SET_PTRACER
899 operation replaces the previous "ptracer process ID".
900 Employing
901 .B PR_SET_PTRACER
902 with
903 .I arg2
904 set to 0 clears the caller's "ptracer process ID".
906 .I arg2
908 .BR PR_SET_PTRACER_ANY ,
909 the ptrace restrictions introduced by Yama are effectively disabled for the
910 calling process.
912 For further information, see the kernel source file
913 .IR Documentation/admin\-guide/LSM/Yama.rst
914 .\" commit 90bb766440f2147486a2acc3e793d7b8348b0c22
916 .IR Documentation/security/Yama.txt
917 before Linux 4.13).
919 .BR PR_SET_SECCOMP " (since Linux 2.6.23)"
920 .\" See http://thread.gmane.org/gmane.linux.kernel/542632
921 .\" [PATCH 0 of 2] seccomp updates
922 .\" andrea@cpushare.com
923 Set the secure computing (seccomp) mode for the calling thread, to limit
924 the available system calls.
925 The more recent
926 .BR seccomp (2)
927 system call provides a superset of the functionality of
928 .BR PR_SET_SECCOMP .
930 The seccomp mode is selected via
931 .IR arg2 .
932 (The seccomp constants are defined in
933 .IR <linux/seccomp.h> .)
935 With
936 .IR arg2
937 set to
938 .BR SECCOMP_MODE_STRICT ,
939 the only system calls that the thread is permitted to make are
940 .BR read (2),
941 .BR write (2),
942 .BR _exit (2)
943 (but not
944 .BR exit_group (2)),
946 .BR sigreturn (2).
947 Other system calls result in the delivery of a
948 .BR SIGKILL
949 signal.
950 Strict secure computing mode is useful for number-crunching applications
951 that may need to execute untrusted byte code,
952 perhaps obtained by reading from a pipe or socket.
953 This operation is available only
954 if the kernel is configured with
955 .B CONFIG_SECCOMP
956 enabled.
958 With
959 .IR arg2
960 set to
961 .BR SECCOMP_MODE_FILTER " (since Linux 3.5),"
962 the system calls allowed are defined by a pointer
963 to a Berkeley Packet Filter passed in
964 .IR arg3 .
965 This argument is a pointer to
966 .IR "struct sock_fprog" ;
967 it can be designed to filter
968 arbitrary system calls and system call arguments.
969 This mode is available only if the kernel is configured with
970 .B CONFIG_SECCOMP_FILTER
971 enabled.
974 .BR SECCOMP_MODE_FILTER
975 filters permit
976 .BR fork (2),
977 then the seccomp mode is inherited by children created by
978 .BR fork (2);
980 .BR execve (2)
981 is permitted, then the seccomp mode is preserved across
982 .BR execve (2).
983 If the filters permit
984 .BR prctl ()
985 calls, then additional filters can be added;
986 they are run in order until the first non-allow result is seen.
988 For further information, see the kernel source file
989 .IR Documentation/userspace\-api/seccomp_filter.rst
990 .\" commit c061f33f35be0ccc80f4b8e0aea5dfd2ed7e01a3
992 .IR Documentation/prctl/seccomp_filter.txt
993 before Linux 4.13).
995 .BR PR_GET_SECCOMP " (since Linux 2.6.23)"
996 Return (as the function result)
997 the secure computing mode of the calling thread.
998 If the caller is not in secure computing mode, this operation returns 0;
999 if the caller is in strict secure computing mode, then the
1000 .BR prctl ()
1001 call will cause a
1002 .B SIGKILL
1003 signal to be sent to the process.
1004 If the caller is in filter mode, and this system call is allowed by the
1005 seccomp filters, it returns 2; otherwise, the process is killed with a
1006 .BR SIGKILL
1007 signal.
1008 This operation is available only
1009 if the kernel is configured with
1010 .B CONFIG_SECCOMP
1011 enabled.
1013 Since Linux 3.8, the
1014 .IR Seccomp
1015 field of the
1016 .IR /proc/[pid]/status
1017 file provides a method of obtaining the same information,
1018 without the risk that the process is killed; see
1019 .BR proc (5).
1021 .BR PR_SET_SECUREBITS " (since Linux 2.6.26)"
1022 Set the "securebits" flags of the calling thread to the value supplied in
1023 .IR arg2 .
1025 .BR capabilities (7).
1027 .BR PR_GET_SECUREBITS " (since Linux 2.6.26)"
1028 Return (as the function result)
1029 the "securebits" flags of the calling thread.
1031 .BR capabilities (7).
1033 .BR PR_GET_SPECULATION_CTRL " (since Linux 4.17)"
1034 Returns the state of the speculation misfeature specified in
1035 .IR arg2 .
1036 Currently, the only permitted value for this argument is
1037 .BR PR_SPEC_STORE_BYPASS
1038 (otherwise the call fails with the error
1039 .BR ENODEV ).
1041 The return value uses bits 0-3 with the following meaning:
1044 .BR PR_SPEC_PRCTL
1045 Mitigation can be controlled per thread by
1046 .B PR_SET_SPECULATION_CTRL
1048 .BR PR_SPEC_ENABLE
1049 The speculation feature is enabled, mitigation is disabled.
1051 .BR PR_SPEC_DISABLE
1052 The speculation feature is disabled, mitigation is enabled
1054 .BR PR_SPEC_FORCE_DISABLE
1055 Same as
1056 .B PR_SPEC_DISABLE
1057 but cannot be undone.
1060 If all bits are 0,
1061 then the CPU is not affected by the speculation misfeature.
1064 .B PR_SPEC_PRCTL
1065 is set, then per-thread control of the mitigation is available.
1066 If not set,
1067 .BR prctl ()
1068 for the speculation misfeature will fail.
1071 .IR arg3 ,
1072 .IR arg4 ,
1074 .I arg5
1075 arguments must be specified as 0; otherwise the call fails with the error
1076 .BR EINVAL .
1078 .BR PR_SET_SPECULATION_CTRL " (since Linux 4.17)"
1079 .\" commit b617cfc858161140d69cc0b5cc211996b557a1c7
1080 .\" commit 356e4bfff2c5489e016fdb925adbf12a1e3950ee
1081 Sets the state of the speculation misfeature specified in
1082 .IR arg2 .
1083 Currently, the only permitted value for this argument is
1084 .B PR_SPEC_STORE_BYPASS
1085 (otherwise the call fails with the error
1086 .BR ENODEV ).
1087 This setting is a per-thread attribute.
1089 .IR arg3
1090 argument is used to hand in the control value,
1091 which is one of the following:
1094 .BR PR_SPEC_ENABLE
1095 The speculation feature is enabled, mitigation is disabled.
1097 .BR PR_SPEC_DISABLE
1098 The speculation feature is disabled, mitigation is enabled
1100 .BR PR_SPEC_FORCE_DISABLE
1101 Same as
1102 .B PR_SPEC_DISABLE
1103 but cannot be undone.
1104 A subsequent
1106 prctl(..., PR_SPEC_ENABLE)
1107 will fail with the error
1108 .BR EPERM .
1111 Any other value in
1112 .IR arg3
1113 will result in the call failing with the error
1114 .BR ERANGE .
1117 .I arg4
1119 .I arg5
1120 arguments must be specified as 0; otherwise the call fails with the error
1121 .BR EINVAL .
1123 The speculation feature can also be controlled by the
1124 .B spec_store_bypass_disable
1125 boot parameter.
1126 This parameter may enforce a read-only policy which will result in the
1127 .BR prctl (2)
1128 call failing with the error
1129 .BR ENXIO .
1130 For further details, see the kernel source file
1131 .IR Documentation/admin-guide/kernel-parameters.txt .
1133 .BR PR_SET_THP_DISABLE " (since Linux 3.15)"
1134 .\" commit a0715cc22601e8830ace98366c0c2bd8da52af52
1135 Set the state of the "THP disable" flag for the calling thread.
1137 .I arg2
1138 has a nonzero value, the flag is set, otherwise it is cleared.
1139 Setting this flag provides a method
1140 for disabling transparent huge pages
1141 for jobs where the code cannot be modified, and using a malloc hook with
1142 .BR madvise (2)
1143 is not an option (i.e., statically allocated data).
1144 The setting of the "THP disable" flag is inherited by a child created via
1145 .BR fork (2)
1146 and is preserved across
1147 .BR execve (2).
1150 .BR PR_TASK_PERF_EVENTS_DISABLE " (since Linux 2.6.31)"
1151 Disable all performance counters attached to the calling process,
1152 regardless of whether the counters were created by
1153 this process or another process.
1154 Performance counters created by the calling process for other
1155 processes are unaffected.
1156 For more information on performance counters, see the Linux kernel source file
1157 .IR tools/perf/design.txt .
1159 Originally called
1160 .BR PR_TASK_PERF_COUNTERS_DISABLE ;
1161 .\" commit 1d1c7ddbfab358445a542715551301b7fc363e28
1162 renamed (retaining the same numerical value)
1163 in Linux 2.6.32.
1166 .BR PR_TASK_PERF_EVENTS_ENABLE " (since Linux 2.6.31)"
1167 The converse of
1168 .BR PR_TASK_PERF_EVENTS_DISABLE ;
1169 enable performance counters attached to the calling process.
1171 Originally called
1172 .BR PR_TASK_PERF_COUNTERS_ENABLE ;
1173 .\" commit 1d1c7ddbfab358445a542715551301b7fc363e28
1174 renamed
1175 .\" commit cdd6c482c9ff9c55475ee7392ec8f672eddb7be6
1176 in Linux 2.6.32.
1179 .BR PR_GET_THP_DISABLE " (since Linux 3.15)"
1180 Return (via the function result) the current setting of the "THP disable"
1181 flag for the calling thread:
1182 either 1, if the flag is set, or 0, if it is not.
1184 .BR PR_GET_TID_ADDRESS " (since Linux 3.5)"
1185 .\" commit 300f786b2683f8bb1ec0afb6e1851183a479c86d
1186 Retrieve the
1187 .I clear_child_tid
1188 address set by
1189 .BR set_tid_address (2)
1190 and the
1191 .BR clone (2)
1192 .B CLONE_CHILD_CLEARTID
1193 flag, in the location pointed to by
1194 .IR "(int\ **)\ arg2" .
1195 This feature is available only if the kernel is built with the
1196 .BR CONFIG_CHECKPOINT_RESTORE
1197 option enabled.
1198 Note that since the
1199 .BR prctl ()
1200 system call does not have a compat implementation for
1201 the AMD64 x32 and MIPS n32 ABIs,
1202 and the kernel writes out a pointer using the kernel's pointer size,
1203 this operation expects a user-space buffer of 8 (not 4) bytes on these ABIs.
1205 .BR PR_SET_TIMERSLACK " (since Linux 2.6.28)"
1206 .\" See https://lwn.net/Articles/369549/
1207 .\" commit 6976675d94042fbd446231d1bd8b7de71a980ada
1208 Each thread has two associated timer slack values:
1209 a "default" value, and a "current" value.
1210 This operation sets the "current" timer slack value for the calling thread.
1211 If the nanosecond value supplied in
1212 .IR arg2
1213 is greater than zero, then the "current" value is set to this value.
1215 .I arg2
1216 is less than or equal to zero,
1217 .\" It seems that it's not possible to set the timer slack to zero;
1218 .\" The minimum value is 1? Seems a little strange.
1219 the "current" timer slack is reset to the
1220 thread's "default" timer slack value.
1222 The "current" timer slack is used by the kernel to group timer expirations
1223 for the calling thread that are close to one another;
1224 as a consequence, timer expirations for the thread may be
1225 up to the specified number of nanoseconds late (but will never expire early).
1226 Grouping timer expirations can help reduce system power consumption
1227 by minimizing CPU wake-ups.
1229 The timer expirations affected by timer slack are those set by
1230 .BR select (2),
1231 .BR pselect (2),
1232 .BR poll (2),
1233 .BR ppoll (2),
1234 .BR epoll_wait (2),
1235 .BR epoll_pwait (2),
1236 .BR clock_nanosleep (2),
1237 .BR nanosleep (2),
1239 .BR futex (2)
1240 (and thus the library functions implemented via futexes, including
1241 .\" List obtained by grepping for futex usage in glibc source
1242 .BR pthread_cond_timedwait (3),
1243 .BR pthread_mutex_timedlock (3),
1244 .BR pthread_rwlock_timedrdlock (3),
1245 .BR pthread_rwlock_timedwrlock (3),
1247 .BR sem_timedwait (3)).
1249 Timer slack is not applied to threads that are scheduled under
1250 a real-time scheduling policy (see
1251 .BR sched_setscheduler (2)).
1253 When a new thread is created,
1254 the two timer slack values are made the same as the "current" value
1255 of the creating thread.
1256 Thereafter, a thread can adjust its "current" timer slack value via
1257 .BR PR_SET_TIMERSLACK .
1258 The "default" value can't be changed.
1259 The timer slack values of
1260 .IR init
1261 (PID 1), the ancestor of all processes,
1262 are 50,000 nanoseconds (50 microseconds).
1263 The timer slack values are preserved across
1264 .BR execve (2).
1266 Since Linux 4.6, the "current" timer slack value of any process
1267 can be examined and changed via the file
1268 .IR /proc/[pid]/timerslack_ns .
1270 .BR proc (5).
1272 .BR PR_GET_TIMERSLACK " (since Linux 2.6.28)"
1273 Return (as the function result)
1274 the "current" timer slack value of the calling thread.
1276 .BR PR_SET_TIMING " (since Linux 2.6.0-test4)"
1277 Set whether to use (normal, traditional) statistical process timing or
1278 accurate timestamp-based process timing, by passing
1279 .B PR_TIMING_STATISTICAL
1280 .\" 0
1282 .B PR_TIMING_TIMESTAMP
1283 .\" 1
1284 to \fIarg2\fP.
1285 .B PR_TIMING_TIMESTAMP
1286 is not currently implemented
1287 (attempting to set this mode will yield the error
1288 .BR EINVAL ).
1289 .\" PR_TIMING_TIMESTAMP doesn't do anything in 2.6.26-rc8,
1290 .\" and looking at the patch history, it appears
1291 .\" that it never did anything.
1293 .BR PR_GET_TIMING " (since Linux 2.6.0-test4)"
1294 Return (as the function result) which process timing method is currently
1295 in use.
1297 .BR PR_SET_TSC " (since Linux 2.6.26, x86 only)"
1298 Set the state of the flag determining whether the timestamp counter
1299 can be read by the process.
1300 Pass
1301 .B PR_TSC_ENABLE
1303 .I arg2
1304 to allow it to be read, or
1305 .B PR_TSC_SIGSEGV
1306 to generate a
1307 .B SIGSEGV
1308 when the process tries to read the timestamp counter.
1310 .BR PR_GET_TSC " (since Linux 2.6.26, x86 only)"
1311 Return the state of the flag determining whether the timestamp counter
1312 can be read,
1313 in the location pointed to by
1314 .IR "(int\ *) arg2" .
1316 .B PR_SET_UNALIGN
1317 (Only on: ia64, since Linux 2.3.48; parisc, since Linux 2.6.15;
1318 PowerPC, since Linux 2.6.18; Alpha, since Linux 2.6.22;
1319 .\" sh: 94ea5e449ae834af058ef005d16a8ad44fcf13d6
1320 .\" tile: 2f9ac29eec71a696cb0dcc5fb82c0f8d4dac28c9
1321 sh, since Linux 2.6.34; tile, since Linux 3.12)
1322 Set unaligned access control bits to \fIarg2\fP.
1323 Pass
1324 \fBPR_UNALIGN_NOPRINT\fP to silently fix up unaligned user accesses,
1325 or \fBPR_UNALIGN_SIGBUS\fP to generate
1326 .B SIGBUS
1327 on unaligned user access.
1328 Alpha also supports an additional flag with the value
1329 of 4 and no corresponding named constant,
1330 which instructs kernel to not fix up
1331 unaligned accesses (it is analogous to providing the
1332 .BR UAC_NOFIX
1333 flag in
1334 .BR SSI_NVPAIRS
1335 operation of the
1336 .BR setsysinfo ()
1337 system call on Tru64).
1339 .B PR_GET_UNALIGN
1340 (see
1341 .B PR_SET_UNALIGN
1342 for information on versions and architectures)
1343 Return unaligned access control bits, in the location pointed to by
1344 .IR "(unsigned int\ *) arg2" .
1345 .SH RETURN VALUE
1346 On success,
1347 .BR PR_GET_DUMPABLE ,
1348 .BR PR_GET_KEEPCAPS ,
1349 .BR PR_GET_NO_NEW_PRIVS ,
1350 .BR PR_GET_THP_DISABLE ,
1351 .BR PR_CAPBSET_READ ,
1352 .BR PR_GET_TIMING ,
1353 .BR PR_GET_TIMERSLACK ,
1354 .BR PR_GET_SECUREBITS ,
1355 .BR PR_MCE_KILL_GET ,
1356 .BR PR_CAP_AMBIENT + PR_CAP_AMBIENT_IS_SET ,
1357 and (if it returns)
1358 .BR PR_GET_SECCOMP
1359 return the nonnegative values described above.
1360 All other
1361 .I option
1362 values return 0 on success.
1363 On error, \-1 is returned, and
1364 .I errno
1365 is set appropriately.
1366 .SH ERRORS
1368 .B EACCES
1369 .I option
1371 .BR PR_SET_SECCOMP
1373 .I arg2
1375 .BR SECCOMP_MODE_FILTER ,
1376 but the process does not have the
1377 .BR CAP_SYS_ADMIN
1378 capability or has not set the
1379 .IR no_new_privs
1380 attribute (see the discussion of
1381 .BR PR_SET_NO_NEW_PRIVS
1382 above).
1384 .B EACCES
1385 .I option
1387 .BR PR_SET_MM ,
1389 .I arg3
1391 .BR PR_SET_MM_EXE_FILE ,
1392 the file is not executable.
1394 .B EBADF
1395 .I option
1397 .BR PR_SET_MM ,
1398 .I arg3
1400 .BR PR_SET_MM_EXE_FILE ,
1401 and the file descriptor passed in
1402 .I arg4
1403 is not valid.
1405 .B EBUSY
1406 .I option
1408 .BR PR_SET_MM ,
1409 .I arg3
1411 .BR PR_SET_MM_EXE_FILE ,
1412 and this the second attempt to change the
1413 .I /proc/pid/exe
1414 symbolic link, which is prohibited.
1416 .B EFAULT
1417 .I arg2
1418 is an invalid address.
1420 .B EFAULT
1421 .I option
1423 .BR PR_SET_SECCOMP ,
1424 .I arg2
1426 .BR SECCOMP_MODE_FILTER ,
1427 the system was built with
1428 .BR CONFIG_SECCOMP_FILTER ,
1430 .I arg3
1431 is an invalid address.
1433 .B EINVAL
1434 The value of
1435 .I option
1436 is not recognized.
1438 .B EINVAL
1439 .I option
1441 .BR PR_MCE_KILL
1443 .BR PR_MCE_KILL_GET
1445 .BR PR_SET_MM ,
1446 and unused
1447 .BR prctl ()
1448 arguments were not specified as zero.
1450 .B EINVAL
1451 .I arg2
1452 is not valid value for this
1453 .IR option .
1455 .B EINVAL
1456 .I option
1458 .BR PR_SET_SECCOMP
1460 .BR PR_GET_SECCOMP ,
1461 and the kernel was not configured with
1462 .BR CONFIG_SECCOMP .
1464 .B EINVAL
1465 .I option
1467 .BR PR_SET_SECCOMP ,
1468 .I arg2
1470 .BR SECCOMP_MODE_FILTER ,
1471 and the kernel was not configured with
1472 .BR CONFIG_SECCOMP_FILTER .
1474 .B EINVAL
1475 .I option
1477 .BR PR_SET_MM ,
1478 and one of the following is true
1480 .IP * 3
1481 .I arg4
1483 .I arg5
1484 is nonzero;
1485 .IP *
1486 .I arg3
1487 is greater than
1488 .B TASK_SIZE
1489 (the limit on the size of the user address space for this architecture);
1490 .IP *
1491 .I arg2
1493 .BR PR_SET_MM_START_CODE ,
1494 .BR PR_SET_MM_END_CODE ,
1495 .BR PR_SET_MM_START_DATA ,
1496 .BR PR_SET_MM_END_DATA ,
1498 .BR PR_SET_MM_START_STACK ,
1499 and the permissions of the corresponding memory area are not as required;
1500 .IP *
1501 .I arg2
1503 .BR PR_SET_MM_START_BRK
1505 .BR PR_SET_MM_BRK ,
1507 .I arg3
1508 is less than or equal to the end of the data segment
1509 or specifies a value that would cause the
1510 .B RLIMIT_DATA
1511 resource limit to be exceeded.
1514 .B EINVAL
1515 .I option
1517 .BR PR_SET_PTRACER
1519 .I arg2
1520 is not 0,
1521 .BR PR_SET_PTRACER_ANY ,
1522 or the PID of an existing process.
1524 .B EINVAL
1525 .I option
1527 .B PR_SET_PDEATHSIG
1529 .I arg2
1530 is not a valid signal number.
1532 .B EINVAL
1533 .I option
1535 .BR PR_SET_DUMPABLE
1537 .I arg2
1538 is neither
1539 .B SUID_DUMP_DISABLE
1541 .BR SUID_DUMP_USER .
1543 .B EINVAL
1544 .I option
1546 .BR PR_SET_TIMING
1548 .I arg2
1549 is not
1550 .BR PR_TIMING_STATISTICAL .
1552 .B EINVAL
1553 .I option
1555 .BR PR_SET_NO_NEW_PRIVS
1557 .I arg2
1558 is not equal to 1
1560 .IR arg3 ,
1561 .IR arg4 ,
1563 .IR arg5
1564 is nonzero.
1566 .B EINVAL
1567 .I option
1569 .BR PR_GET_NO_NEW_PRIVS
1571 .IR arg2 ,
1572 .IR arg3 ,
1573 .IR arg4 ,
1575 .IR arg5
1576 is nonzero.
1578 .B EINVAL
1579 .I option
1581 .BR PR_SET_THP_DISABLE
1583 .IR arg3 ,
1584 .IR arg4 ,
1586 .IR arg5
1587 is nonzero.
1589 .B EINVAL
1590 .I option
1592 .BR PR_GET_THP_DISABLE
1594 .IR arg2 ,
1595 .IR arg3 ,
1596 .IR arg4 ,
1598 .IR arg5
1599 is nonzero.
1601 .B EINVAL
1602 .I option
1604 .B PR_CAP_AMBIENT
1605 and an unused argument
1606 .RI ( arg4 ,
1607 .IR arg5 ,
1609 in the case of
1610 .BR PR_CAP_AMBIENT_CLEAR_ALL ,
1611 .IR arg3 )
1612 is nonzero; or
1613 .IR arg2
1614 has an invalid value;
1616 .IR arg2
1618 .BR PR_CAP_AMBIENT_LOWER ,
1619 .BR PR_CAP_AMBIENT_RAISE ,
1621 .BR PR_CAP_AMBIENT_IS_SET
1623 .IR arg3
1624 does not specify a valid capability.
1626 .B ENODEV
1627 .I option
1629 .BR PR_SET_SPECULATION_CTRL
1630 the kernel or CPU does not support the requested speculation misfeature.
1632 .B ENXIO
1633 .I option
1635 .BR PR_MPX_ENABLE_MANAGEMENT
1637 .BR PR_MPX_DISABLE_MANAGEMENT
1638 and the kernel or the CPU does not support MPX management.
1639 Check that the kernel and processor have MPX support.
1641 .B ENXIO
1642 .I option
1644 .BR PR_SET_SPECULATION_CTRL
1645 implies that the control of the selected speculation misfeature is not possible.
1647 .BR PR_GET_SPECULATION_CTRL
1648 for the bit fields to determine which option is available.
1650 .B EOPNOTSUPP
1651 .I option
1653 .B PR_SET_FP_MODE
1655 .I arg2
1656 has an invalid or unsupported value.
1658 .B EPERM
1659 .I option
1661 .BR PR_SET_SECUREBITS ,
1662 and the caller does not have the
1663 .B CAP_SETPCAP
1664 capability,
1665 or tried to unset a "locked" flag,
1666 or tried to set a flag whose corresponding locked flag was set
1667 (see
1668 .BR capabilities (7)).
1670 .B EPERM
1671 .I option
1673 .BR PR_SET_SPECULATION_CTRL
1674 wherein the speculation was disabled with
1675 .B PR_SPEC_FORCE_DISABLE
1676 and caller tried to enable it again.
1678 .B EPERM
1679 .I option
1681 .BR PR_SET_KEEPCAPS ,
1682 and the caller's
1683 .B SECBIT_KEEP_CAPS_LOCKED
1684 flag is set
1685 (see
1686 .BR capabilities (7)).
1688 .B EPERM
1689 .I option
1691 .BR PR_CAPBSET_DROP ,
1692 and the caller does not have the
1693 .B CAP_SETPCAP
1694 capability.
1696 .B EPERM
1697 .I option
1699 .BR PR_SET_MM ,
1700 and the caller does not have the
1701 .B CAP_SYS_RESOURCE
1702 capability.
1704 .B EPERM
1705 .IR option
1707 .BR PR_CAP_AMBIENT
1709 .IR arg2
1711 .BR PR_CAP_AMBIENT_RAISE ,
1712 but either the capability specified in
1713 .IR arg3
1714 is not present in the process's permitted and inheritable capability sets,
1715 or the
1716 .B PR_CAP_AMBIENT_LOWER
1717 securebit has been set.
1719 .B ERANGE
1720 .I option
1722 .BR PR_SET_SPECULATION_CTRL
1724 .IR arg3
1725 is neither
1726 .BR PR_SPEC_ENABLE ,
1727 .BR PR_SPEC_DISABLE ,
1729 .BR PR_SPEC_FORCE_DISABLE .
1731 .B EINVAL
1732 .I option
1734 .BR PR_GET_SPECULATION_CTRL
1736 .BR PR_SET_SPECULATION_CTRL
1737 and unused arguments to
1738 .BR prctl ()
1739 are not 0.
1740 .SH VERSIONS
1742 .BR prctl ()
1743 system call was introduced in Linux 2.1.57.
1744 .\" The library interface was added in glibc 2.0.6
1745 .SH CONFORMING TO
1746 This call is Linux-specific.
1747 IRIX has a
1748 .BR prctl ()
1749 system call (also introduced in Linux 2.1.44
1750 as irix_prctl on the MIPS architecture),
1751 with prototype
1753 .in +4n
1755 .BI "ptrdiff_t prctl(int " option ", int " arg2 ", int " arg3 );
1759 and options to get the maximum number of processes per user,
1760 get the maximum number of processors the calling process can use,
1761 find out whether a specified process is currently blocked,
1762 get or set the maximum stack size, and so on.
1763 .SH SEE ALSO
1764 .BR signal (2),
1765 .BR core (5)