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