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