]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/prctl.2
prctl.2: Document Syscall User Dispatch
[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, 2015 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" and Copyright Guillem Jover <guillem@hadrons.org>
4 .\" and Copyright (C) 2010 Andi Kleen <andi@firstfloor.org>
5 .\" and Copyright (C) 2012 Cyrill Gorcunov <gorcunov@openvz.org>
6 .\" and Copyright (C) 2014 Dave Hansen / Intel
7 .\" and Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
8 .\" and Copyright (c) 2018 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
9 .\" and Copyright (c) 2020 Dave Martin <Dave.Martin@arm.com>
10 .\"
11 .\" %%%LICENSE_START(VERBATIM)
12 .\" Permission is granted to make and distribute verbatim copies of this
13 .\" manual provided the copyright notice and this permission notice are
14 .\" preserved on all copies.
15 .\"
16 .\" Permission is granted to copy and distribute modified versions of this
17 .\" manual under the conditions for verbatim copying, provided that the
18 .\" entire resulting derived work is distributed under the terms of a
19 .\" permission notice identical to this one.
20 .\"
21 .\" Since the Linux kernel and libraries are constantly changing, this
22 .\" manual page may be incorrect or out-of-date. The author(s) assume no
23 .\" responsibility for errors or omissions, or for damages resulting from
24 .\" the use of the information contained herein. The author(s) may not
25 .\" have taken the same level of care in the production of this manual,
26 .\" which is licensed free of charge, as they might when working
27 .\" professionally.
28 .\"
29 .\" Formatted or processed versions of this manual, if unaccompanied by
30 .\" the source, must acknowledge the copyright and authors of this work.
31 .\" %%%LICENSE_END
32 .\"
33 .\" Modified Thu Nov 11 04:19:42 MET 1999, aeb: added PR_GET_PDEATHSIG
34 .\" Modified 27 Jun 02, Michael Kerrisk
35 .\" Added PR_SET_DUMPABLE, PR_GET_DUMPABLE,
36 .\" PR_SET_KEEPCAPS, PR_GET_KEEPCAPS
37 .\" Modified 2006-08-30 Guillem Jover <guillem@hadrons.org>
38 .\" Updated Linux versions where the options where introduced.
39 .\" Added PR_SET_TIMING, PR_GET_TIMING, PR_SET_NAME, PR_GET_NAME,
40 .\" PR_SET_UNALIGN, PR_GET_UNALIGN, PR_SET_FPEMU, PR_GET_FPEMU,
41 .\" PR_SET_FPEXC, PR_GET_FPEXC
42 .\" 2008-04-29 Serge Hallyn, Document PR_CAPBSET_READ and PR_CAPBSET_DROP
43 .\" 2008-06-13 Erik Bosman, <ejbosman@cs.vu.nl>
44 .\" Document PR_GET_TSC and PR_SET_TSC.
45 .\" 2008-06-15 mtk, Document PR_SET_SECCOMP, PR_GET_SECCOMP
46 .\" 2009-10-03 Andi Kleen, document PR_MCE_KILL
47 .\" 2012-04 Cyrill Gorcunov, Document PR_SET_MM
48 .\" 2012-04-25 Michael Kerrisk, Document PR_TASK_PERF_EVENTS_DISABLE and
49 .\" PR_TASK_PERF_EVENTS_ENABLE
50 .\" 2012-09-20 Kees Cook, update PR_SET_SECCOMP for mode 2
51 .\" 2012-09-20 Kees Cook, document PR_SET_NO_NEW_PRIVS, PR_GET_NO_NEW_PRIVS
52 .\" 2012-10-25 Michael Kerrisk, Document PR_SET_TIMERSLACK and
53 .\" PR_GET_TIMERSLACK
54 .\" 2013-01-10 Kees Cook, document PR_SET_PTRACER
55 .\" 2012-02-04 Michael Kerrisk, document PR_{SET,GET}_CHILD_SUBREAPER
56 .\" 2014-11-10 Dave Hansen, document PR_MPX_{EN,DIS}ABLE_MANAGEMENT
57 .\"
58 .\"
59 .TH PRCTL 2 2020-08-13 "Linux" "Linux Programmer's Manual"
60 .SH NAME
61 prctl \- operations on a process or thread
62 .SH SYNOPSIS
63 .nf
64 .B #include <sys/prctl.h>
65 .PP
66 .BI "int prctl(int " option ", unsigned long " arg2 ", unsigned long " arg3 ,
67 .BI " unsigned long " arg4 ", unsigned long " arg5 );
68 .fi
69 .SH DESCRIPTION
70 .BR prctl ()
71 manipulates various aspects of the behavior
72 of the calling thread or process.
73 .PP
74 Note that careless use of some
75 .BR prctl ()
76 operations can confuse the user-space run-time environment,
77 so these operations should be used with care.
78 .PP
79 .BR prctl ()
80 is called with a first argument describing what to do
81 (with values defined in \fI<linux/prctl.h>\fP), and further
82 arguments with a significance depending on the first one.
83 The first argument can be:
84 .\"
85 .\" prctl PR_CAP_AMBIENT
86 .TP
87 .BR PR_CAP_AMBIENT " (since Linux 4.3)"
88 .\" commit 58319057b7847667f0c9585b9de0e8932b0fdb08
89 Reads or changes the ambient capability set of the calling thread,
90 according to the value of
91 .IR arg2 ,
92 which must be one of the following:
93 .RS
94 .\"
95 .TP
96 .B PR_CAP_AMBIENT_RAISE
97 The capability specified in
98 .I arg3
99 is added to the ambient set.
100 The specified capability must already be present in
101 both the permitted and the inheritable sets of the process.
102 This operation is not permitted if the
103 .B SECBIT_NO_CAP_AMBIENT_RAISE
104 securebit is set.
105 .TP
106 .B PR_CAP_AMBIENT_LOWER
107 The capability specified in
108 .I arg3
109 is removed from the ambient set.
110 .TP
111 .B PR_CAP_AMBIENT_IS_SET
112 The
113 .BR prctl ()
114 call returns 1 if the capability in
115 .I arg3
116 is in the ambient set and 0 if it is not.
117 .TP
118 .BR PR_CAP_AMBIENT_CLEAR_ALL
119 All capabilities will be removed from the ambient set.
120 This operation requires setting
121 .I arg3
122 to zero.
123 .RE
124 .IP
125 In all of the above operations,
126 .I arg4
127 and
128 .I arg5
129 must be specified as 0.
130 .IP
131 Higher-level interfaces layered on top of the above operations are
132 provided in the
133 .BR libcap (3)
134 library in the form of
135 .BR cap_get_ambient (3),
136 .BR cap_set_ambient (3),
137 and
138 .BR cap_reset_ambient (3).
139 .\" prctl PR_CAPBSET_READ
140 .TP
141 .BR PR_CAPBSET_READ " (since Linux 2.6.25)"
142 Return (as the function result) 1 if the capability specified in
143 .I arg2
144 is in the calling thread's capability bounding set,
145 or 0 if it is not.
146 (The capability constants are defined in
147 .IR <linux/capability.h> .)
148 The capability bounding set dictates
149 whether the process can receive the capability through a
150 file's permitted capability set on a subsequent call to
151 .BR execve (2).
152 .IP
153 If the capability specified in
154 .I arg2
155 is not valid, then the call fails with the error
156 .BR EINVAL .
157 .IP
158 A higher-level interface layered on top of this operation is provided in the
159 .BR libcap (3)
160 library in the form of
161 .BR cap_get_bound (3).
162 .\" prctl PR_CAPBSET_DROP
163 .TP
164 .BR PR_CAPBSET_DROP " (since Linux 2.6.25)"
165 If the calling thread has the
166 .B CAP_SETPCAP
167 capability within its user namespace, then drop the capability specified by
168 .I arg2
169 from the calling thread's capability bounding set.
170 Any children of the calling thread will inherit the newly
171 reduced bounding set.
172 .IP
173 The call fails with the error:
174 .B EPERM
175 if the calling thread does not have the
176 .BR CAP_SETPCAP ;
177 .BR EINVAL
178 if
179 .I arg2
180 does not represent a valid capability; or
181 .BR EINVAL
182 if file capabilities are not enabled in the kernel,
183 in which case bounding sets are not supported.
184 .IP
185 A higher-level interface layered on top of this operation is provided in the
186 .BR libcap (3)
187 library in the form of
188 .BR cap_drop_bound (3).
189 .\" prctl PR_SET_CHILD_SUBREAPER
190 .TP
191 .BR PR_SET_CHILD_SUBREAPER " (since Linux 3.4)"
192 .\" commit ebec18a6d3aa1e7d84aab16225e87fd25170ec2b
193 If
194 .I arg2
195 is nonzero,
196 set the "child subreaper" attribute of the calling process;
197 if
198 .I arg2
199 is zero, unset the attribute.
200 .IP
201 A subreaper fulfills the role of
202 .BR init (1)
203 for its descendant processes.
204 When a process becomes orphaned
205 (i.e., its immediate parent terminates),
206 then that process will be reparented to
207 the nearest still living ancestor subreaper.
208 Subsequently, calls to
209 .BR getppid (2)
210 in the orphaned process will now return the PID of the subreaper process,
211 and when the orphan terminates, it is the subreaper process that
212 will receive a
213 .BR SIGCHLD
214 signal and will be able to
215 .BR wait (2)
216 on the process to discover its termination status.
217 .IP
218 The setting of the "child subreaper" attribute
219 is not inherited by children created by
220 .BR fork (2)
221 and
222 .BR clone (2).
223 The setting is preserved across
224 .BR execve (2).
225 .IP
226 Establishing a subreaper process is useful in session management frameworks
227 where a hierarchical group of processes is managed by a subreaper process
228 that needs to be informed when one of the processes\(emfor example,
229 a double-forked daemon\(emterminates
230 (perhaps so that it can restart that process).
231 Some
232 .BR init (1)
233 frameworks (e.g.,
234 .BR systemd (1))
235 employ a subreaper process for similar reasons.
236 .\" prctl PR_GET_CHILD_SUBREAPER
237 .TP
238 .BR PR_GET_CHILD_SUBREAPER " (since Linux 3.4)"
239 Return the "child subreaper" setting of the caller,
240 in the location pointed to by
241 .IR "(int\ *) arg2" .
242 .\" prctl PR_SET_DUMPABLE
243 .TP
244 .BR PR_SET_DUMPABLE " (since Linux 2.3.20)"
245 Set the state of the "dumpable" attribute,
246 which determines whether core dumps are produced for the calling process
247 upon delivery of a signal whose default behavior is to produce a core dump.
248 .IP
249 In kernels up to and including 2.6.12,
250 .I arg2
251 must be either 0
252 .RB ( SUID_DUMP_DISABLE ,
253 process is not dumpable) or 1
254 .RB ( SUID_DUMP_USER ,
255 process is dumpable).
256 Between kernels 2.6.13 and 2.6.17,
257 .\" commit abf75a5033d4da7b8a7e92321d74021d1fcfb502
258 the value 2 was also permitted,
259 which caused any binary which normally would not be dumped
260 to be dumped readable by root only;
261 for security reasons, this feature has been removed.
262 .\" See http://marc.theaimsgroup.com/?l=linux-kernel&m=115270289030630&w=2
263 .\" Subject: Fix prctl privilege escalation (CVE-2006-2451)
264 .\" From: Marcel Holtmann <marcel () holtmann ! org>
265 .\" Date: 2006-07-12 11:12:00
266 (See also the description of
267 .I /proc/sys/fs/\:suid_dumpable
268 in
269 .BR proc (5).)
270 .IP
271 Normally, the "dumpable" attribute is set to 1.
272 However, it is reset to the current value contained in the file
273 .IR /proc/sys/fs/\:suid_dumpable
274 (which by default has the value 0),
275 in the following circumstances:
276 .\" See kernel/cred.c::commit_creds() (Linux 3.18 sources)
277 .RS
278 .IP * 3
279 The process's effective user or group ID is changed.
280 .IP *
281 The process's filesystem user or group ID is changed (see
282 .BR credentials (7)).
283 .IP *
284 The process executes
285 .RB ( execve (2))
286 a set-user-ID or set-group-ID program, resulting in a change
287 of either the effective user ID or the effective group ID.
288 .IP *
289 The process executes
290 .RB ( execve (2))
291 a program that has file capabilities (see
292 .BR capabilities (7)),
293 .\" See kernel/cred.c::commit_creds()
294 but only if the permitted capabilities
295 gained exceed those already permitted for the process.
296 .\" Also certain namespace operations;
297 .RE
298 .IP
299 Processes that are not dumpable can not be attached via
300 .BR ptrace (2)
301 .BR PTRACE_ATTACH ;
302 see
303 .BR ptrace (2)
304 for further details.
305 .IP
306 If a process is not dumpable,
307 the ownership of files in the process's
308 .IR /proc/[pid]
309 directory is affected as described in
310 .BR proc (5).
311 .\" prctl PR_GET_DUMPABLE
312 .TP
313 .BR PR_GET_DUMPABLE " (since Linux 2.3.20)"
314 Return (as the function result) the current state of the calling
315 process's dumpable attribute.
316 .\" Since Linux 2.6.13, the dumpable flag can have the value 2,
317 .\" but in 2.6.13 PR_GET_DUMPABLE simply returns 1 if the dumpable
318 .\" flags has a nonzero value. This was fixed in 2.6.14.
319 .\" prctl PR_SET_ENDIAN
320 .TP
321 .BR PR_SET_ENDIAN " (since Linux 2.6.18, PowerPC only)"
322 Set the endian-ness of the calling process to the value given
323 in \fIarg2\fP, which should be one of the following:
324 .\" Respectively 0, 1, 2
325 .BR PR_ENDIAN_BIG ,
326 .BR PR_ENDIAN_LITTLE ,
327 or
328 .B PR_ENDIAN_PPC_LITTLE
329 (PowerPC pseudo little endian).
330 .\" prctl PR_GET_ENDIAN
331 .TP
332 .BR PR_GET_ENDIAN " (since Linux 2.6.18, PowerPC only)"
333 Return the endian-ness of the calling process,
334 in the location pointed to by
335 .IR "(int\ *) arg2" .
336 .\" prctl PR_SET_FP_MODE
337 .TP
338 .BR PR_SET_FP_MODE " (since Linux 4.0, only on MIPS)"
339 .\" commit 9791554b45a2acc28247f66a5fd5bbc212a6b8c8
340 On the MIPS architecture,
341 user-space code can be built using an ABI which permits linking
342 with code that has more restrictive floating-point (FP) requirements.
343 For example, user-space code may be built to target the O32 FPXX ABI
344 and linked with code built for either one of the more restrictive
345 FP32 or FP64 ABIs.
346 When more restrictive code is linked in,
347 the overall requirement for the process is to use the more
348 restrictive floating-point mode.
349 .IP
350 Because the kernel has no means of knowing in advance
351 which mode the process should be executed in,
352 and because these restrictions can
353 change over the lifetime of the process, the
354 .B PR_SET_FP_MODE
355 operation is provided to allow control of the floating-point mode
356 from user space.
357 .IP
358 .\" https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking
359 The
360 .I (unsigned int) arg2
361 argument is a bit mask describing the floating-point mode used:
362 .RS
363 .TP
364 .BR PR_FP_MODE_FR
365 When this bit is
366 .I unset
367 (so called
368 .BR FR=0 " or " FR0
369 mode), the 32 floating-point registers are 32 bits wide,
370 and 64-bit registers are represented as a pair of registers
371 (even- and odd- numbered,
372 with the even-numbered register containing the lower 32 bits,
373 and the odd-numbered register containing the higher 32 bits).
374 .IP
375 When this bit is
376 .I set
377 (on supported hardware),
378 the 32 floating-point registers are 64 bits wide (so called
379 .BR FR=1 " or " FR1
380 mode).
381 Note that modern MIPS implementations (MIPS R6 and newer) support
382 .B FR=1
383 mode only.
384 .IP
385 Applications that use the O32 FP32 ABI can operate only when this bit is
386 .I unset
387 .RB ( FR=0 ;
388 or they can be used with FRE enabled, see below).
389 Applications that use the O32 FP64 ABI
390 (and the O32 FP64A ABI, which exists to
391 provide the ability to operate with existing FP32 code; see below)
392 can operate only when this bit is
393 .I set
394 .RB ( FR=1 ).
395 Applications that use the O32 FPXX ABI can operate with either
396 .BR FR=0
397 or
398 .BR FR=1 .
399 .TP
400 .BR PR_FP_MODE_FRE
401 Enable emulation of 32-bit floating-point mode.
402 When this mode is enabled,
403 it emulates 32-bit floating-point operations
404 by raising a reserved-instruction exception
405 on every instruction that uses 32-bit formats and
406 the kernel then handles the instruction in software.
407 (The problem lies in the discrepancy of handling odd-numbered registers
408 which are the high 32 bits of 64-bit registers with even numbers in
409 .B FR=0
410 mode and the lower 32-bit parts of odd-numbered 64-bit registers in
411 .B FR=1
412 mode.)
413 Enabling this bit is necessary when code with the O32 FP32 ABI should operate
414 with code with compatible the O32 FPXX or O32 FP64A ABIs (which require
415 .B FR=1
416 FPU mode) or when it is executed on newer hardware (MIPS R6 onwards)
417 which lacks
418 .B FR=0
419 mode support when a binary with the FP32 ABI is used.
420 .IP
421 Note that this mode makes sense only when the FPU is in 64-bit mode
422 .RB ( FR=1 ).
423 .IP
424 Note that the use of emulation inherently has a significant performance hit
425 and should be avoided if possible.
426 .RE
427 .IP
428 In the N32/N64 ABI, 64-bit floating-point mode is always used,
429 so FPU emulation is not required and the FPU always operates in
430 .B FR=1
431 mode.
432 .IP
433 This option is mainly intended for use by the dynamic linker
434 .RB ( ld.so (8)).
435 .IP
436 The arguments
437 .IR arg3 ,
438 .IR arg4 ,
439 and
440 .IR arg5
441 are ignored.
442 .\" prctl PR_GET_FP_MODE
443 .TP
444 .BR PR_GET_FP_MODE " (since Linux 4.0, only on MIPS)"
445 Return (as the function result)
446 the current floating-point mode (see the description of
447 .B PR_SET_FP_MODE
448 for details).
449 .IP
450 On success,
451 the call returns a bit mask which represents the current floating-point mode.
452 .IP
453 The arguments
454 .IR arg2 ,
455 .IR arg3 ,
456 .IR arg4 ,
457 and
458 .IR arg5
459 are ignored.
460 .\" prctl PR_SET_FPEMU
461 .TP
462 .BR PR_SET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)"
463 Set floating-point emulation control bits to \fIarg2\fP.
464 Pass
465 .B PR_FPEMU_NOPRINT
466 to silently emulate floating-point operation accesses, or
467 .B PR_FPEMU_SIGFPE
468 to not emulate floating-point operations and send
469 .B SIGFPE
470 instead.
471 .\" prctl PR_GET_FPEMU
472 .TP
473 .BR PR_GET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)"
474 Return floating-point emulation control bits,
475 in the location pointed to by
476 .IR "(int\ *) arg2" .
477 .\" prctl PR_SET_FPEXC
478 .TP
479 .BR PR_SET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)"
480 Set floating-point exception mode to \fIarg2\fP.
481 Pass \fBPR_FP_EXC_SW_ENABLE\fP to use FPEXC for FP exception enables,
482 \fBPR_FP_EXC_DIV\fP for floating-point divide by zero,
483 \fBPR_FP_EXC_OVF\fP for floating-point overflow,
484 \fBPR_FP_EXC_UND\fP for floating-point underflow,
485 \fBPR_FP_EXC_RES\fP for floating-point inexact result,
486 \fBPR_FP_EXC_INV\fP for floating-point invalid operation,
487 \fBPR_FP_EXC_DISABLED\fP for FP exceptions disabled,
488 \fBPR_FP_EXC_NONRECOV\fP for async nonrecoverable exception mode,
489 \fBPR_FP_EXC_ASYNC\fP for async recoverable exception mode,
490 \fBPR_FP_EXC_PRECISE\fP for precise exception mode.
491 .\" prctl PR_GET_FPEXC
492 .TP
493 .BR PR_GET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)"
494 Return floating-point exception mode,
495 in the location pointed to by
496 .IR "(int\ *) arg2" .
497 .\" prctl PR_SET_IO_FLUSHER
498 .TP
499 .BR PR_SET_IO_FLUSHER " (since Linux 5.6)"
500 If a user process is involved in the block layer or filesystem I/O path,
501 and can allocate memory while processing I/O requests it must set
502 \fIarg2\fP to 1.
503 This will put the process in the IO_FLUSHER state,
504 which allows it special treatment to make progress when allocating memory.
505 If \fIarg2\fP is 0, the process will clear the IO_FLUSHER state, and
506 the default behavior will be used.
507 .IP
508 The calling process must have the
509 .BR CAP_SYS_RESOURCE
510 capability.
511 .IP
512 .IR arg3 ,
513 .IR arg4 ,
514 and
515 .IR arg5
516 must be zero.
517 .IP
518 The IO_FLUSHER state is inherited by a child process created via
519 .BR fork (2)
520 and is preserved across
521 .BR execve (2).
522 .IP
523 Examples of IO_FLUSHER applications are FUSE daemons, SCSI device
524 emulation daemons, and daemons that perform error handling like multipath
525 path recovery applications.
526 .\" prctl PR_GET_IO_FLUSHER
527 .TP
528 .B PR_GET_IO_FLUSHER (Since Linux 5.6)
529 Return (as the function result) the IO_FLUSHER state of the caller.
530 A value of 1 indicates that the caller is in the IO_FLUSHER state;
531 0 indicates that the caller is not in the IO_FLUSHER state.
532 .IP
533 The calling process must have the
534 .BR CAP_SYS_RESOURCE
535 capability.
536 .IP
537 .IR arg2 ,
538 .IR arg3 ,
539 .IR arg4 ,
540 and
541 .IR arg5
542 must be zero.
543 .\" prctl PR_SET_KEEPCAPS
544 .TP
545 .BR PR_SET_KEEPCAPS " (since Linux 2.2.18)"
546 Set the state of the calling thread's "keep capabilities" flag.
547 The effect of this flag is described in
548 .BR capabilities (7).
549 .I arg2
550 must be either 0 (clear the flag)
551 or 1 (set the flag).
552 The "keep capabilities" value will be reset to 0 on subsequent calls to
553 .BR execve (2).
554 .\" prctl PR_GET_KEEPCAPS
555 .TP
556 .BR PR_GET_KEEPCAPS " (since Linux 2.2.18)"
557 Return (as the function result) the current state of the calling thread's
558 "keep capabilities" flag.
559 See
560 .BR capabilities (7)
561 for a description of this flag.
562 .\" prctl PR_MCE_KILL
563 .TP
564 .BR PR_MCE_KILL " (since Linux 2.6.32)"
565 Set the machine check memory corruption kill policy for the calling thread.
566 If
567 .I arg2
568 is
569 .BR PR_MCE_KILL_CLEAR ,
570 clear the thread memory corruption kill policy and use the system-wide default.
571 (The system-wide default is defined by
572 .IR /proc/sys/vm/memory_failure_early_kill ;
573 see
574 .BR proc (5).)
575 If
576 .I arg2
577 is
578 .BR PR_MCE_KILL_SET ,
579 use a thread-specific memory corruption kill policy.
580 In this case,
581 .I arg3
582 defines whether the policy is
583 .I early kill
584 .RB ( PR_MCE_KILL_EARLY ),
585 .I late kill
586 .RB ( PR_MCE_KILL_LATE ),
587 or the system-wide default
588 .RB ( PR_MCE_KILL_DEFAULT ).
589 Early kill means that the thread receives a
590 .B SIGBUS
591 signal as soon as hardware memory corruption is detected inside
592 its address space.
593 In late kill mode, the process is killed only when it accesses a corrupted page.
594 See
595 .BR sigaction (2)
596 for more information on the
597 .BR SIGBUS
598 signal.
599 The policy is inherited by children.
600 The remaining unused
601 .BR prctl ()
602 arguments must be zero for future compatibility.
603 .\" prctl PR_MCE_KILL_GET
604 .TP
605 .BR PR_MCE_KILL_GET " (since Linux 2.6.32)"
606 Return (as the function result)
607 the current per-process machine check kill policy.
608 All unused
609 .BR prctl ()
610 arguments must be zero.
611 .\" prctl PR_SET_MM
612 .TP
613 .BR PR_SET_MM " (since Linux 3.3)"
614 .\" commit 028ee4be34a09a6d48bdf30ab991ae933a7bc036
615 Modify certain kernel memory map descriptor fields
616 of the calling process.
617 Usually these fields are set by the kernel and dynamic loader (see
618 .BR ld.so (8)
619 for more information) and a regular application should not use this feature.
620 However, there are cases, such as self-modifying programs,
621 where a program might find it useful to change its own memory map.
622 .IP
623 The calling process must have the
624 .BR CAP_SYS_RESOURCE
625 capability.
626 The value in
627 .I arg2
628 is one of the options below, while
629 .I arg3
630 provides a new value for the option.
631 The
632 .I arg4
633 and
634 .I arg5
635 arguments must be zero if unused.
636 .IP
637 Before Linux 3.10,
638 .\" commit 52b3694157e3aa6df871e283115652ec6f2d31e0
639 this feature is available only if the kernel is built with the
640 .BR CONFIG_CHECKPOINT_RESTORE
641 option enabled.
642 .RS
643 .TP
644 .BR PR_SET_MM_START_CODE
645 Set the address above which the program text can run.
646 The corresponding memory area must be readable and executable,
647 but not writable or shareable (see
648 .BR mprotect (2)
649 and
650 .BR mmap (2)
651 for more information).
652 .TP
653 .BR PR_SET_MM_END_CODE
654 Set the address below which the program text can run.
655 The corresponding memory area must be readable and executable,
656 but not writable or shareable.
657 .TP
658 .BR PR_SET_MM_START_DATA
659 Set the address above which initialized and
660 uninitialized (bss) data are placed.
661 The corresponding memory area must be readable and writable,
662 but not executable or shareable.
663 .TP
664 .B PR_SET_MM_END_DATA
665 Set the address below which initialized and
666 uninitialized (bss) data are placed.
667 The corresponding memory area must be readable and writable,
668 but not executable or shareable.
669 .TP
670 .BR PR_SET_MM_START_STACK
671 Set the start address of the stack.
672 The corresponding memory area must be readable and writable.
673 .TP
674 .BR PR_SET_MM_START_BRK
675 Set the address above which the program heap can be expanded with
676 .BR brk (2)
677 call.
678 The address must be greater than the ending address of
679 the current program data segment.
680 In addition, the combined size of the resulting heap and
681 the size of the data segment can't exceed the
682 .BR RLIMIT_DATA
683 resource limit (see
684 .BR setrlimit (2)).
685 .TP
686 .BR PR_SET_MM_BRK
687 Set the current
688 .BR brk (2)
689 value.
690 The requirements for the address are the same as for the
691 .BR PR_SET_MM_START_BRK
692 option.
693 .PP
694 The following options are available since Linux 3.5.
695 .\" commit fe8c7f5cbf91124987106faa3bdf0c8b955c4cf7
696 .TP
697 .BR PR_SET_MM_ARG_START
698 Set the address above which the program command line is placed.
699 .TP
700 .BR PR_SET_MM_ARG_END
701 Set the address below which the program command line is placed.
702 .TP
703 .BR PR_SET_MM_ENV_START
704 Set the address above which the program environment is placed.
705 .TP
706 .BR PR_SET_MM_ENV_END
707 Set the address below which the program environment is placed.
708 .IP
709 The address passed with
710 .BR PR_SET_MM_ARG_START ,
711 .BR PR_SET_MM_ARG_END ,
712 .BR PR_SET_MM_ENV_START ,
713 and
714 .BR PR_SET_MM_ENV_END
715 should belong to a process stack area.
716 Thus, the corresponding memory area must be readable, writable, and
717 (depending on the kernel configuration) have the
718 .BR MAP_GROWSDOWN
719 attribute set (see
720 .BR mmap (2)).
721 .TP
722 .BR PR_SET_MM_AUXV
723 Set a new auxiliary vector.
724 The
725 .I arg3
726 argument should provide the address of the vector.
727 The
728 .I arg4
729 is the size of the vector.
730 .TP
731 .BR PR_SET_MM_EXE_FILE
732 .\" commit b32dfe377102ce668775f8b6b1461f7ad428f8b6
733 Supersede the
734 .IR /proc/pid/exe
735 symbolic link with a new one pointing to a new executable file
736 identified by the file descriptor provided in
737 .I arg3
738 argument.
739 The file descriptor should be obtained with a regular
740 .BR open (2)
741 call.
742 .IP
743 To change the symbolic link, one needs to unmap all existing
744 executable memory areas, including those created by the kernel itself
745 (for example the kernel usually creates at least one executable
746 memory area for the ELF
747 .IR \.text
748 section).
749 .IP
750 In Linux 4.9 and earlier, the
751 .\" commit 3fb4afd9a504c2386b8435028d43283216bf588e
752 .BR PR_SET_MM_EXE_FILE
753 operation can be performed only once in a process's lifetime;
754 attempting to perform the operation a second time results in the error
755 .BR EPERM .
756 This restriction was enforced for security reasons that were subsequently
757 deemed specious,
758 and the restriction was removed in Linux 4.10 because some
759 user-space applications needed to perform this operation more than once.
760 .PP
761 The following options are available since Linux 3.18.
762 .\" commit f606b77f1a9e362451aca8f81d8f36a3a112139e
763 .TP
764 .BR PR_SET_MM_MAP
765 Provides one-shot access to all the addresses by passing in a
766 .I struct prctl_mm_map
767 (as defined in \fI<linux/prctl.h>\fP).
768 The
769 .I arg4
770 argument should provide the size of the struct.
771 .IP
772 This feature is available only if the kernel is built with the
773 .BR CONFIG_CHECKPOINT_RESTORE
774 option enabled.
775 .TP
776 .BR PR_SET_MM_MAP_SIZE
777 Returns the size of the
778 .I struct prctl_mm_map
779 the kernel expects.
780 This allows user space to find a compatible struct.
781 The
782 .I arg4
783 argument should be a pointer to an unsigned int.
784 .IP
785 This feature is available only if the kernel is built with the
786 .BR CONFIG_CHECKPOINT_RESTORE
787 option enabled.
788 .RE
789 .\" prctl PR_MPX_ENABLE_MANAGEMENT
790 .TP
791 .BR PR_MPX_ENABLE_MANAGEMENT ", " PR_MPX_DISABLE_MANAGEMENT " (since Linux 3.19, removed in Linux 5.4; only on x86)"
792 .\" commit fe3d197f84319d3bce379a9c0dc17b1f48ad358c
793 .\" See also http://lwn.net/Articles/582712/
794 .\" See also https://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler
795 Enable or disable kernel management of Memory Protection eXtensions (MPX)
796 bounds tables.
797 The
798 .IR arg2 ,
799 .IR arg3 ,
800 .IR arg4 ,
801 and
802 .IR arg5
803 .\" commit e9d1b4f3c60997fe197bf0243cb4a41a44387a88
804 arguments must be zero.
805 .IP
806 MPX is a hardware-assisted mechanism for performing bounds checking on
807 pointers.
808 It consists of a set of registers storing bounds information
809 and a set of special instruction prefixes that tell the CPU on which
810 instructions it should do bounds enforcement.
811 There is a limited number of these registers and
812 when there are more pointers than registers,
813 their contents must be "spilled" into a set of tables.
814 These tables are called "bounds tables" and the MPX
815 .BR prctl ()
816 operations control
817 whether the kernel manages their allocation and freeing.
818 .IP
819 When management is enabled, the kernel will take over allocation
820 and freeing of the bounds tables.
821 It does this by trapping the #BR exceptions that result
822 at first use of missing bounds tables and
823 instead of delivering the exception to user space,
824 it allocates the table and populates the bounds directory
825 with the location of the new table.
826 For freeing, the kernel checks to see if bounds tables are
827 present for memory which is not allocated, and frees them if so.
828 .IP
829 Before enabling MPX management using
830 .BR PR_MPX_ENABLE_MANAGEMENT ,
831 the application must first have allocated a user-space buffer for
832 the bounds directory and placed the location of that directory in the
833 .I bndcfgu
834 register.
835 .IP
836 These calls fail if the CPU or kernel does not support MPX.
837 Kernel support for MPX is enabled via the
838 .BR CONFIG_X86_INTEL_MPX
839 configuration option.
840 You can check whether the CPU supports MPX by looking for the
841 .I mpx
842 CPUID bit, like with the following command:
843 .IP
844 .in +4n
845 .EX
846 cat /proc/cpuinfo | grep \(aq mpx \(aq
847 .EE
848 .in
849 .IP
850 A thread may not switch in or out of long (64-bit) mode while MPX is
851 enabled.
852 .IP
853 All threads in a process are affected by these calls.
854 .IP
855 The child of a
856 .BR fork (2)
857 inherits the state of MPX management.
858 During
859 .BR execve (2),
860 MPX management is reset to a state as if
861 .BR PR_MPX_DISABLE_MANAGEMENT
862 had been called.
863 .IP
864 For further information on Intel MPX, see the kernel source file
865 .IR Documentation/x86/intel_mpx.txt .
866 .IP
867 .\" commit f240652b6032b48ad7fa35c5e701cc4c8d697c0b
868 .\" See also https://lkml.kernel.org/r/20190705175321.DB42F0AD@viggo.jf.intel.com
869 Due to a lack of toolchain support,
870 .BR PR_MPX_ENABLE_MANAGEMENT " and " PR_MPX_DISABLE_MANAGEMENT
871 are not supported in Linux 5.4 and later.
872 .\" prctl PR_SET_NAME
873 .TP
874 .BR PR_SET_NAME " (since Linux 2.6.9)"
875 Set the name of the calling thread,
876 using the value in the location pointed to by
877 .IR "(char\ *) arg2" .
878 The name can be up to 16 bytes long,
879 .\" TASK_COMM_LEN in include/linux/sched.h
880 including the terminating null byte.
881 (If the length of the string, including the terminating null byte,
882 exceeds 16 bytes, the string is silently truncated.)
883 This is the same attribute that can be set via
884 .BR pthread_setname_np (3)
885 and retrieved using
886 .BR pthread_getname_np (3).
887 The attribute is likewise accessible via
888 .IR /proc/self/task/[tid]/comm
889 (see
890 .BR proc (5)),
891 where
892 .I [tid]
893 is the thread ID of the calling thread, as returned by
894 .BR gettid (2).
895 .\" prctl PR_GET_NAME
896 .TP
897 .BR PR_GET_NAME " (since Linux 2.6.11)"
898 Return the name of the calling thread,
899 in the buffer pointed to by
900 .IR "(char\ *) arg2" .
901 The buffer should allow space for up to 16 bytes;
902 the returned string will be null-terminated.
903 .\" prctl PR_SET_NO_NEW_PRIVS
904 .TP
905 .BR PR_SET_NO_NEW_PRIVS " (since Linux 3.5)"
906 Set the calling thread's
907 .I no_new_privs
908 attribute to the value in
909 .IR arg2 .
910 With
911 .I no_new_privs
912 set to 1,
913 .BR execve (2)
914 promises not to grant privileges to do anything
915 that could not have been done without the
916 .BR execve (2)
917 call (for example,
918 rendering the set-user-ID and set-group-ID mode bits,
919 and file capabilities non-functional).
920 Once set, the
921 .I no_new_privs
922 attribute cannot be unset.
923 The setting of this attribute is inherited by children created by
924 .BR fork (2)
925 and
926 .BR clone (2),
927 and preserved across
928 .BR execve (2).
929 .IP
930 Since Linux 4.10,
931 the value of a thread's
932 .I no_new_privs
933 attribute can be viewed via the
934 .I NoNewPrivs
935 field in the
936 .IR /proc/[pid]/status
937 file.
938 .IP
939 For more information, see the kernel source file
940 .IR Documentation/userspace\-api/no_new_privs.rst
941 .\" commit 40fde647ccb0ae8c11d256d271e24d385eed595b
942 (or
943 .IR Documentation/prctl/no_new_privs.txt
944 before Linux 4.13).
945 See also
946 .BR seccomp (2).
947 .\" prctl PR_GET_NO_NEW_PRIVS
948 .TP
949 .BR PR_GET_NO_NEW_PRIVS " (since Linux 3.5)"
950 Return (as the function result) the value of the
951 .I no_new_privs
952 attribute for the calling thread.
953 A value of 0 indicates the regular
954 .BR execve (2)
955 behavior.
956 A value of 1 indicates
957 .BR execve (2)
958 will operate in the privilege-restricting mode described above.
959 .\" prctl PR_PAC_RESET_KEYS
960 .\" commit ba830885656414101b2f8ca88786524d4bb5e8c1
961 .TP
962 .BR PR_PAC_RESET_KEYS " (since Linux 5.0, only on arm64)"
963 Securely reset the thread's pointer authentication keys
964 to fresh random values generated by the kernel.
965 .IP
966 The set of keys to be reset is specified by
967 .IR arg2 ,
968 which must be a logical OR of zero or more of the following:
969 .RS
970 .TP
971 .B PR_PAC_APIAKEY
972 instruction authentication key A
973 .TP
974 .B PR_PAC_APIBKEY
975 instruction authentication key B
976 .TP
977 .B PR_PAC_APDAKEY
978 data authentication key A
979 .TP
980 .B PR_PAC_APDBKEY
981 data authentication key B
982 .TP
983 .B PR_PAC_APGAKEY
984 generic authentication \(lqA\(rq key.
985 .IP
986 (Yes folks, there really is no generic B key.)
987 .RE
988 .IP
989 As a special case, if
990 .I arg2
991 is zero, then all the keys are reset.
992 Since new keys could be added in future,
993 this is the recommended way to completely wipe the existing keys
994 when establishing a clean execution context.
995 Note that there is no need to use
996 .BR PR_PAC_RESET_KEYS
997 in preparation for calling
998 .BR execve (2),
999 since
1000 .BR execve (2)
1001 resets all the pointer authentication keys.
1002 .IP
1003 The remaining arguments
1004 .IR arg3 ", " arg4 ", and " arg5
1005 must all be zero.
1006 .IP
1007 If the arguments are invalid,
1008 and in particular if
1009 .I arg2
1010 contains set bits that are unrecognized
1011 or that correspond to a key not available on this platform,
1012 then the call fails with error
1013 .BR EINVAL .
1014 .IP
1015 .B Warning:
1016 Because the compiler or run-time environment
1017 may be using some or all of the keys,
1018 a successful
1019 .B PR_PAC_RESET_KEYS
1020 may crash the calling process.
1021 The conditions for using it safely are complex and system-dependent.
1022 Don't use it unless you know what you are doing.
1023 .IP
1024 For more information, see the kernel source file
1025 .I Documentation/arm64/pointer\-authentication.rst
1026 .\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
1027 (or
1028 .I Documentation/arm64/pointer\-authentication.txt
1029 before Linux 5.3).
1030 .\" prctl PR_SET_PDEATHSIG
1031 .TP
1032 .BR PR_SET_PDEATHSIG " (since Linux 2.1.57)"
1033 Set the parent-death signal
1034 of the calling process to \fIarg2\fP (either a signal value
1035 in the range 1..\c
1036 .BR NSIG "\-1" ,
1037 or 0 to clear).
1038 This is the signal that the calling process will get when its
1039 parent dies.
1040 .IP
1041 .IR Warning :
1042 .\" https://bugzilla.kernel.org/show_bug.cgi?id=43300
1043 the "parent" in this case is considered to be the
1044 .I thread
1045 that created this process.
1046 In other words, the signal will be sent when that thread terminates
1047 (via, for example,
1048 .BR pthread_exit (3)),
1049 rather than after all of the threads in the parent process terminate.
1050 .IP
1051 The parent-death signal is sent upon subsequent termination of the parent
1052 thread and also upon termination of each subreaper process
1053 (see the description of
1054 .B PR_SET_CHILD_SUBREAPER
1055 above) to which the caller is subsequently reparented.
1056 If the parent thread and all ancestor subreapers have already terminated
1057 by the time of the
1058 .BR PR_SET_PDEATHSIG
1059 operation, then no parent-death signal is sent to the caller.
1060 .IP
1061 The parent-death signal is process-directed (see
1062 .BR signal (7))
1063 and, if the child installs a handler using the
1064 .BR sigaction (2)
1065 .B SA_SIGINFO
1066 flag, the
1067 .I si_pid
1068 field of the
1069 .I siginfo_t
1070 argument of the handler contains the PID of the terminating parent process.
1071 .IP
1072 The parent-death signal setting is cleared for the child of a
1073 .BR fork (2).
1074 It is also
1075 (since Linux 2.4.36 / 2.6.23)
1076 .\" commit d2d56c5f51028cb9f3d800882eb6f4cbd3f9099f
1077 cleared when executing a set-user-ID or set-group-ID binary,
1078 or a binary that has associated capabilities (see
1079 .BR capabilities (7));
1080 otherwise, this value is preserved across
1081 .BR execve (2).
1082 The parent-death signal setting is also cleared upon changes to
1083 any of the following thread credentials:
1084 .\" FIXME capability changes can also trigger this; see
1085 .\" kernel/cred.c::commit_creds in the Linux 5.6 source.
1086 effective user ID, effective group ID, filesystem user ID,
1087 or filesystem group ID.
1088 .\" prctl PR_GET_PDEATHSIG
1089 .TP
1090 .BR PR_GET_PDEATHSIG " (since Linux 2.3.15)"
1091 Return the current value of the parent process death signal,
1092 in the location pointed to by
1093 .IR "(int\ *) arg2" .
1094 .\" prctl PR_SET_PTRACER
1095 .TP
1096 .BR PR_SET_PTRACER " (since Linux 3.4)"
1097 .\" commit 2d514487faf188938a4ee4fb3464eeecfbdcf8eb
1098 .\" commit bf06189e4d14641c0148bea16e9dd24943862215
1099 This is meaningful only when the Yama LSM is enabled and in mode 1
1100 ("restricted ptrace", visible via
1101 .IR /proc/sys/kernel/yama/ptrace_scope ).
1102 When a "ptracer process ID" is passed in \fIarg2\fP,
1103 the caller is declaring that the ptracer process can
1104 .BR ptrace (2)
1105 the calling process as if it were a direct process ancestor.
1106 Each
1107 .B PR_SET_PTRACER
1108 operation replaces the previous "ptracer process ID".
1109 Employing
1110 .B PR_SET_PTRACER
1111 with
1112 .I arg2
1113 set to 0 clears the caller's "ptracer process ID".
1114 If
1115 .I arg2
1116 is
1117 .BR PR_SET_PTRACER_ANY ,
1118 the ptrace restrictions introduced by Yama are effectively disabled for the
1119 calling process.
1120 .IP
1121 For further information, see the kernel source file
1122 .IR Documentation/admin\-guide/LSM/Yama.rst
1123 .\" commit 90bb766440f2147486a2acc3e793d7b8348b0c22
1124 (or
1125 .IR Documentation/security/Yama.txt
1126 before Linux 4.13).
1127 .\" prctl PR_SET_SECCOMP
1128 .TP
1129 .BR PR_SET_SECCOMP " (since Linux 2.6.23)"
1130 .\" See http://thread.gmane.org/gmane.linux.kernel/542632
1131 .\" [PATCH 0 of 2] seccomp updates
1132 .\" andrea@cpushare.com
1133 Set the secure computing (seccomp) mode for the calling thread, to limit
1134 the available system calls.
1135 The more recent
1136 .BR seccomp (2)
1137 system call provides a superset of the functionality of
1138 .BR PR_SET_SECCOMP .
1139 .IP
1140 The seccomp mode is selected via
1141 .IR arg2 .
1142 (The seccomp constants are defined in
1143 .IR <linux/seccomp.h> .)
1144 .IP
1145 With
1146 .IR arg2
1147 set to
1148 .BR SECCOMP_MODE_STRICT ,
1149 the only system calls that the thread is permitted to make are
1150 .BR read (2),
1151 .BR write (2),
1152 .BR _exit (2)
1153 (but not
1154 .BR exit_group (2)),
1155 and
1156 .BR sigreturn (2).
1157 Other system calls result in the delivery of a
1158 .BR SIGKILL
1159 signal.
1160 Strict secure computing mode is useful for number-crunching applications
1161 that may need to execute untrusted byte code,
1162 perhaps obtained by reading from a pipe or socket.
1163 This operation is available only
1164 if the kernel is configured with
1165 .B CONFIG_SECCOMP
1166 enabled.
1167 .IP
1168 With
1169 .IR arg2
1170 set to
1171 .BR SECCOMP_MODE_FILTER " (since Linux 3.5),"
1172 the system calls allowed are defined by a pointer
1173 to a Berkeley Packet Filter passed in
1174 .IR arg3 .
1175 This argument is a pointer to
1176 .IR "struct sock_fprog" ;
1177 it can be designed to filter
1178 arbitrary system calls and system call arguments.
1179 This mode is available only if the kernel is configured with
1180 .B CONFIG_SECCOMP_FILTER
1181 enabled.
1182 .IP
1183 If
1184 .BR SECCOMP_MODE_FILTER
1185 filters permit
1186 .BR fork (2),
1187 then the seccomp mode is inherited by children created by
1188 .BR fork (2);
1189 if
1190 .BR execve (2)
1191 is permitted, then the seccomp mode is preserved across
1192 .BR execve (2).
1193 If the filters permit
1194 .BR prctl ()
1195 calls, then additional filters can be added;
1196 they are run in order until the first non-allow result is seen.
1197 .IP
1198 For further information, see the kernel source file
1199 .IR Documentation/userspace\-api/seccomp_filter.rst
1200 .\" commit c061f33f35be0ccc80f4b8e0aea5dfd2ed7e01a3
1201 (or
1202 .IR Documentation/prctl/seccomp_filter.txt
1203 before Linux 4.13).
1204 .\" prctl PR_GET_SECCOMP
1205 .TP
1206 .BR PR_GET_SECCOMP " (since Linux 2.6.23)"
1207 Return (as the function result)
1208 the secure computing mode of the calling thread.
1209 If the caller is not in secure computing mode, this operation returns 0;
1210 if the caller is in strict secure computing mode, then the
1211 .BR prctl ()
1212 call will cause a
1213 .B SIGKILL
1214 signal to be sent to the process.
1215 If the caller is in filter mode, and this system call is allowed by the
1216 seccomp filters, it returns 2; otherwise, the process is killed with a
1217 .BR SIGKILL
1218 signal.
1219 This operation is available only
1220 if the kernel is configured with
1221 .B CONFIG_SECCOMP
1222 enabled.
1223 .IP
1224 Since Linux 3.8, the
1225 .IR Seccomp
1226 field of the
1227 .IR /proc/[pid]/status
1228 file provides a method of obtaining the same information,
1229 without the risk that the process is killed; see
1230 .BR proc (5).
1231 .\" prctl PR_SET_SECUREBITS
1232 .TP
1233 .BR PR_SET_SECUREBITS " (since Linux 2.6.26)"
1234 Set the "securebits" flags of the calling thread to the value supplied in
1235 .IR arg2 .
1236 See
1237 .BR capabilities (7).
1238 .\" prctl PR_GET_SECUREBITS
1239 .TP
1240 .BR PR_GET_SECUREBITS " (since Linux 2.6.26)"
1241 Return (as the function result)
1242 the "securebits" flags of the calling thread.
1243 See
1244 .BR capabilities (7).
1245 .\" prctl PR_GET_SPECULATION_CTRL
1246 .TP
1247 .BR PR_GET_SPECULATION_CTRL " (since Linux 4.17)"
1248 Return (as the function result)
1249 the state of the speculation misfeature specified in
1250 .IR arg2 .
1251 Currently, the only permitted value for this argument is
1252 .BR PR_SPEC_STORE_BYPASS
1253 (otherwise the call fails with the error
1254 .BR ENODEV ).
1255 .IP
1256 The return value uses bits 0-3 with the following meaning:
1257 .RS
1258 .TP
1259 .BR PR_SPEC_PRCTL
1260 Mitigation can be controlled per thread by
1261 .BR PR_SET_SPECULATION_CTRL .
1262 .TP
1263 .BR PR_SPEC_ENABLE
1264 The speculation feature is enabled, mitigation is disabled.
1265 .TP
1266 .BR PR_SPEC_DISABLE
1267 The speculation feature is disabled, mitigation is enabled.
1268 .TP
1269 .BR PR_SPEC_FORCE_DISABLE
1270 Same as
1271 .B PR_SPEC_DISABLE
1272 but cannot be undone.
1273 .TP
1274 .BR PR_SPEC_DISABLE_NOEXEC " (since Linux 5.1)"
1275 Same as
1276 .BR PR_SPEC_DISABLE ,
1277 but the state will be cleared on
1278 .BR execve (2).
1279 .RE
1280 .IP
1281 If all bits are 0,
1282 then the CPU is not affected by the speculation misfeature.
1283 .IP
1284 If
1285 .B PR_SPEC_PRCTL
1286 is set, then per-thread control of the mitigation is available.
1287 If not set,
1288 .BR prctl ()
1289 for the speculation misfeature will fail.
1290 .IP
1291 The
1292 .IR arg3 ,
1293 .IR arg4 ,
1294 and
1295 .I arg5
1296 arguments must be specified as 0; otherwise the call fails with the error
1297 .BR EINVAL .
1298 .\" prctl PR_SET_SPECULATION_CTRL
1299 .TP
1300 .BR PR_SET_SPECULATION_CTRL " (since Linux 4.17)"
1301 .\" commit b617cfc858161140d69cc0b5cc211996b557a1c7
1302 .\" commit 356e4bfff2c5489e016fdb925adbf12a1e3950ee
1303 Sets the state of the speculation misfeature specified in
1304 .IR arg2 .
1305 The speculation-misfeature settings are per-thread attributes.
1306 .IP
1307 Currently,
1308 .I arg2
1309 must be one of:
1310 .RS
1311 .TP
1312 .B PR_SPEC_STORE_BYPASS
1313 Set the state of the speculative store bypass misfeature.
1314 .\" commit 9137bb27e60e554dab694eafa4cca241fa3a694f
1315 .TP
1316 .BR PR_SPEC_INDIRECT_BRANCH " (since Linux 4.20)"
1317 Set the state of the indirect branch speculation misfeature.
1318 .RE
1319 .IP
1320 If
1321 .I arg2
1322 does not have one of the above values,
1323 then the call fails with the error
1324 .BR ENODEV .
1325 .IP
1326 The
1327 .IR arg3
1328 argument is used to hand in the control value,
1329 which is one of the following:
1330 .RS
1331 .TP
1332 .BR PR_SPEC_ENABLE
1333 The speculation feature is enabled, mitigation is disabled.
1334 .TP
1335 .BR PR_SPEC_DISABLE
1336 The speculation feature is disabled, mitigation is enabled.
1337 .TP
1338 .BR PR_SPEC_FORCE_DISABLE
1339 Same as
1340 .BR PR_SPEC_DISABLE ,
1341 but cannot be undone.
1342 A subsequent
1343 .BR prctl (\c
1344 .IR arg2 ,
1345 .BR PR_SPEC_ENABLE )
1346 with the same value for
1347 .I arg2
1348 will fail with the error
1349 .BR EPERM .
1350 .\" commit 71368af9027f18fe5d1c6f372cfdff7e4bde8b48
1351 .TP
1352 .BR PR_SPEC_DISABLE_NOEXEC " (since Linux 5.1)"
1353 Same as
1354 .BR PR_SPEC_DISABLE ,
1355 but the state will be cleared on
1356 .BR execve (2).
1357 Currently only supported for
1358 .I arg2
1359 equal to
1360 .B PR_SPEC_STORE_BYPASS.
1361 .RE
1362 .IP
1363 Any unsupported value in
1364 .IR arg3
1365 will result in the call failing with the error
1366 .BR ERANGE .
1367 .IP
1368 The
1369 .I arg4
1370 and
1371 .I arg5
1372 arguments must be specified as 0; otherwise the call fails with the error
1373 .BR EINVAL .
1374 .IP
1375 The speculation feature can also be controlled by the
1376 .B spec_store_bypass_disable
1377 boot parameter.
1378 This parameter may enforce a read-only policy which will result in the
1379 .BR prctl ()
1380 call failing with the error
1381 .BR ENXIO .
1382 For further details, see the kernel source file
1383 .IR Documentation/admin\-guide/kernel\-parameters.txt .
1384 .\" prctl PR_SVE_SET_VL
1385 .\" commit 2d2123bc7c7f843aa9db87720de159a049839862
1386 .\" linux-5.6/Documentation/arm64/sve.rst
1387 .TP
1388 .BR PR_SVE_SET_VL " (since Linux 4.15, only on arm64)"
1389 Configure the thread's SVE vector length,
1390 as specified by
1391 .IR "(int) arg2" .
1392 Arguments
1393 .IR arg3 ", " arg4 ", and " arg5
1394 are ignored.
1395 .IP
1396 The bits of
1397 .I arg2
1398 corresponding to
1399 .B PR_SVE_VL_LEN_MASK
1400 must be set to the desired vector length in bytes.
1401 This is interpreted as an upper bound:
1402 the kernel will select the greatest available vector length
1403 that does not exceed the value specified.
1404 In particular, specifying
1405 .B SVE_VL_MAX
1406 (defined in
1407 .I <asm/sigcontext.h>)
1408 for the
1409 .B PR_SVE_VL_LEN_MASK
1410 bits requests the maximum supported vector length.
1411 .IP
1412 In addition, the other bits of
1413 .I arg2
1414 must be set to one of the following combinations of flags:
1415 .RS
1416 .TP
1417 .B 0
1418 Perform the change immediately.
1419 At the next
1420 .BR execve (2)
1421 in the thread,
1422 the vector length will be reset to the value configured in
1423 .IR /proc/sys/abi/sve_default_vector_length .
1424 .TP
1425 .B PR_SVE_VL_INHERIT
1426 Perform the change immediately.
1427 Subsequent
1428 .BR execve (2)
1429 calls will preserve the new vector length.
1430 .TP
1431 .B PR_SVE_SET_VL_ONEXEC
1432 Defer the change, so that it is performed at the next
1433 .BR execve (2)
1434 in the thread.
1435 Further
1436 .BR execve (2)
1437 calls will reset the vector length to the value configured in
1438 .IR /proc/sys/abi/sve_default_vector_length .
1439 .TP
1440 .B "PR_SVE_SET_VL_ONEXEC | PR_SVE_VL_INHERIT"
1441 Defer the change, so that it is performed at the next
1442 .BR execve (2)
1443 in the thread.
1444 Further
1445 .BR execve (2)
1446 calls will preserve the new vector length.
1447 .RE
1448 .IP
1449 In all cases,
1450 any previously pending deferred change is canceled.
1451 .IP
1452 The call fails with error
1453 .B EINVAL
1454 if SVE is not supported on the platform, if
1455 .I arg2
1456 is unrecognized or invalid, or the value in the bits of
1457 .I arg2
1458 corresponding to
1459 .B PR_SVE_VL_LEN_MASK
1460 is outside the range
1461 .BR SVE_VL_MIN .. SVE_VL_MAX
1462 or is not a multiple of 16.
1463 .IP
1464 On success,
1465 a nonnegative value is returned that describes the
1466 .I selected
1467 configuration.
1468 If
1469 .B PR_SVE_SET_VL_ONEXEC
1470 was included in
1471 .IR arg2 ,
1472 then the configuration described by the return value
1473 will take effect at the next
1474 .BR execve ().
1475 Otherwise, the configuration is already in effect when the
1476 .B PR_SVE_SET_VL
1477 call returns.
1478 In either case, the value is encoded in the same way as the return value of
1479 .BR PR_SVE_GET_VL .
1480 Note that there is no explicit flag in the return value
1481 corresponding to
1482 .BR PR_SVE_SET_VL_ONEXEC .
1483 .IP
1484 The configuration (including any pending deferred change)
1485 is inherited across
1486 .BR fork (2)
1487 and
1488 .BR clone (2).
1489 .IP
1490 For more information, see the kernel source file
1491 .I Documentation/arm64/sve.rst
1492 .\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
1493 (or
1494 .I Documentation/arm64/sve.txt
1495 before Linux 5.3).
1496 .IP
1497 .B Warning:
1498 Because the compiler or run-time environment
1499 may be using SVE, using this call without the
1500 .B PR_SVE_SET_VL_ONEXEC
1501 flag may crash the calling process.
1502 The conditions for using it safely are complex and system-dependent.
1503 Don't use it unless you really know what you are doing.
1504 .\" prctl PR_SVE_GET_VL
1505 .TP
1506 .BR PR_SVE_GET_VL " (since Linux 4.15, only on arm64)"
1507 Get the thread's current SVE vector length configuration.
1508 .IP
1509 Arguments
1510 .IR arg2 ", " arg3 ", " arg4 ", and " arg5
1511 are ignored.
1512 .IP
1513 Provided that the kernel and platform support SVE,
1514 this operation always succeeds,
1515 returning a nonnegative value that describes the
1516 .I current
1517 configuration.
1518 The bits corresponding to
1519 .B PR_SVE_VL_LEN_MASK
1520 contain the currently configured vector length in bytes.
1521 The bit corresponding to
1522 .B PR_SVE_VL_INHERIT
1523 indicates whether the vector length will be inherited
1524 across
1525 .BR execve (2).
1526 .IP
1527 Note that there is no way to determine whether there is
1528 a pending vector length change that has not yet taken effect.
1529 .IP
1530 For more information, see the kernel source file
1531 .I Documentation/arm64/sve.rst
1532 .\"commit b693d0b372afb39432e1c49ad7b3454855bc6bed
1533 (or
1534 .I Documentation/arm64/sve.txt
1535 before Linux 5.3).
1536 .TP
1537 .\" prctl PR_SET_SYSCALL_USER_DISPATCH
1538 .\" commit 1446e1df9eb183fdf81c3f0715402f1d7595d4
1539 .BR PR_SET_SYSCALL_USER_DISPATCH " (since Linux 5.11, x86 only)"
1540 .IP
1541 Configure the Syscall User Dispatch mechanism
1542 for the calling thread.
1543 This mechanism allows an application
1544 to selectively intercept system calls
1545 so that they can be handled within the application itself.
1546 Interception takes the form of a thread-directed
1547 .B SIGSYS
1548 signal that is delivered to the thread
1549 when it makes a system call.
1550 If intercepted,
1551 the system call is not executed by the kernel.
1552 .IP
1553 To enable this mechanism,
1554 .I arg2
1555 should be set to
1556 .BR PR_SYS_DISPATCH_ON .
1557 Once enabled, further system calls will be selectively intercepted,
1558 depending on a control variable provided by user space.
1559 In this case,
1560 .I arg3
1561 and
1562 .I arg4
1563 respectively identify the
1564 .I offset
1565 and
1566 .I length
1567 of a single contiguous memory region in the process address space
1568 from where system calls are always allowed to be executed,
1569 regardless of the control variable.
1570 (Typically, this area would include the area of memory
1571 containing the C library.)
1572 .IP
1573 .I arg5
1574 points to a char-sized variable
1575 that is a fast switch to allow/block system call execution
1576 without the overhead of doing another system call
1577 to re-configure Syscall User Dispatch.
1578 This control variable can either be set to
1579 .B SYSCALL_DISPATCH_FILTER_BLOCK
1580 to block system calls from executing
1581 or to
1582 .B SYSCALL_DISPATCH_FILTER_ALLOW
1583 to temporarily allow them to be executed.
1584 This value is checked by the kernel
1585 on every system call entry,
1586 and any unexpected value will raise
1587 an uncatchable
1588 .B SIGSYS
1589 at that time,
1590 killing the application.
1591 .IP
1592 When a system call is intercepted,
1593 the kernel sends a thread-directed
1594 .B SIGSYS
1595 signal to the triggering thread.
1596 Various fields will be set in the
1597 .I siginfo_t
1598 structure (see
1599 .BR sigaction (2))
1600 associated with the signal:
1601 .RS
1602 .IP * 3
1603 .I si_signo
1604 will contain
1605 .BR SIGSYS .
1606 .IP *
1607 .IR si_call_addr
1608 will show the address of the system call instruction.
1609 .IP *
1610 .IR si_syscall
1611 and
1612 .IR si_arch
1613 will indicate which system call was attempted.
1614 .IP *
1615 .I si_code
1616 will contain
1617 .BR SYS_USER_DISPATCH .
1618 .IP *
1619 .I si_errno
1620 will be set to 0.
1621 .RE
1622 .IP
1623 The program counter will be as though the system call happened
1624 (i.e., the program counter will not point to the system call instruction).
1625 .IP
1626 When the signal handler returns to the kernel,
1627 the system call completes immediately
1628 and returns to the calling thread,
1629 without actually being executed.
1630 If necessary
1631 (i.e., when emulating the system call on user space.),
1632 the signal handler should set the system call return value
1633 to a sane value,
1634 by modifying the register context stored in the
1635 .I ucontext
1636 argument of the signal handler.
1637 See
1638 .BR sigaction (2),
1639 .BR sigreturn (2),
1640 and
1641 .BR getcontext (3)
1642 for more information.
1643 .IP
1644 If
1645 .I arg2
1646 is set to
1647 .BR PR_SYS_DISPATCH_OFF ,
1648 Syscall User Dispatch is disabled for that thread.
1649 the remaining arguments must be set to 0.
1650 .IP
1651 The setting is not preserved across
1652 .BR fork (2),
1653 .BR clone (2),
1654 or
1655 .BR execve (2).
1656 .IP
1657 For more information,
1658 see the kernel source file
1659 .IR Documentation/admin-guide/syscall-user-dispatch.rst
1660 .\" prctl PR_SET_TAGGED_ADDR_CTRL
1661 .\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
1662 .TP
1663 .BR PR_SET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
1664 Controls support for passing tagged user-space addresses to the kernel
1665 (i.e., addresses where bits 56\(em63 are not all zero).
1666 .IP
1667 The level of support is selected by
1668 .IR "arg2" ,
1669 which can be one of the following:
1670 .RS
1671 .TP
1672 .B 0
1673 Addresses that are passed
1674 for the purpose of being dereferenced by the kernel
1675 must be untagged.
1676 .TP
1677 .B PR_TAGGED_ADDR_ENABLE
1678 Addresses that are passed
1679 for the purpose of being dereferenced by the kernel
1680 may be tagged, with the exceptions summarized below.
1681 .RE
1682 .IP
1683 The remaining arguments
1684 .IR arg3 ", " arg4 ", and " arg5
1685 must all be zero.
1686 .\" Enforcement added in
1687 .\" commit 3e91ec89f527b9870fe42dcbdb74fd389d123a95
1688 .IP
1689 On success, the mode specified in
1690 .I arg2
1691 is set for the calling thread and the return value is 0.
1692 If the arguments are invalid,
1693 the mode specified in
1694 .I arg2
1695 is unrecognized,
1696 or if this feature is unsupported by the kernel
1697 or disabled via
1698 .IR /proc/sys/abi/tagged_addr_disabled ,
1699 the call fails with the error
1700 .BR EINVAL .
1701 .IP
1702 In particular, if
1703 .BR prctl ( PR_SET_TAGGED_ADDR_CTRL ,
1704 0, 0, 0, 0)
1705 fails with
1706 .BR EINVAL ,
1707 then all addresses passed to the kernel must be untagged.
1708 .IP
1709 Irrespective of which mode is set,
1710 addresses passed to certain interfaces
1711 must always be untagged:
1712 .RS
1713 .IP \(bu 2
1714 .BR brk (2),
1715 .BR mmap (2),
1716 .BR shmat (2),
1717 .BR shmdt (2),
1718 and the
1719 .I new_address
1720 argument of
1721 .BR mremap (2).
1722 .IP
1723 (Prior to Linux 5.6 these accepted tagged addresses,
1724 but the behaviour may not be what you expect.
1725 Don't rely on it.)
1726 .IP \(bu
1727 \(oqpolymorphic\(cq interfaces
1728 that accept pointers to arbitrary types cast to a
1729 .I void *
1730 or other generic type, specifically
1731 .BR prctl (),
1732 .BR ioctl (2),
1733 and in general
1734 .BR setsockopt (2)
1735 (only certain specific
1736 .BR setsockopt (2)
1737 options allow tagged addresses).
1738 .RE
1739 .IP
1740 This list of exclusions may shrink
1741 when moving from one kernel version to a later kernel version.
1742 While the kernel may make some guarantees
1743 for backwards compatibility reasons,
1744 for the purposes of new software
1745 the effect of passing tagged addresses to these interfaces
1746 is unspecified.
1747 .IP
1748 The mode set by this call is inherited across
1749 .BR fork (2)
1750 and
1751 .BR clone (2).
1752 The mode is reset by
1753 .BR execve (2)
1754 to 0
1755 (i.e., tagged addresses not permitted in the user/kernel ABI).
1756 .IP
1757 For more information, see the kernel source file
1758 .IR Documentation/arm64/tagged\-address\-abi.rst .
1759 .IP
1760 .B Warning:
1761 This call is primarily intended for use by the run-time environment.
1762 A successful
1763 .B PR_SET_TAGGED_ADDR_CTRL
1764 call elsewhere may crash the calling process.
1765 The conditions for using it safely are complex and system-dependent.
1766 Don't use it unless you know what you are doing.
1767 .\" prctl PR_GET_TAGGED_ADDR_CTRL
1768 .\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d
1769 .TP
1770 .BR PR_GET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)"
1771 Returns the current tagged address mode
1772 for the calling thread.
1773 .IP
1774 Arguments
1775 .IR arg2 ", " arg3 ", " arg4 ", and " arg5
1776 must all be zero.
1777 .IP
1778 If the arguments are invalid
1779 or this feature is disabled or unsupported by the kernel,
1780 the call fails with
1781 .BR EINVAL .
1782 In particular, if
1783 .BR prctl ( PR_GET_TAGGED_ADDR_CTRL ,
1784 0, 0, 0, 0)
1785 fails with
1786 .BR EINVAL ,
1787 then this feature is definitely either unsupported,
1788 or disabled via
1789 .IR /proc/sys/abi/tagged_addr_disabled .
1790 In this case,
1791 all addresses passed to the kernel must be untagged.
1792 .IP
1793 Otherwise, the call returns a nonnegative value
1794 describing the current tagged address mode,
1795 encoded in the same way as the
1796 .I arg2
1797 argument of
1798 .BR PR_SET_TAGGED_ADDR_CTRL .
1799 .IP
1800 For more information, see the kernel source file
1801 .IR Documentation/arm64/tagged\-address\-abi.rst .
1802 .\"
1803 .\" prctl PR_TASK_PERF_EVENTS_DISABLE
1804 .TP
1805 .BR PR_TASK_PERF_EVENTS_DISABLE " (since Linux 2.6.31)"
1806 Disable all performance counters attached to the calling process,
1807 regardless of whether the counters were created by
1808 this process or another process.
1809 Performance counters created by the calling process for other
1810 processes are unaffected.
1811 For more information on performance counters, see the Linux kernel source file
1812 .IR tools/perf/design.txt .
1813 .IP
1814 Originally called
1815 .BR PR_TASK_PERF_COUNTERS_DISABLE ;
1816 .\" commit 1d1c7ddbfab358445a542715551301b7fc363e28
1817 renamed (retaining the same numerical value)
1818 in Linux 2.6.32.
1819 .\"
1820 .\" prctl PR_TASK_PERF_EVENTS_ENABLE
1821 .TP
1822 .BR PR_TASK_PERF_EVENTS_ENABLE " (since Linux 2.6.31)"
1823 The converse of
1824 .BR PR_TASK_PERF_EVENTS_DISABLE ;
1825 enable performance counters attached to the calling process.
1826 .IP
1827 Originally called
1828 .BR PR_TASK_PERF_COUNTERS_ENABLE ;
1829 .\" commit 1d1c7ddbfab358445a542715551301b7fc363e28
1830 renamed
1831 .\" commit cdd6c482c9ff9c55475ee7392ec8f672eddb7be6
1832 in Linux 2.6.32.
1833 .\"
1834 .\" prctl PR_SET_THP_DISABLE
1835 .TP
1836 .BR PR_SET_THP_DISABLE " (since Linux 3.15)"
1837 .\" commit a0715cc22601e8830ace98366c0c2bd8da52af52
1838 Set the state of the "THP disable" flag for the calling thread.
1839 If
1840 .I arg2
1841 has a nonzero value, the flag is set, otherwise it is cleared.
1842 Setting this flag provides a method
1843 for disabling transparent huge pages
1844 for jobs where the code cannot be modified, and using a malloc hook with
1845 .BR madvise (2)
1846 is not an option (i.e., statically allocated data).
1847 The setting of the "THP disable" flag is inherited by a child created via
1848 .BR fork (2)
1849 and is preserved across
1850 .BR execve (2).
1851 .\" prctl PR_GET_THP_DISABLE
1852 .TP
1853 .BR PR_GET_THP_DISABLE " (since Linux 3.15)"
1854 Return (as the function result) the current setting of the "THP disable"
1855 flag for the calling thread:
1856 either 1, if the flag is set, or 0, if it is not.
1857 .\" prctl PR_GET_TID_ADDRESS
1858 .TP
1859 .BR PR_GET_TID_ADDRESS " (since Linux 3.5)"
1860 .\" commit 300f786b2683f8bb1ec0afb6e1851183a479c86d
1861 Return the
1862 .I clear_child_tid
1863 address set by
1864 .BR set_tid_address (2)
1865 and the
1866 .BR clone (2)
1867 .B CLONE_CHILD_CLEARTID
1868 flag, in the location pointed to by
1869 .IR "(int\ **)\ arg2" .
1870 This feature is available only if the kernel is built with the
1871 .BR CONFIG_CHECKPOINT_RESTORE
1872 option enabled.
1873 Note that since the
1874 .BR prctl ()
1875 system call does not have a compat implementation for
1876 the AMD64 x32 and MIPS n32 ABIs,
1877 and the kernel writes out a pointer using the kernel's pointer size,
1878 this operation expects a user-space buffer of 8 (not 4) bytes on these ABIs.
1879 .\" prctl PR_SET_TIMERSLACK
1880 .TP
1881 .BR PR_SET_TIMERSLACK " (since Linux 2.6.28)"
1882 .\" See https://lwn.net/Articles/369549/
1883 .\" commit 6976675d94042fbd446231d1bd8b7de71a980ada
1884 Each thread has two associated timer slack values:
1885 a "default" value, and a "current" value.
1886 This operation sets the "current" timer slack value for the calling thread.
1887 .I arg2
1888 is an unsigned long value, then maximum "current" value is ULONG_MAX and
1889 the minimum "current" value is 1.
1890 If the nanosecond value supplied in
1891 .IR arg2
1892 is greater than zero, then the "current" value is set to this value.
1893 If
1894 .I arg2
1895 is equal to zero,
1896 the "current" timer slack is reset to the
1897 thread's "default" timer slack value.
1898 .IP
1899 The "current" timer slack is used by the kernel to group timer expirations
1900 for the calling thread that are close to one another;
1901 as a consequence, timer expirations for the thread may be
1902 up to the specified number of nanoseconds late (but will never expire early).
1903 Grouping timer expirations can help reduce system power consumption
1904 by minimizing CPU wake-ups.
1905 .IP
1906 The timer expirations affected by timer slack are those set by
1907 .BR select (2),
1908 .BR pselect (2),
1909 .BR poll (2),
1910 .BR ppoll (2),
1911 .BR epoll_wait (2),
1912 .BR epoll_pwait (2),
1913 .BR clock_nanosleep (2),
1914 .BR nanosleep (2),
1915 and
1916 .BR futex (2)
1917 (and thus the library functions implemented via futexes, including
1918 .\" List obtained by grepping for futex usage in glibc source
1919 .BR pthread_cond_timedwait (3),
1920 .BR pthread_mutex_timedlock (3),
1921 .BR pthread_rwlock_timedrdlock (3),
1922 .BR pthread_rwlock_timedwrlock (3),
1923 and
1924 .BR sem_timedwait (3)).
1925 .IP
1926 Timer slack is not applied to threads that are scheduled under
1927 a real-time scheduling policy (see
1928 .BR sched_setscheduler (2)).
1929 .IP
1930 When a new thread is created,
1931 the two timer slack values are made the same as the "current" value
1932 of the creating thread.
1933 Thereafter, a thread can adjust its "current" timer slack value via
1934 .BR PR_SET_TIMERSLACK .
1935 The "default" value can't be changed.
1936 The timer slack values of
1937 .IR init
1938 (PID 1), the ancestor of all processes,
1939 are 50,000 nanoseconds (50 microseconds).
1940 The timer slack value is inherited by a child created via
1941 .BR fork (2),
1942 and is preserved across
1943 .BR execve (2).
1944 .IP
1945 Since Linux 4.6, the "current" timer slack value of any process
1946 can be examined and changed via the file
1947 .IR /proc/[pid]/timerslack_ns .
1948 See
1949 .BR proc (5).
1950 .\" prctl PR_GET_TIMERSLACK
1951 .TP
1952 .BR PR_GET_TIMERSLACK " (since Linux 2.6.28)"
1953 Return (as the function result)
1954 the "current" timer slack value of the calling thread.
1955 .\" prctl PR_SET_TIMING
1956 .TP
1957 .BR PR_SET_TIMING " (since Linux 2.6.0)"
1958 .\" Precisely: Linux 2.6.0-test4
1959 Set whether to use (normal, traditional) statistical process timing or
1960 accurate timestamp-based process timing, by passing
1961 .B PR_TIMING_STATISTICAL
1962 .\" 0
1963 or
1964 .B PR_TIMING_TIMESTAMP
1965 .\" 1
1966 to \fIarg2\fP.
1967 .B PR_TIMING_TIMESTAMP
1968 is not currently implemented
1969 (attempting to set this mode will yield the error
1970 .BR EINVAL ).
1971 .\" PR_TIMING_TIMESTAMP doesn't do anything in 2.6.26-rc8,
1972 .\" and looking at the patch history, it appears
1973 .\" that it never did anything.
1974 .\" prctl PR_GET_TIMING
1975 .TP
1976 .BR PR_GET_TIMING " (since Linux 2.6.0)"
1977 .\" Precisely: Linux 2.6.0-test4
1978 Return (as the function result) which process timing method is currently
1979 in use.
1980 .\" prctl PR_SET_TSC
1981 .TP
1982 .BR PR_SET_TSC " (since Linux 2.6.26, x86 only)"
1983 Set the state of the flag determining whether the timestamp counter
1984 can be read by the process.
1985 Pass
1986 .B PR_TSC_ENABLE
1987 to
1988 .I arg2
1989 to allow it to be read, or
1990 .B PR_TSC_SIGSEGV
1991 to generate a
1992 .B SIGSEGV
1993 when the process tries to read the timestamp counter.
1994 .\" prctl PR_GET_TSC
1995 .TP
1996 .BR PR_GET_TSC " (since Linux 2.6.26, x86 only)"
1997 Return the state of the flag determining whether the timestamp counter
1998 can be read,
1999 in the location pointed to by
2000 .IR "(int\ *) arg2" .
2001 .\" prctl PR_SET_UNALIGN
2002 .TP
2003 .B PR_SET_UNALIGN
2004 (Only on: ia64, since Linux 2.3.48; parisc, since Linux 2.6.15;
2005 PowerPC, since Linux 2.6.18; Alpha, since Linux 2.6.22;
2006 .\" sh: 94ea5e449ae834af058ef005d16a8ad44fcf13d6
2007 .\" tile: 2f9ac29eec71a696cb0dcc5fb82c0f8d4dac28c9
2008 sh, since Linux 2.6.34; tile, since Linux 3.12)
2009 Set unaligned access control bits to \fIarg2\fP.
2010 Pass
2011 \fBPR_UNALIGN_NOPRINT\fP to silently fix up unaligned user accesses,
2012 or \fBPR_UNALIGN_SIGBUS\fP to generate
2013 .B SIGBUS
2014 on unaligned user access.
2015 Alpha also supports an additional flag with the value
2016 of 4 and no corresponding named constant,
2017 which instructs kernel to not fix up
2018 unaligned accesses (it is analogous to providing the
2019 .BR UAC_NOFIX
2020 flag in
2021 .BR SSI_NVPAIRS
2022 operation of the
2023 .BR setsysinfo ()
2024 system call on Tru64).
2025 .\" prctl PR_GET_UNALIGN
2026 .TP
2027 .B PR_GET_UNALIGN
2028 (See
2029 .B PR_SET_UNALIGN
2030 for information on versions and architectures.)
2031 Return unaligned access control bits, in the location pointed to by
2032 .IR "(unsigned int\ *) arg2" .
2033 .SH RETURN VALUE
2034 On success,
2035 .BR PR_CAP_AMBIENT + PR_CAP_AMBIENT_IS_SET ,
2036 .BR PR_CAPBSET_READ ,
2037 .BR PR_GET_DUMPABLE ,
2038 .BR PR_GET_FP_MODE ,
2039 .BR PR_GET_IO_FLUSHER ,
2040 .BR PR_GET_KEEPCAPS ,
2041 .BR PR_MCE_KILL_GET ,
2042 .BR PR_GET_NO_NEW_PRIVS ,
2043 .BR PR_GET_SECUREBITS ,
2044 .BR PR_GET_SPECULATION_CTRL ,
2045 .BR PR_SVE_GET_VL ,
2046 .BR PR_SVE_SET_VL ,
2047 .BR PR_GET_TAGGED_ADDR_CTRL ,
2048 .BR PR_GET_THP_DISABLE ,
2049 .BR PR_GET_TIMING ,
2050 .BR PR_GET_TIMERSLACK ,
2051 and (if it returns)
2052 .BR PR_GET_SECCOMP
2053 return the nonnegative values described above.
2054 All other
2055 .I option
2056 values return 0 on success.
2057 On error, \-1 is returned, and
2058 .I errno
2059 is set to indicate the error.
2060 .SH ERRORS
2061 .TP
2062 .B EACCES
2063 .I option
2064 is
2065 .BR PR_SET_SECCOMP
2066 and
2067 .I arg2
2068 is
2069 .BR SECCOMP_MODE_FILTER ,
2070 but the process does not have the
2071 .BR CAP_SYS_ADMIN
2072 capability or has not set the
2073 .IR no_new_privs
2074 attribute (see the discussion of
2075 .BR PR_SET_NO_NEW_PRIVS
2076 above).
2077 .TP
2078 .B EACCES
2079 .I option
2080 is
2081 .BR PR_SET_MM ,
2082 and
2083 .I arg3
2084 is
2085 .BR PR_SET_MM_EXE_FILE ,
2086 the file is not executable.
2087 .TP
2088 .B EBADF
2089 .I option
2090 is
2091 .BR PR_SET_MM ,
2092 .I arg3
2093 is
2094 .BR PR_SET_MM_EXE_FILE ,
2095 and the file descriptor passed in
2096 .I arg4
2097 is not valid.
2098 .TP
2099 .B EBUSY
2100 .I option
2101 is
2102 .BR PR_SET_MM ,
2103 .I arg3
2104 is
2105 .BR PR_SET_MM_EXE_FILE ,
2106 and this the second attempt to change the
2107 .I /proc/pid/exe
2108 symbolic link, which is prohibited.
2109 .TP
2110 .B EFAULT
2111 .I arg2
2112 is an invalid address.
2113 .TP
2114 .B EFAULT
2115 .I option
2116 is
2117 .BR PR_SET_SECCOMP ,
2118 .I arg2
2119 is
2120 .BR SECCOMP_MODE_FILTER ,
2121 the system was built with
2122 .BR CONFIG_SECCOMP_FILTER ,
2123 and
2124 .I arg3
2125 is an invalid address.
2126 .TP
2127 .B EFAULT
2128 .I option
2129 is
2130 .B PR_SET_SYSCALL_USER_DISPATCH
2131 and
2132 .I arg5
2133 has an invalid address.
2134 .TP
2135 .B EINVAL
2136 The value of
2137 .I option
2138 is not recognized,
2139 or not supported on this system.
2140 .TP
2141 .B EINVAL
2142 .I option
2143 is
2144 .BR PR_MCE_KILL
2145 or
2146 .BR PR_MCE_KILL_GET
2147 or
2148 .BR PR_SET_MM ,
2149 and unused
2150 .BR prctl ()
2151 arguments were not specified as zero.
2152 .TP
2153 .B EINVAL
2154 .I arg2
2155 is not valid value for this
2156 .IR option .
2157 .TP
2158 .B EINVAL
2159 .I option
2160 is
2161 .BR PR_SET_SECCOMP
2162 or
2163 .BR PR_GET_SECCOMP ,
2164 and the kernel was not configured with
2165 .BR CONFIG_SECCOMP .
2166 .TP
2167 .B EINVAL
2168 .I option
2169 is
2170 .BR PR_SET_SECCOMP ,
2171 .I arg2
2172 is
2173 .BR SECCOMP_MODE_FILTER ,
2174 and the kernel was not configured with
2175 .BR CONFIG_SECCOMP_FILTER .
2176 .TP
2177 .B EINVAL
2178 .I option
2179 is
2180 .BR PR_SET_MM ,
2181 and one of the following is true
2182 .RS
2183 .IP * 3
2184 .I arg4
2185 or
2186 .I arg5
2187 is nonzero;
2188 .IP *
2189 .I arg3
2190 is greater than
2191 .B TASK_SIZE
2192 (the limit on the size of the user address space for this architecture);
2193 .IP *
2194 .I arg2
2195 is
2196 .BR PR_SET_MM_START_CODE ,
2197 .BR PR_SET_MM_END_CODE ,
2198 .BR PR_SET_MM_START_DATA ,
2199 .BR PR_SET_MM_END_DATA ,
2200 or
2201 .BR PR_SET_MM_START_STACK ,
2202 and the permissions of the corresponding memory area are not as required;
2203 .IP *
2204 .I arg2
2205 is
2206 .BR PR_SET_MM_START_BRK
2207 or
2208 .BR PR_SET_MM_BRK ,
2209 and
2210 .I arg3
2211 is less than or equal to the end of the data segment
2212 or specifies a value that would cause the
2213 .B RLIMIT_DATA
2214 resource limit to be exceeded.
2215 .RE
2216 .TP
2217 .B EINVAL
2218 .I option
2219 is
2220 .BR PR_SET_PTRACER
2221 and
2222 .I arg2
2223 is not 0,
2224 .BR PR_SET_PTRACER_ANY ,
2225 or the PID of an existing process.
2226 .TP
2227 .B EINVAL
2228 .I option
2229 is
2230 .B PR_SET_PDEATHSIG
2231 and
2232 .I arg2
2233 is not a valid signal number.
2234 .TP
2235 .B EINVAL
2236 .I option
2237 is
2238 .BR PR_SET_DUMPABLE
2239 and
2240 .I arg2
2241 is neither
2242 .B SUID_DUMP_DISABLE
2243 nor
2244 .BR SUID_DUMP_USER .
2245 .TP
2246 .B EINVAL
2247 .I option
2248 is
2249 .BR PR_SET_TIMING
2250 and
2251 .I arg2
2252 is not
2253 .BR PR_TIMING_STATISTICAL .
2254 .TP
2255 .B EINVAL
2256 .I option
2257 is
2258 .BR PR_SET_NO_NEW_PRIVS
2259 and
2260 .I arg2
2261 is not equal to 1
2262 or
2263 .IR arg3 ,
2264 .IR arg4 ,
2265 or
2266 .IR arg5
2267 is nonzero.
2268 .TP
2269 .B EINVAL
2270 .I option
2271 is
2272 .BR PR_GET_NO_NEW_PRIVS
2273 and
2274 .IR arg2 ,
2275 .IR arg3 ,
2276 .IR arg4 ,
2277 or
2278 .IR arg5
2279 is nonzero.
2280 .TP
2281 .B EINVAL
2282 .I option
2283 is
2284 .BR PR_SET_THP_DISABLE
2285 and
2286 .IR arg3 ,
2287 .IR arg4 ,
2288 or
2289 .IR arg5
2290 is nonzero.
2291 .TP
2292 .B EINVAL
2293 .I option
2294 is
2295 .BR PR_GET_THP_DISABLE
2296 and
2297 .IR arg2 ,
2298 .IR arg3 ,
2299 .IR arg4 ,
2300 or
2301 .IR arg5
2302 is nonzero.
2303 .TP
2304 .B EINVAL
2305 .I option
2306 is
2307 .B PR_CAP_AMBIENT
2308 and an unused argument
2309 .RI ( arg4 ,
2310 .IR arg5 ,
2311 or,
2312 in the case of
2313 .BR PR_CAP_AMBIENT_CLEAR_ALL ,
2314 .IR arg3 )
2315 is nonzero; or
2316 .IR arg2
2317 has an invalid value;
2318 or
2319 .IR arg2
2320 is
2321 .BR PR_CAP_AMBIENT_LOWER ,
2322 .BR PR_CAP_AMBIENT_RAISE ,
2323 or
2324 .BR PR_CAP_AMBIENT_IS_SET
2325 and
2326 .IR arg3
2327 does not specify a valid capability.
2328 .TP
2329 .B EINVAL
2330 .I option
2331 was
2332 .BR PR_GET_SPECULATION_CTRL
2333 or
2334 .BR PR_SET_SPECULATION_CTRL
2335 and unused arguments to
2336 .BR prctl ()
2337 are not 0.
2338 .B EINVAL
2339 .I option
2340 is
2341 .B PR_PAC_RESET_KEYS
2342 and the arguments are invalid or unsupported.
2343 See the description of
2344 .B PR_PAC_RESET_KEYS
2345 above for details.
2346 .TP
2347 .B EINVAL
2348 .I option
2349 is
2350 .B PR_SVE_SET_VL
2351 and the arguments are invalid or unsupported,
2352 or SVE is not available on this platform.
2353 See the description of
2354 .B PR_SVE_SET_VL
2355 above for details.
2356 .TP
2357 .B EINVAL
2358 .I option
2359 is
2360 .B PR_SVE_GET_VL
2361 and SVE is not available on this platform.
2362 .TP
2363 .B EINVAL
2364 .I option
2365 is
2366 .B PR_SET_SYSCALL_USER_DISPATCH
2367 and one of the following is true:
2368 .RS
2369 .IP * 3
2370 .I arg2
2371 is
2372 .B PR_SYS_DISPATCH_OFF
2373 and the remaining arguments are not 0;
2374 .IP * 3
2375 .I arg2
2376 is
2377 .B PR_SYS_DISPATCH_ON
2378 and the memory range specified is outside the
2379 address space of the process.
2380 .IP * 3
2381 .I arg2
2382 is invalid.
2383 .RE
2384 .TP
2385 .B EINVAL
2386 .I option
2387 is
2388 .BR PR_SET_TAGGED_ADDR_CTRL
2389 and the arguments are invalid or unsupported.
2390 See the description of
2391 .B PR_SET_TAGGED_ADDR_CTRL
2392 above for details.
2393 .TP
2394 .B EINVAL
2395 .I option
2396 is
2397 .BR PR_GET_TAGGED_ADDR_CTRL
2398 and the arguments are invalid or unsupported.
2399 See the description of
2400 .B PR_GET_TAGGED_ADDR_CTRL
2401 above for details.
2402 .TP
2403 .B ENODEV
2404 .I option
2405 was
2406 .BR PR_SET_SPECULATION_CTRL
2407 the kernel or CPU does not support the requested speculation misfeature.
2408 .TP
2409 .B ENXIO
2410 .I option
2411 was
2412 .BR PR_MPX_ENABLE_MANAGEMENT
2413 or
2414 .BR PR_MPX_DISABLE_MANAGEMENT
2415 and the kernel or the CPU does not support MPX management.
2416 Check that the kernel and processor have MPX support.
2417 .TP
2418 .B ENXIO
2419 .I option
2420 was
2421 .BR PR_SET_SPECULATION_CTRL
2422 implies that the control of the selected speculation misfeature is not possible.
2423 See
2424 .BR PR_GET_SPECULATION_CTRL
2425 for the bit fields to determine which option is available.
2426 .TP
2427 .B EOPNOTSUPP
2428 .I option
2429 is
2430 .B PR_SET_FP_MODE
2431 and
2432 .I arg2
2433 has an invalid or unsupported value.
2434 .TP
2435 .B EPERM
2436 .I option
2437 is
2438 .BR PR_SET_SECUREBITS ,
2439 and the caller does not have the
2440 .B CAP_SETPCAP
2441 capability,
2442 or tried to unset a "locked" flag,
2443 or tried to set a flag whose corresponding locked flag was set
2444 (see
2445 .BR capabilities (7)).
2446 .TP
2447 .B EPERM
2448 .I option
2449 is
2450 .BR PR_SET_SPECULATION_CTRL
2451 wherein the speculation was disabled with
2452 .B PR_SPEC_FORCE_DISABLE
2453 and caller tried to enable it again.
2454 .TP
2455 .B EPERM
2456 .I option
2457 is
2458 .BR PR_SET_KEEPCAPS ,
2459 and the caller's
2460 .B SECBIT_KEEP_CAPS_LOCKED
2461 flag is set
2462 (see
2463 .BR capabilities (7)).
2464 .TP
2465 .B EPERM
2466 .I option
2467 is
2468 .BR PR_CAPBSET_DROP ,
2469 and the caller does not have the
2470 .B CAP_SETPCAP
2471 capability.
2472 .TP
2473 .B EPERM
2474 .I option
2475 is
2476 .BR PR_SET_MM ,
2477 and the caller does not have the
2478 .B CAP_SYS_RESOURCE
2479 capability.
2480 .TP
2481 .B EPERM
2482 .IR option
2483 is
2484 .BR PR_CAP_AMBIENT
2485 and
2486 .IR arg2
2487 is
2488 .BR PR_CAP_AMBIENT_RAISE ,
2489 but either the capability specified in
2490 .IR arg3
2491 is not present in the process's permitted and inheritable capability sets,
2492 or the
2493 .B PR_CAP_AMBIENT_LOWER
2494 securebit has been set.
2495 .TP
2496 .B ERANGE
2497 .I option
2498 was
2499 .BR PR_SET_SPECULATION_CTRL
2500 and
2501 .IR arg3
2502 is not
2503 .BR PR_SPEC_ENABLE ,
2504 .BR PR_SPEC_DISABLE ,
2505 .BR PR_SPEC_FORCE_DISABLE ,
2506 nor
2507 .BR PR_SPEC_DISABLE_NOEXEC .
2508 .SH VERSIONS
2509 The
2510 .BR prctl ()
2511 system call was introduced in Linux 2.1.57.
2512 .\" The library interface was added in glibc 2.0.6
2513 .SH CONFORMING TO
2514 This call is Linux-specific.
2515 IRIX has a
2516 .BR prctl ()
2517 system call (also introduced in Linux 2.1.44
2518 as irix_prctl on the MIPS architecture),
2519 with prototype
2520 .PP
2521 .in +4n
2522 .EX
2523 .BI "ptrdiff_t prctl(int " option ", int " arg2 ", int " arg3 );
2524 .EE
2525 .in
2526 .PP
2527 and options to get the maximum number of processes per user,
2528 get the maximum number of processors the calling process can use,
2529 find out whether a specified process is currently blocked,
2530 get or set the maximum stack size, and so on.
2531 .SH SEE ALSO
2532 .BR signal (2),
2533 .BR core (5)