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