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