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