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