]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/prctl.2
prctl.2: Note semantics of child_subreaper setting on fork() and exec()
[thirdparty/man-pages.git] / man2 / prctl.2
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 2016-12-12 "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 .sp
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.
102 .TP
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.
108 .RE
109 .IP
110 In all of the above operations,
111 .I arg4
112 and
113 .I arg5
114 must be specified as 0.
115 .TP
116 .BR PR_CAPBSET_READ " (since Linux 2.6.25)"
117 Return (as the function result) 1 if the capability specified in
118 .I arg2
119 is in the calling thread's capability bounding set,
120 or 0 if it is not.
121 (The capability constants are defined in
122 .IR <linux/capability.h> .)
123 The capability bounding set dictates
124 whether the process can receive the capability through a
125 file's permitted capability set on a subsequent call to
126 .BR execve (2).
127
128 If the capability specified in
129 .I arg2
130 is not valid, then the call fails with the error
131 .BR EINVAL .
132 .TP
133 .BR PR_CAPBSET_DROP " (since Linux 2.6.25)"
134 If the calling thread has the
135 .B CAP_SETPCAP
136 capability within its user namespace, then drop the capability specified by
137 .I arg2
138 from the calling thread's capability bounding set.
139 Any children of the calling thread will inherit the newly
140 reduced bounding set.
141
142 The call fails with the error:
143 .B EPERM
144 if the calling thread does not have the
145 .BR CAP_SETPCAP ;
146 .BR EINVAL
147 if
148 .I arg2
149 does not represent a valid capability; or
150 .BR EINVAL
151 if file capabilities are not enabled in the kernel,
152 in which case bounding sets are not supported.
153 .TP
154 .BR PR_SET_CHILD_SUBREAPER " (since Linux 3.4)"
155 .\" commit ebec18a6d3aa1e7d84aab16225e87fd25170ec2b
156 If
157 .I arg2
158 is nonzero,
159 set the "child subreaper" attribute of the calling process;
160 if
161 .I arg2
162 is zero, unset the attribute.
163
164 When a process is marked as a child subreaper,
165 all of the children that it creates, and their descendants,
166 will be marked as having a subreaper.
167 In effect, a subreaper fulfills the role of
168 .BR init (1)
169 for its descendant processes.
170 Upon termination of a process
171 that is orphaned (i.e., its immediate parent has already terminated)
172 and marked as having a subreaper,
173 the nearest still living ancestor subreaper
174 will receive a
175 .BR SIGCHLD
176 signal and will be able to
177 .BR wait (2)
178 on the process to discover its termination status.
179
180 The setting of this bit is not inherited by children created by
181 .BR fork (2)
182 and
183 .BR clone (2).
184 The setting is preserved across
185 .BR execve (2).
186 .TP
187 .BR PR_GET_CHILD_SUBREAPER " (since Linux 3.4)"
188 Return the "child subreaper" setting of the caller,
189 in the location pointed to by
190 .IR "(int\ *) arg2" .
191 .TP
192 .BR PR_SET_DUMPABLE " (since Linux 2.3.20)"
193 Set the state of the "dumpable" flag,
194 which determines whether core dumps are produced for the calling process
195 upon delivery of a signal whose default behavior is to produce a core dump.
196
197 In kernels up to and including 2.6.12,
198 .I arg2
199 must be either 0
200 .RB ( SUID_DUMP_DISABLE ,
201 process is not dumpable) or 1
202 .RB ( SUID_DUMP_USER ,
203 process is dumpable).
204 Between kernels 2.6.13 and 2.6.17,
205 .\" commit abf75a5033d4da7b8a7e92321d74021d1fcfb502
206 the value 2 was also permitted,
207 which caused any binary which normally would not be dumped
208 to be dumped readable by root only;
209 for security reasons, this feature has been removed.
210 .\" See http://marc.theaimsgroup.com/?l=linux-kernel&m=115270289030630&w=2
211 .\" Subject: Fix prctl privilege escalation (CVE-2006-2451)
212 .\" From: Marcel Holtmann <marcel () holtmann ! org>
213 .\" Date: 2006-07-12 11:12:00
214 (See also the description of
215 .I /proc/sys/fs/\:suid_dumpable
216 in
217 .BR proc (5).)
218
219 Normally, this flag is set to 1.
220 However, it is reset to the current value contained in the file
221 .IR /proc/sys/fs/\:suid_dumpable
222 (which by default has the value 0),
223 in the following circumstances:
224 .\" See kernel/cred.c::commit_creds() (Linux 3.18 sources)
225 .RS
226 .IP * 3
227 The process's effective user or group ID is changed.
228 .IP *
229 The process's filesystem user or group ID is changed (see
230 .BR credentials (7)).
231 .IP *
232 The process executes
233 .RB ( execve (2))
234 a set-user-ID or set-group-ID program, resulting in a change
235 of either the effective user ID or the effective group ID.
236 .IP *
237 The process executes
238 .RB ( execve (2))
239 a program that has file capabilities (see
240 .BR capabilities (7)),
241 .\" See kernel/cred.c::commit_creds()
242 but only if the permitted capabilities
243 gained exceed those already permitted for the process.
244 .\" Also certain namespace operations;
245 .RE
246 .IP
247 Processes that are not dumpable can not be attached via
248 .BR ptrace (2)
249 .BR PTRACE_ATTACH ;
250 see
251 .BR ptrace (2)
252 for further details.
253
254 If a process is not dumpable,
255 the ownership of files in the process's
256 .IR /proc/[pid]
257 directory is affected as described in
258 .BR proc (5).
259 .TP
260 .BR PR_GET_DUMPABLE " (since Linux 2.3.20)"
261 Return (as the function result) the current state of the calling
262 process's dumpable flag.
263 .\" Since Linux 2.6.13, the dumpable flag can have the value 2,
264 .\" but in 2.6.13 PR_GET_DUMPABLE simply returns 1 if the dumpable
265 .\" flags has a nonzero value. This was fixed in 2.6.14.
266 .TP
267 .BR PR_SET_ENDIAN " (since Linux 2.6.18, PowerPC only)"
268 Set the endian-ness of the calling process to the value given
269 in \fIarg2\fP, which should be one of the following:
270 .\" Respectively 0, 1, 2
271 .BR PR_ENDIAN_BIG ,
272 .BR PR_ENDIAN_LITTLE ,
273 or
274 .B PR_ENDIAN_PPC_LITTLE
275 (PowerPC pseudo little endian).
276 .TP
277 .BR PR_GET_ENDIAN " (since Linux 2.6.18, PowerPC only)"
278 Return the endian-ness of the calling process,
279 in the location pointed to by
280 .IR "(int\ *) arg2" .
281 .TP
282 .BR PR_SET_FP_MODE " (since Linux 4.0, only on MIPS)"
283 .\" commit 9791554b45a2acc28247f66a5fd5bbc212a6b8c8
284 On the MIPS architecture,
285 user-space code can be built using an ABI which permits linking
286 with code that has more restrictive floating-point (FP) requirements.
287 For example, user-space code may be built to target the O32 FPXX ABI
288 and linked with code built for either one of the more restrictive
289 FP32 or FP64 ABIs.
290 When more restrictive code is linked in,
291 the overall requirement for the process is to use the more
292 restrictive floating-point mode.
293
294 Because the kernel has no means of knowing in advance
295 which mode the process should be executed in,
296 and because these restrictions can
297 change over the lifetime of the process, the
298 .B PR_SET_FP_MODE
299 operation is provided to allow control of the floating-point mode
300 from user space.
301
302 .\" https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking
303 The
304 .I (unsigned int) arg2
305 argument is a bit mask describing the floating-point mode used:
306 .RS
307 .TP
308 .BR PR_FP_MODE_FR
309 When this bit is
310 .I unset
311 (so called
312 .BR FR=0 " or " FR0
313 mode), the 32 floating-point registers are 32 bits wide,
314 and 64-bit registers are represented as a pair of registers
315 (even- and odd- numbered,
316 with the even-numbered register containing the lower 32 bits,
317 and the odd-numbered register containing the higher 32 bits).
318
319 When this bit is
320 .I set
321 (on supported hardware),
322 the 32 floating-point registers are 64 bits wide (so called
323 .BR FR=1 " or " FR1
324 mode).
325 Note that modern MIPS implementations (MIPS R6 and newer) support
326 .B FR=1
327 mode only.
328
329
330 Applications that use the O32 FP32 ABI can operate only when this bit is
331 .I unset
332 .RB ( FR=0 ;
333 or they can be used with FRE enabled, see below).
334 Applications that use the O32 FP64 ABI
335 (and the O32 FP64A ABI, which exists to
336 provide the ability to operate with existing FP32 code; see below)
337 can operate only when this bit is
338 .I set
339 .RB ( FR=1 ).
340 Applications that use the O32 FPXX ABI can operate with either
341 .BR FR=0
342 or
343 .BR FR=1 .
344 .TP
345 .BR PR_FP_MODE_FRE
346 Enable emulation of 32-bit floating-point mode.
347 When this mode is enabled,
348 it emulates 32-bit floating-point operations
349 by raising a reserved-instruction exception
350 on every instruction that uses 32-bit formats and
351 the kernel then handles the instruction in software.
352 (The problem lies in the discrepancy of handling odd-numbered registers
353 which are the high 32 bits of 64-bit registers with even numbers in
354 .B FR=0
355 mode and the lower 32-bit parts of odd-numbered 64-bit registers in
356 .B FR=1
357 mode.)
358 Enabling this bit is necessary when code with the O32 FP32 ABI should operate
359 with code with compatible the O32 FPXX or O32 FP64A ABIs (which require
360 .B FR=1
361 FPU mode) or when it is executed on newer hardware (MIPS R6 onwards)
362 which lacks
363 .B FR=0
364 mode support when a binary with the FP32 ABI is used.
365 .IP
366 Note that this mode makes sense only when the FPU is in 64-bit mode
367 .RB ( FR=1 ).
368 .IP
369 Note that the use of emulation inherently has a significant performance hit
370 and should be avoided if possible.
371 .RE
372 .IP
373 In the N32/N64 ABI, 64-bit floating-point mode is always used,
374 so FPU emulation is not required and the FPU always operates in
375 .B FR=1
376 mode.
377 .IP
378 This option is mainly intended for use by the dynamic linker
379 .RB ( ld.so (8)).
380 .IP
381 The arguments
382 .IR arg3 ,
383 .IR arg4 ,
384 and
385 .IR arg5
386 are ignored.
387 .TP
388 .BR PR_GET_FP_MODE " (since Linux 4.0, only on MIPS)"
389 Get the current floating-point mode (see the description of
390 .B PR_SET_FP_MODE
391 for details).
392
393 On success,
394 the call returns a bit mask which represents the current floating-point mode.
395
396 The arguments
397 .IR arg2 ,
398 .IR arg3 ,
399 .IR arg4 ,
400 and
401 .IR arg5
402 are ignored.
403 .TP
404 .BR PR_SET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)"
405 Set floating-point emulation control bits to \fIarg2\fP.
406 Pass
407 .B PR_FPEMU_NOPRINT
408 to silently emulate floating-point operation accesses, or
409 .B PR_FPEMU_SIGFPE
410 to not emulate floating-point operations and send
411 .B SIGFPE
412 instead.
413 .TP
414 .BR PR_GET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)"
415 Return floating-point emulation control bits,
416 in the location pointed to by
417 .IR "(int\ *) arg2" .
418 .TP
419 .BR PR_SET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)"
420 Set floating-point exception mode to \fIarg2\fP.
421 Pass \fBPR_FP_EXC_SW_ENABLE\fP to use FPEXC for FP exception enables,
422 \fBPR_FP_EXC_DIV\fP for floating-point divide by zero,
423 \fBPR_FP_EXC_OVF\fP for floating-point overflow,
424 \fBPR_FP_EXC_UND\fP for floating-point underflow,
425 \fBPR_FP_EXC_RES\fP for floating-point inexact result,
426 \fBPR_FP_EXC_INV\fP for floating-point invalid operation,
427 \fBPR_FP_EXC_DISABLED\fP for FP exceptions disabled,
428 \fBPR_FP_EXC_NONRECOV\fP for async nonrecoverable exception mode,
429 \fBPR_FP_EXC_ASYNC\fP for async recoverable exception mode,
430 \fBPR_FP_EXC_PRECISE\fP for precise exception mode.
431 .TP
432 .BR PR_GET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)"
433 Return floating-point exception mode,
434 in the location pointed to by
435 .IR "(int\ *) arg2" .
436 .TP
437 .BR PR_SET_KEEPCAPS " (since Linux 2.2.18)"
438 Set the state of the calling thread's "keep capabilities" flag,
439 which determines whether the thread's permitted
440 capability set is cleared when a change is made to the thread's user IDs
441 such that the thread's real UID, effective UID, and saved set-user-ID
442 all become nonzero when at least one of them previously had the value 0.
443 By default, the permitted capability set is cleared when such a change is made;
444 setting the "keep capabilities" flag prevents it from being cleared.
445 .I arg2
446 must be either 0 (permitted capabilities are cleared)
447 or 1 (permitted capabilities are kept).
448 (A thread's
449 .I effective
450 capability set is always cleared when such a credential change is made,
451 regardless of the setting of the "keep capabilities" flag.)
452 The "keep capabilities" value will be reset to 0 on subsequent calls to
453 .BR execve (2).
454 .TP
455 .BR PR_GET_KEEPCAPS " (since Linux 2.2.18)"
456 Return (as the function result) the current state of the calling thread's
457 "keep capabilities" flag.
458 .TP
459 .BR PR_MCE_KILL " (since Linux 2.6.32)"
460 Set the machine check memory corruption kill policy for the calling thread.
461 If
462 .I arg2
463 is
464 .BR PR_MCE_KILL_CLEAR ,
465 clear the thread memory corruption kill policy and use the system-wide default.
466 (The system-wide default is defined by
467 .IR /proc/sys/vm/memory_failure_early_kill ;
468 see
469 .BR proc (5).)
470 If
471 .I arg2
472 is
473 .BR PR_MCE_KILL_SET ,
474 use a thread-specific memory corruption kill policy.
475 In this case,
476 .I arg3
477 defines whether the policy is
478 .I early kill
479 .RB ( PR_MCE_KILL_EARLY ),
480 .I late kill
481 .RB ( PR_MCE_KILL_LATE ),
482 or the system-wide default
483 .RB ( PR_MCE_KILL_DEFAULT ).
484 Early kill means that the thread receives a
485 .B SIGBUS
486 signal as soon as hardware memory corruption is detected inside
487 its address space.
488 In late kill mode, the process is killed only when it accesses a corrupted page.
489 See
490 .BR sigaction (2)
491 for more information on the
492 .BR SIGBUS
493 signal.
494 The policy is inherited by children.
495 The remaining unused
496 .BR prctl ()
497 arguments must be zero for future compatibility.
498 .TP
499 .BR PR_MCE_KILL_GET " (since Linux 2.6.32)"
500 Return the current per-process machine check kill policy.
501 All unused
502 .BR prctl ()
503 arguments must be zero.
504 .TP
505 .BR PR_SET_MM " (since Linux 3.3)"
506 .\" commit 028ee4be34a09a6d48bdf30ab991ae933a7bc036
507 Modify certain kernel memory map descriptor fields
508 of the calling process.
509 Usually these fields are set by the kernel and dynamic loader (see
510 .BR ld.so (8)
511 for more information) and a regular application should not use this feature.
512 However, there are cases, such as self-modifying programs,
513 where a program might find it useful to change its own memory map.
514 This feature is available only if the kernel is built with the
515 .BR CONFIG_CHECKPOINT_RESTORE
516 option enabled.
517 The calling process must have the
518 .BR CAP_SYS_RESOURCE
519 capability.
520 The value in
521 .I arg2
522 is one of the options below, while
523 .I arg3
524 provides a new value for the option.
525 .RS
526 .TP
527 .BR PR_SET_MM_START_CODE
528 Set the address above which the program text can run.
529 The corresponding memory area must be readable and executable,
530 but not writable or sharable (see
531 .BR mprotect (2)
532 and
533 .BR mmap (2)
534 for more information).
535 .TP
536 .BR PR_SET_MM_END_CODE
537 Set the address below which the program text can run.
538 The corresponding memory area must be readable and executable,
539 but not writable or sharable.
540 .TP
541 .BR PR_SET_MM_START_DATA
542 Set the address above which initialized and
543 uninitialized (bss) data are placed.
544 The corresponding memory area must be readable and writable,
545 but not executable or sharable.
546 .TP
547 .B PR_SET_MM_END_DATA
548 Set the address below which initialized and
549 uninitialized (bss) data are placed.
550 The corresponding memory area must be readable and writable,
551 but not executable or sharable.
552 .TP
553 .BR PR_SET_MM_START_STACK
554 Set the start address of the stack.
555 The corresponding memory area must be readable and writable.
556 .TP
557 .BR PR_SET_MM_START_BRK
558 Set the address above which the program heap can be expanded with
559 .BR brk (2)
560 call.
561 The address must be greater than the ending address of
562 the current program data segment.
563 In addition, the combined size of the resulting heap and
564 the size of the data segment can't exceed the
565 .BR RLIMIT_DATA
566 resource limit (see
567 .BR setrlimit (2)).
568 .TP
569 .BR PR_SET_MM_BRK
570 Set the current
571 .BR brk (2)
572 value.
573 The requirements for the address are the same as for the
574 .BR PR_SET_MM_START_BRK
575 option.
576 .P
577 The following options are available since Linux 3.5.
578 .\" commit fe8c7f5cbf91124987106faa3bdf0c8b955c4cf7
579 .TP
580 .BR PR_SET_MM_ARG_START
581 Set the address above which the program command line is placed.
582 .TP
583 .BR PR_SET_MM_ARG_END
584 Set the address below which the program command line is placed.
585 .TP
586 .BR PR_SET_MM_ENV_START
587 Set the address above which the program environment is placed.
588 .TP
589 .BR PR_SET_MM_ENV_END
590 Set the address below which the program environment is placed.
591 .IP
592 The address passed with
593 .BR PR_SET_MM_ARG_START ,
594 .BR PR_SET_MM_ARG_END ,
595 .BR PR_SET_MM_ENV_START ,
596 and
597 .BR PR_SET_MM_ENV_END
598 should belong to a process stack area.
599 Thus, the corresponding memory area must be readable, writable, and
600 (depending on the kernel configuration) have the
601 .BR MAP_GROWSDOWN
602 attribute set (see
603 .BR mmap (2)).
604 .TP
605 .BR PR_SET_MM_AUXV
606 Set a new auxiliary vector.
607 The
608 .I arg3
609 argument should provide the address of the vector.
610 The
611 .I arg4
612 is the size of the vector.
613 .TP
614 .BR PR_SET_MM_EXE_FILE
615 .\" commit b32dfe377102ce668775f8b6b1461f7ad428f8b6
616 Supersede the
617 .IR /proc/pid/exe
618 symbolic link with a new one pointing to a new executable file
619 identified by the file descriptor provided in
620 .I arg3
621 argument.
622 The file descriptor should be obtained with a regular
623 .BR open (2)
624 call.
625 .IP
626 To change the symbolic link, one needs to unmap all existing
627 executable memory areas, including those created by the kernel itself
628 (for example the kernel usually creates at least one executable
629 memory area for the ELF
630 .IR \.text
631 section).
632 .IP
633 The second limitation is that such transitions can be done only once
634 in a process life time.
635 Any further attempts will be rejected.
636 This should help system administrators monitor unusual
637 symbolic-link transitions over all processes running on a system.
638 .RE
639 .TP
640 .BR PR_MPX_ENABLE_MANAGEMENT ", " PR_MPX_DISABLE_MANAGEMENT " (since Linux 3.19) "
641 .\" commit fe3d197f84319d3bce379a9c0dc17b1f48ad358c
642 .\" See also http://lwn.net/Articles/582712/
643 .\" See also https://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler
644 Enable or disable kernel management of Memory Protection eXtensions (MPX)
645 bounds tables.
646 The
647 .IR arg2 ,
648 .IR arg3 ,
649 .IR arg4 ,
650 and
651 .IR arg5
652 .\" commit e9d1b4f3c60997fe197bf0243cb4a41a44387a88
653 arguments must be zero.
654
655 MPX is a hardware-assisted mechanism for performing bounds checking on
656 pointers.
657 It consists of a set of registers storing bounds information
658 and a set of special instruction prefixes that tell the CPU on which
659 instructions it should do bounds enforcement.
660 There is a limited number of these registers and
661 when there are more pointers than registers,
662 their contents must be "spilled" into a set of tables.
663 These tables are called "bounds tables" and the MPX
664 .BR prctl ()
665 operations control
666 whether the kernel manages their allocation and freeing.
667
668 When management is enabled, the kernel will take over allocation
669 and freeing of the bounds tables.
670 It does this by trapping the #BR exceptions that result
671 at first use of missing bounds tables and
672 instead of delivering the exception to user space,
673 it allocates the table and populates the bounds directory
674 with the location of the new table.
675 For freeing, the kernel checks to see if bounds tables are
676 present for memory which is not allocated, and frees them if so.
677
678 Before enabling MPX management using
679 .BR PR_MPX_ENABLE_MANAGEMENT ,
680 the application must first have allocated a user-space buffer for
681 the bounds directory and placed the location of that directory in the
682 .I bndcfgu
683 register.
684
685 These calls will fail if the CPU or kernel does not support MPX.
686 Kernel support for MPX is enabled via the
687 .BR CONFIG_X86_INTEL_MPX
688 configuration option.
689 You can check whether the CPU supports MPX by looking for the 'mpx'
690 CPUID bit, like with the following command:
691
692 cat /proc/cpuinfo | grep ' mpx '
693
694 A thread may not switch in or out of long (64-bit) mode while MPX is
695 enabled.
696
697 All threads in a process are affected by these calls.
698
699 The child of a
700 .BR fork (2)
701 inherits the state of MPX management.
702 During
703 .BR execve (2),
704 MPX management is reset to a state as if
705 .BR PR_MPX_DISABLE_MANAGEMENT
706 had been called.
707
708 For further information on Intel MPX, see the kernel source file
709 .IR Documentation/x86/intel_mpx.txt .
710 .TP
711 .BR PR_SET_NAME " (since Linux 2.6.9)"
712 Set the name of the calling thread,
713 using the value in the location pointed to by
714 .IR "(char\ *) arg2" .
715 The name can be up to 16 bytes long,
716 .\" TASK_COMM_LEN in include/linux/sched.h
717 including the terminating null byte.
718 (If the length of the string, including the terminating null byte,
719 exceeds 16 bytes, the string is silently truncated.)
720 This is the same attribute that can be set via
721 .BR pthread_setname_np (3)
722 and retrieved using
723 .BR pthread_getname_np (3).
724 The attribute is likewise accessible via
725 .IR /proc/self/task/[tid]/comm ,
726 where
727 .I tid
728 is the name of the calling thread.
729 .TP
730 .BR PR_GET_NAME " (since Linux 2.6.11)"
731 Return the name of the calling thread,
732 in the buffer pointed to by
733 .IR "(char\ *) arg2" .
734 The buffer should allow space for up to 16 bytes;
735 the returned string will be null-terminated.
736 .TP
737 .BR PR_SET_NO_NEW_PRIVS " (since Linux 3.5)"
738 Set the calling thread's
739 .I no_new_privs
740 bit to the value in
741 .IR arg2 .
742 With
743 .I no_new_privs
744 set to 1,
745 .BR execve (2)
746 promises not to grant privileges to do anything
747 that could not have been done without the
748 .BR execve (2)
749 call (for example,
750 rendering the set-user-ID and set-group-ID mode bits,
751 and file capabilities non-functional).
752 Once set, this bit cannot be unset.
753 The setting of this bit is inherited by children created by
754 .BR fork (2)
755 and
756 .BR clone (2),
757 and preserved across
758 .BR execve (2).
759
760 Since Linux 4.10,
761 the value of a thread's
762 .I no_new_privs
763 bit can be viewed via the
764 .I NoNewPrivs
765 field in the
766 .IR /proc/[pid]/status
767 file.
768
769 For more information, see the kernel source file
770 .IR Documentation/prctl/no_new_privs.txt .
771 See also
772 .BR seccomp (2).
773 .TP
774 .BR PR_GET_NO_NEW_PRIVS " (since Linux 3.5)"
775 Return (as the function result) the value of the
776 .I no_new_privs
777 bit for the calling thread.
778 A value of 0 indicates the regular
779 .BR execve (2)
780 behavior.
781 A value of 1 indicates
782 .BR execve (2)
783 will operate in the privilege-restricting mode described above.
784 .TP
785 .BR PR_SET_PDEATHSIG " (since Linux 2.1.57)"
786 Set the parent death signal
787 of the calling process to \fIarg2\fP (either a signal value
788 in the range 1..maxsig, or 0 to clear).
789 This is the signal that the calling process will get when its
790 parent dies.
791 This value is cleared for the child of a
792 .BR fork (2)
793 and (since Linux 2.4.36 / 2.6.23)
794 when executing a set-user-ID or set-group-ID binary,
795 or a binary that has associated capabilities (see
796 .BR capabilities (7)).
797 This value is preserved across
798 .BR execve (2).
799
800 .IR Warning :
801 .\" https://bugzilla.kernel.org/show_bug.cgi?id=43300
802 the "parent" in this case is considered to be the
803 .I thread
804 that created this process.
805 In other words, the signal will be sent when that thread terminates
806 (via, for example,
807 .BR pthread_exit (3)),
808 rather than after all of the threads in the parent process terminate.
809 .TP
810 .BR PR_GET_PDEATHSIG " (since Linux 2.3.15)"
811 Return the current value of the parent process death signal,
812 in the location pointed to by
813 .IR "(int\ *) arg2" .
814 .TP
815 .BR PR_SET_PTRACER " (since Linux 3.4)"
816 .\" commit 2d514487faf188938a4ee4fb3464eeecfbdcf8eb
817 .\" commit bf06189e4d14641c0148bea16e9dd24943862215
818 This is meaningful only when the Yama LSM is enabled and in mode 1
819 ("restricted ptrace", visible via
820 .IR /proc/sys/kernel/yama/ptrace_scope ).
821 When a "ptracer process ID" is passed in \fIarg2\fP,
822 the caller is declaring that the ptracer process can
823 .BR ptrace (2)
824 the calling process as if it were a direct process ancestor.
825 Each
826 .B PR_SET_PTRACER
827 operation replaces the previous "ptracer process ID".
828 Employing
829 .B PR_SET_PTRACER
830 with
831 .I arg2
832 set to 0 clears the caller's "ptracer process ID".
833 If
834 .I arg2
835 is
836 .BR PR_SET_PTRACER_ANY ,
837 the ptrace restrictions introduced by Yama are effectively disabled for the
838 calling process.
839
840 For further information, see the kernel source file
841 .IR Documentation/security/Yama.txt .
842 .TP
843 .BR PR_SET_SECCOMP " (since Linux 2.6.23)"
844 .\" See http://thread.gmane.org/gmane.linux.kernel/542632
845 .\" [PATCH 0 of 2] seccomp updates
846 .\" andrea@cpushare.com
847 Set the secure computing (seccomp) mode for the calling thread, to limit
848 the available system calls.
849 The more recent
850 .BR seccomp (2)
851 system call provides a superset of the functionality of
852 .BR PR_SET_SECCOMP .
853
854 The seccomp mode is selected via
855 .IR arg2 .
856 (The seccomp constants are defined in
857 .IR <linux/seccomp.h> .)
858
859 With
860 .IR arg2
861 set to
862 .BR SECCOMP_MODE_STRICT ,
863 the only system calls that the thread is permitted to make are
864 .BR read (2),
865 .BR write (2),
866 .BR _exit (2)
867 (but not
868 .BR exit_group (2)),
869 and
870 .BR sigreturn (2).
871 Other system calls result in the delivery of a
872 .BR SIGKILL
873 signal.
874 Strict secure computing mode is useful for number-crunching applications
875 that may need to execute untrusted byte code,
876 perhaps obtained by reading from a pipe or socket.
877 This operation is available only
878 if the kernel is configured with
879 .B CONFIG_SECCOMP
880 enabled.
881
882 With
883 .IR arg2
884 set to
885 .BR SECCOMP_MODE_FILTER " (since Linux 3.5),"
886 the system calls allowed are defined by a pointer
887 to a Berkeley Packet Filter passed in
888 .IR arg3 .
889 This argument is a pointer to
890 .IR "struct sock_fprog" ;
891 it can be designed to filter
892 arbitrary system calls and system call arguments.
893 This mode is available only if the kernel is configured with
894 .B CONFIG_SECCOMP_FILTER
895 enabled.
896
897 If
898 .BR SECCOMP_MODE_FILTER
899 filters permit
900 .BR fork (2),
901 then the seccomp mode is inherited by children created by
902 .BR fork (2);
903 if
904 .BR execve (2)
905 is permitted, then the seccomp mode is preserved across
906 .BR execve (2).
907 If the filters permit
908 .BR prctl ()
909 calls, then additional filters can be added;
910 they are run in order until the first non-allow result is seen.
911
912 For further information, see the kernel source file
913 .IR Documentation/prctl/seccomp_filter.txt .
914 .TP
915 .BR PR_GET_SECCOMP " (since Linux 2.6.23)"
916 Return (as the function result)
917 the secure computing mode of the calling thread.
918 If the caller is not in secure computing mode, this operation returns 0;
919 if the caller is in strict secure computing mode, then the
920 .BR prctl ()
921 call will cause a
922 .B SIGKILL
923 signal to be sent to the process.
924 If the caller is in filter mode, and this system call is allowed by the
925 seccomp filters, it returns 2; otherwise, the process is killed with a
926 .BR SIGKILL
927 signal.
928 This operation is available only
929 if the kernel is configured with
930 .B CONFIG_SECCOMP
931 enabled.
932
933 Since Linux 3.8, the
934 .IR Seccomp
935 field of the
936 .IR /proc/[pid]/status
937 file provides a method of obtaining the same information,
938 without the risk that the process is killed; see
939 .BR proc (5).
940 .TP
941 .BR PR_SET_SECUREBITS " (since Linux 2.6.26)"
942 Set the "securebits" flags of the calling thread to the value supplied in
943 .IR arg2 .
944 See
945 .BR capabilities (7).
946 .TP
947 .BR PR_GET_SECUREBITS " (since Linux 2.6.26)"
948 Return (as the function result)
949 the "securebits" flags of the calling thread.
950 See
951 .BR capabilities (7).
952 .TP
953 .BR PR_SET_THP_DISABLE " (since Linux 3.15)"
954 .\" commit a0715cc22601e8830ace98366c0c2bd8da52af52
955 Set the state of the "THP disable" flag for the calling thread.
956 If
957 .I arg2
958 has a nonzero value, the flag is set, otherwise it is cleared.
959 Setting this flag provides a method
960 for disabling transparent huge pages
961 for jobs where the code cannot be modified, and using a malloc hook with
962 .BR madvise (2)
963 is not an option (i.e., statically allocated data).
964 The setting of the "THP disable" flag is inherited by a child created via
965 .BR fork (2)
966 and is preserved across
967 .BR execve (2).
968 .\"
969 .TP
970 .BR PR_TASK_PERF_EVENTS_DISABLE " (since Linux 2.6.31)"
971 Disable all performance counters attached to the calling process,
972 regardless of whether the counters were created by
973 this process or another process.
974 Performance counters created by the calling process for other
975 processes are unaffected.
976 For more information on performance counters, see the Linux kernel source file
977 .IR tools/perf/design.txt .
978 .IP
979 Originally called
980 .BR PR_TASK_PERF_COUNTERS_DISABLE ;
981 .\" commit 1d1c7ddbfab358445a542715551301b7fc363e28
982 renamed (with same numerical value)
983 in Linux 2.6.32.
984 .\"
985 .TP
986 .BR PR_TASK_PERF_EVENTS_ENABLE " (since Linux 2.6.31)"
987 The converse of
988 .BR PR_TASK_PERF_EVENTS_DISABLE ;
989 enable performance counters attached to the calling process.
990 .IP
991 Originally called
992 .BR PR_TASK_PERF_COUNTERS_ENABLE ;
993 .\" commit 1d1c7ddbfab358445a542715551301b7fc363e28
994 renamed
995 .\" commit cdd6c482c9ff9c55475ee7392ec8f672eddb7be6
996 in Linux 2.6.32.
997 .\"
998 .TP
999 .BR PR_GET_THP_DISABLE " (since Linux 3.15)"
1000 Return (via the function result) the current setting of the "THP disable"
1001 flag for the calling thread:
1002 either 1, if the flag is set, or 0, if it is not.
1003 .TP
1004 .BR PR_GET_TID_ADDRESS " (since Linux 3.5)"
1005 .\" commit 300f786b2683f8bb1ec0afb6e1851183a479c86d
1006 Retrieve the
1007 .I clear_child_tid
1008 address set by
1009 .BR set_tid_address (2)
1010 and the
1011 .BR clone (2)
1012 .B CLONE_CHILD_CLEARTID
1013 flag, in the location pointed to by
1014 .IR "(int\ **)\ arg2" .
1015 This feature is available only if the kernel is built with the
1016 .BR CONFIG_CHECKPOINT_RESTORE
1017 option enabled.
1018 Note that since the
1019 .BR prctl ()
1020 system call does not have a compat implementation for
1021 the AMD64 x32 and MIPS n32 ABIs,
1022 and the kernel writes out a pointer using the kernel's pointer size,
1023 this operation expects a user-space buffer of 8 (not 4) bytes on these ABIs.
1024 .TP
1025 .BR PR_SET_TIMERSLACK " (since Linux 2.6.28)"
1026 .\" See https://lwn.net/Articles/369549/
1027 .\" commit 6976675d94042fbd446231d1bd8b7de71a980ada
1028 Each thread has two associated timer slack values:
1029 a "default" value, and a "current" value.
1030 This operation sets the "current" timer slack value for the calling thread.
1031 If the nanosecond value supplied in
1032 .IR arg2
1033 is greater than zero, then the "current" value is set to this value.
1034 If
1035 .I arg2
1036 is less than or equal to zero,
1037 .\" It seems that it's not possible to set the timer slack to zero;
1038 .\" The minimum value is 1? Seems a little strange.
1039 the "current" timer slack is reset to the
1040 thread's "default" timer slack value.
1041
1042 The "current" timer slack is used by the kernel to group timer expirations
1043 for the calling thread that are close to one another;
1044 as a consequence, timer expirations for the thread may be
1045 up to the specified number of nanoseconds late (but will never expire early).
1046 Grouping timer expirations can help reduce system power consumption
1047 by minimizing CPU wake-ups.
1048
1049 The timer expirations affected by timer slack are those set by
1050 .BR select (2),
1051 .BR pselect (2),
1052 .BR poll (2),
1053 .BR ppoll (2),
1054 .BR epoll_wait (2),
1055 .BR epoll_pwait (2),
1056 .BR clock_nanosleep (2),
1057 .BR nanosleep (2),
1058 and
1059 .BR futex (2)
1060 (and thus the library functions implemented via futexes, including
1061 .\" List obtained by grepping for futex usage in glibc source
1062 .BR pthread_cond_timedwait (3),
1063 .BR pthread_mutex_timedlock (3),
1064 .BR pthread_rwlock_timedrdlock (3),
1065 .BR pthread_rwlock_timedwrlock (3),
1066 and
1067 .BR sem_timedwait (3)).
1068
1069 Timer slack is not applied to threads that are scheduled under
1070 a real-time scheduling policy (see
1071 .BR sched_setscheduler (2)).
1072
1073 When a new thread is created,
1074 the two timer slack values are made the same as the "current" value
1075 of the creating thread.
1076 Thereafter, a thread can adjust its "current" timer slack value via
1077 .BR PR_SET_TIMERSLACK .
1078 The "default" value can't be changed.
1079 The timer slack values of
1080 .IR init
1081 (PID 1), the ancestor of all processes,
1082 are 50,000 nanoseconds (50 microseconds).
1083 The timer slack values are preserved across
1084 .BR execve (2).
1085
1086 Since Linux 4.6, the "current" timer slack value of any process
1087 can be examined and changed via the file
1088 .IR /proc/[pid]/timerslack_ns .
1089 See
1090 .BR proc (5).
1091 .TP
1092 .BR PR_GET_TIMERSLACK " (since Linux 2.6.28)"
1093 Return (as the function result)
1094 the "current" timer slack value of the calling thread.
1095 .TP
1096 .BR PR_SET_TIMING " (since Linux 2.6.0-test4)"
1097 Set whether to use (normal, traditional) statistical process timing or
1098 accurate timestamp-based process timing, by passing
1099 .B PR_TIMING_STATISTICAL
1100 .\" 0
1101 or
1102 .B PR_TIMING_TIMESTAMP
1103 .\" 1
1104 to \fIarg2\fP.
1105 .B PR_TIMING_TIMESTAMP
1106 is not currently implemented
1107 (attempting to set this mode will yield the error
1108 .BR EINVAL ).
1109 .\" PR_TIMING_TIMESTAMP doesn't do anything in 2.6.26-rc8,
1110 .\" and looking at the patch history, it appears
1111 .\" that it never did anything.
1112 .TP
1113 .BR PR_GET_TIMING " (since Linux 2.6.0-test4)"
1114 Return (as the function result) which process timing method is currently
1115 in use.
1116 .TP
1117 .BR PR_SET_TSC " (since Linux 2.6.26, x86 only)"
1118 Set the state of the flag determining whether the timestamp counter
1119 can be read by the process.
1120 Pass
1121 .B PR_TSC_ENABLE
1122 to
1123 .I arg2
1124 to allow it to be read, or
1125 .B PR_TSC_SIGSEGV
1126 to generate a
1127 .B SIGSEGV
1128 when the process tries to read the timestamp counter.
1129 .TP
1130 .BR PR_GET_TSC " (since Linux 2.6.26, x86 only)"
1131 Return the state of the flag determining whether the timestamp counter
1132 can be read,
1133 in the location pointed to by
1134 .IR "(int\ *) arg2" .
1135 .TP
1136 .B PR_SET_UNALIGN
1137 (Only on: ia64, since Linux 2.3.48; parisc, since Linux 2.6.15;
1138 PowerPC, since Linux 2.6.18; Alpha, since Linux 2.6.22;
1139 .\" sh: 94ea5e449ae834af058ef005d16a8ad44fcf13d6
1140 .\" tile: 2f9ac29eec71a696cb0dcc5fb82c0f8d4dac28c9
1141 sh, since Linux 2.6.34; tile, since Linux 3.12)
1142 Set unaligned access control bits to \fIarg2\fP.
1143 Pass
1144 \fBPR_UNALIGN_NOPRINT\fP to silently fix up unaligned user accesses,
1145 or \fBPR_UNALIGN_SIGBUS\fP to generate
1146 .B SIGBUS
1147 on unaligned user access.
1148 Alpha also supports an additional flag with the value
1149 of 4 and no corresponding named constant,
1150 which instructs kernel to not fix up
1151 unaligned accesses (it is analogous to providing the
1152 .BR UAC_NOFIX
1153 flag in
1154 .BR SSI_NVPAIRS
1155 operation of the
1156 .BR setsysinfo ()
1157 system call on Tru64).
1158 .TP
1159 .B PR_GET_UNALIGN
1160 (see
1161 .B PR_SET_UNALIGN
1162 for information on versions and architectures)
1163 Return unaligned access control bits, in the location pointed to by
1164 .IR "(unsigned int\ *) arg2" .
1165 .SH RETURN VALUE
1166 On success,
1167 .BR PR_GET_DUMPABLE ,
1168 .BR PR_GET_KEEPCAPS ,
1169 .BR PR_GET_NO_NEW_PRIVS ,
1170 .BR PR_GET_THP_DISABLE ,
1171 .BR PR_CAPBSET_READ ,
1172 .BR PR_GET_TIMING ,
1173 .BR PR_GET_TIMERSLACK ,
1174 .BR PR_GET_SECUREBITS ,
1175 .BR PR_MCE_KILL_GET ,
1176 .BR PR_CAP_AMBIENT + PR_CAP_AMBIENT_IS_SET ,
1177 and (if it returns)
1178 .BR PR_GET_SECCOMP
1179 return the nonnegative values described above.
1180 All other
1181 .I option
1182 values return 0 on success.
1183 On error, \-1 is returned, and
1184 .I errno
1185 is set appropriately.
1186 .SH ERRORS
1187 .TP
1188 .B EACCES
1189 .I option
1190 is
1191 .BR PR_SET_SECCOMP
1192 and
1193 .I arg2
1194 is
1195 .BR SECCOMP_MODE_FILTER ,
1196 but the process does not have the
1197 .BR CAP_SYS_ADMIN
1198 capability or has not set the
1199 .IR no_new_privs
1200 attribute (see the discussion of
1201 .BR PR_SET_NO_NEW_PRIVS
1202 above).
1203 .TP
1204 .B EACCES
1205 .I option
1206 is
1207 .BR PR_SET_MM ,
1208 and
1209 .I arg3
1210 is
1211 .BR PR_SET_MM_EXE_FILE ,
1212 the file is not executable.
1213 .TP
1214 .B EBADF
1215 .I option
1216 is
1217 .BR PR_SET_MM ,
1218 .I arg3
1219 is
1220 .BR PR_SET_MM_EXE_FILE ,
1221 and the file descriptor passed in
1222 .I arg4
1223 is not valid.
1224 .TP
1225 .B EBUSY
1226 .I option
1227 is
1228 .BR PR_SET_MM ,
1229 .I arg3
1230 is
1231 .BR PR_SET_MM_EXE_FILE ,
1232 and this the second attempt to change the
1233 .I /proc/pid/exe
1234 symbolic link, which is prohibited.
1235 .TP
1236 .B EFAULT
1237 .I arg2
1238 is an invalid address.
1239 .TP
1240 .B EFAULT
1241 .I option
1242 is
1243 .BR PR_SET_SECCOMP ,
1244 .I arg2
1245 is
1246 .BR SECCOMP_MODE_FILTER ,
1247 the system was built with
1248 .BR CONFIG_SECCOMP_FILTER ,
1249 and
1250 .I arg3
1251 is an invalid address.
1252 .TP
1253 .B EINVAL
1254 The value of
1255 .I option
1256 is not recognized.
1257 .TP
1258 .B EINVAL
1259 .I option
1260 is
1261 .BR PR_MCE_KILL
1262 or
1263 .BR PR_MCE_KILL_GET
1264 or
1265 .BR PR_SET_MM ,
1266 and unused
1267 .BR prctl ()
1268 arguments were not specified as zero.
1269 .TP
1270 .B EINVAL
1271 .I arg2
1272 is not valid value for this
1273 .IR option .
1274 .TP
1275 .B EINVAL
1276 .I option
1277 is
1278 .BR PR_SET_SECCOMP
1279 or
1280 .BR PR_GET_SECCOMP ,
1281 and the kernel was not configured with
1282 .BR CONFIG_SECCOMP .
1283 .TP
1284 .B EINVAL
1285 .I option
1286 is
1287 .BR PR_SET_SECCOMP ,
1288 .I arg2
1289 is
1290 .BR SECCOMP_MODE_FILTER ,
1291 and the kernel was not configured with
1292 .BR CONFIG_SECCOMP_FILTER .
1293 .TP
1294 .B EINVAL
1295 .I option
1296 is
1297 .BR PR_SET_MM ,
1298 and one of the following is true
1299 .RS
1300 .IP * 3
1301 .I arg4
1302 or
1303 .I arg5
1304 is nonzero;
1305 .IP *
1306 .I arg3
1307 is greater than
1308 .B TASK_SIZE
1309 (the limit on the size of the user address space for this architecture);
1310 .IP *
1311 .I arg2
1312 is
1313 .BR PR_SET_MM_START_CODE ,
1314 .BR PR_SET_MM_END_CODE ,
1315 .BR PR_SET_MM_START_DATA ,
1316 .BR PR_SET_MM_END_DATA ,
1317 or
1318 .BR PR_SET_MM_START_STACK ,
1319 and the permissions of the corresponding memory area are not as required;
1320 .IP *
1321 .I arg2
1322 is
1323 .BR PR_SET_MM_START_BRK
1324 or
1325 .BR PR_SET_MM_BRK ,
1326 and
1327 .I arg3
1328 is less than or equal to the end of the data segment
1329 or specifies a value that would cause the
1330 .B RLIMIT_DATA
1331 resource limit to be exceeded.
1332 .RE
1333 .TP
1334 .B EINVAL
1335 .I option
1336 is
1337 .BR PR_SET_PTRACER
1338 and
1339 .I arg2
1340 is not 0,
1341 .BR PR_SET_PTRACER_ANY ,
1342 or the PID of an existing process.
1343 .TP
1344 .B EINVAL
1345 .I option
1346 is
1347 .B PR_SET_PDEATHSIG
1348 and
1349 .I arg2
1350 is not a valid signal number.
1351 .TP
1352 .B EINVAL
1353 .I option
1354 is
1355 .BR PR_SET_DUMPABLE
1356 and
1357 .I arg2
1358 is neither
1359 .B SUID_DUMP_DISABLE
1360 nor
1361 .BR SUID_DUMP_USER .
1362 .TP
1363 .B EINVAL
1364 .I option
1365 is
1366 .BR PR_SET_TIMING
1367 and
1368 .I arg2
1369 is not
1370 .BR PR_TIMING_STATISTICAL .
1371 .TP
1372 .B EINVAL
1373 .I option
1374 is
1375 .BR PR_SET_NO_NEW_PRIVS
1376 and
1377 .I arg2
1378 is not equal to 1
1379 or
1380 .IR arg3 ,
1381 .IR arg4 ,
1382 or
1383 .IR arg5
1384 is nonzero.
1385 .TP
1386 .B EINVAL
1387 .I option
1388 is
1389 .BR PR_GET_NO_NEW_PRIVS
1390 and
1391 .IR arg2 ,
1392 .IR arg3 ,
1393 .IR arg4 ,
1394 or
1395 .IR arg5
1396 is nonzero.
1397 .TP
1398 .B EINVAL
1399 .I option
1400 is
1401 .BR PR_SET_THP_DISABLE
1402 and
1403 .IR arg3 ,
1404 .IR arg4 ,
1405 or
1406 .IR arg5
1407 is nonzero.
1408 .TP
1409 .B EINVAL
1410 .I option
1411 is
1412 .BR PR_GET_THP_DISABLE
1413 and
1414 .IR arg2 ,
1415 .IR arg3 ,
1416 .IR arg4 ,
1417 or
1418 .IR arg5
1419 is nonzero.
1420 .TP
1421 .B EINVAL
1422 .I option
1423 is
1424 .B PR_CAP_AMBIENT
1425 and an unused argument
1426 .RI ( arg4 ,
1427 .IR arg5 ,
1428 or,
1429 in the case of
1430 .BR PR_CAP_AMBIENT_CLEAR_ALL ,
1431 .IR arg3 )
1432 is nonzero; or
1433 .IR arg2
1434 has an invalid value;
1435 or
1436 .IR arg2
1437 is
1438 .BR PR_CAP_AMBIENT_LOWER ,
1439 .BR PR_CAP_AMBIENT_RAISE ,
1440 or
1441 .BR PR_CAP_AMBIENT_IS_SET
1442 and
1443 .IR arg3
1444 does not specify a valid capability.
1445 .TP
1446 .B ENXIO
1447 .I option
1448 was
1449 .BR PR_MPX_ENABLE_MANAGEMENT
1450 or
1451 .BR PR_MPX_DISABLE_MANAGEMENT
1452 and the kernel or the CPU does not support MPX management.
1453 Check that the kernel and processor have MPX support.
1454 .TP
1455 .B EOPNOTSUPP
1456 .I option
1457 is
1458 .B PR_SET_FP_MODE
1459 and
1460 .I arg2
1461 has an invalid or unsupported value.
1462 .TP
1463 .B EPERM
1464 .I option
1465 is
1466 .BR PR_SET_SECUREBITS ,
1467 and the caller does not have the
1468 .B CAP_SETPCAP
1469 capability,
1470 or tried to unset a "locked" flag,
1471 or tried to set a flag whose corresponding locked flag was set
1472 (see
1473 .BR capabilities (7)).
1474 .TP
1475 .B EPERM
1476 .I option
1477 is
1478 .BR PR_SET_KEEPCAPS ,
1479 and the caller's
1480 .B SECURE_KEEP_CAPS_LOCKED
1481 flag is set
1482 (see
1483 .BR capabilities (7)).
1484 .TP
1485 .B EPERM
1486 .I option
1487 is
1488 .BR PR_CAPBSET_DROP ,
1489 and the caller does not have the
1490 .B CAP_SETPCAP
1491 capability.
1492 .TP
1493 .B EPERM
1494 .I option
1495 is
1496 .BR PR_SET_MM ,
1497 and the caller does not have the
1498 .B CAP_SYS_RESOURCE
1499 capability.
1500 .TP
1501 .B EPERM
1502 .IR option
1503 is
1504 .BR PR_CAP_AMBIENT
1505 and
1506 .IR arg2
1507 is
1508 .BR PR_CAP_AMBIENT_RAISE ,
1509 but either the capability specified in
1510 .IR arg3
1511 is not present in the process's permitted and inheritable capability sets,
1512 or the
1513 .B PR_CAP_AMBIENT_LOWER
1514 securebit has been set.
1515 .SH VERSIONS
1516 The
1517 .BR prctl ()
1518 system call was introduced in Linux 2.1.57.
1519 .\" The library interface was added in glibc 2.0.6
1520 .SH CONFORMING TO
1521 This call is Linux-specific.
1522 IRIX has a
1523 .BR prctl ()
1524 system call (also introduced in Linux 2.1.44
1525 as irix_prctl on the MIPS architecture),
1526 with prototype
1527 .sp
1528 .BI "ptrdiff_t prctl(int " option ", int " arg2 ", int " arg3 );
1529 .sp
1530 and options to get the maximum number of processes per user,
1531 get the maximum number of processors the calling process can use,
1532 find out whether a specified process is currently blocked,
1533 get or set the maximum stack size, and so on.
1534 .SH SEE ALSO
1535 .BR signal (2),
1536 .BR core (5)