OSDN Git Service

(split) LDP: Update original to LDP v3.50.
[linuxjm/LDP_man-pages.git] / original / man2 / prctl.2
1 .\" Copyright (C) 1998 Andries Brouwer (aeb@cwi.nl)
2 .\" and Copyright (C) 2002, 2006, 2008, 2012, 2013 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" and Copyright Guillem Jover <guillem@hadrons.org>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .\" Modified Thu Nov 11 04:19:42 MET 1999, aeb: added PR_GET_PDEATHSIG
28 .\" Modified 27 Jun 02, Michael Kerrisk
29 .\"     Added PR_SET_DUMPABLE, PR_GET_DUMPABLE,
30 .\"     PR_SET_KEEPCAPS, PR_GET_KEEPCAPS
31 .\" Modified 2006-08-30 Guillem Jover <guillem@hadrons.org>
32 .\"     Updated Linux versions where the options where introduced.
33 .\"     Added PR_SET_TIMING, PR_GET_TIMING, PR_SET_NAME, PR_GET_NAME,
34 .\"     PR_SET_UNALIGN, PR_GET_UNALIGN, PR_SET_FPEMU, PR_GET_FPEMU,
35 .\"     PR_SET_FPEXC, PR_GET_FPEXC
36 .\" 2008-04-29 Serge Hallyn, Document PR_CAPBSET_READ and PR_CAPBSET_DROP
37 .\" 2008-06-13 Erik Bosman, <ejbosman@cs.vu.nl>
38 .\"     Document PR_GET_TSC and PR_SET_TSC.
39 .\" 2008-06-15 mtk, Document PR_SET_SECCOMP, PR_GET_SECCOMP
40 .\" 2009-10-03 Andi Kleen, document PR_MCE_KILL
41 .\" 2012-04 Cyrill Gorcunov, Document PR_SET_MM
42 .\" 2012-04-25 Michael Kerrisk, Document PR_TASK_PERF_EVENTS_DISABLE and
43 .\"                             PR_TASK_PERF_EVENTS_ENABLE
44 .\" 2012-09-20 Kees Cook, update PR_SET_SECCOMP for mode 2
45 .\" 2012-09-20 Kees Cook, document PR_SET_NO_NEW_PRIVS, PR_GET_NO_NEW_PRIVS
46 .\" 2012-10-25 Michael Kerrisk, Document PR_SET_TIMERSLACK and
47 .\"                             PR_GET_TIMERSLACK
48 .\" 2013-01-10 Kees Cook, document PR_SET_PTRACER
49 .\" 2012-02-04 Michael kerrisk, document PR_{SET,GET}_CHILD_SUBREAPER
50 .\"
51 .\"
52 .TH PRCTL 2 2013-02-25 "Linux" "Linux Programmer's Manual"
53 .SH NAME
54 prctl \- operations on a process
55 .SH SYNOPSIS
56 .nf
57 .B #include <sys/prctl.h>
58 .sp
59 .BI "int prctl(int " option ", unsigned long " arg2 ", unsigned long " arg3 ,
60 .BI "          unsigned long " arg4 ", unsigned long " arg5 );
61 .fi
62 .SH DESCRIPTION
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 .TP
69 .BR PR_CAPBSET_READ " (since Linux 2.6.25)"
70 Return (as the function result) 1 if the capability specified in
71 .I arg2
72 is in the calling thread's capability bounding set,
73 or 0 if it is not.
74 (The capability constants are defined in
75 .IR <linux/capability.h> .)
76 The capability bounding set dictates
77 whether the process can receive the capability through a
78 file's permitted capability set on a subsequent call to
79 .BR execve (2).
80
81 If the capability specified in
82 .I arg2
83 is not valid, then the call fails with the error
84 .BR EINVAL .
85 .TP
86 .BR PR_CAPBSET_DROP " (since Linux 2.6.25)"
87 If the calling thread has the
88 .B CAP_SETPCAP
89 capability, then drop the capability specified by
90 .I arg2
91 from the calling thread's capability bounding set.
92 Any children of the calling thread will inherit the newly
93 reduced bounding set.
94
95 The call fails with the error:
96 .B EPERM
97 if the calling thread does not have the
98 .BR CAP_SETPCAP ;
99 .BR EINVAL
100 if
101 .I arg2
102 does not represent a valid capability; or
103 .BR EINVAL
104 if file capabilities are not enabled in the kernel,
105 in which case bounding sets are not supported.
106 .TP
107 .BR PR_SET_CHILD_SUBREAPER " (since Linux 3.4)"
108 .\" commit ebec18a6d3aa1e7d84aab16225e87fd25170ec2b
109 If
110 .I arg2
111 is nonzero,
112 set the "child subreaper" attribute of the calling process;
113 if
114 .I arg2
115 is zero, unset the attribute.
116 When a process is marked as a child subreaper,
117 all of the children that it creates, and their descendants,
118 will be marked as having a subreaper.
119 In effect, a subreaper fulfills the role of
120 .BR init (1)
121 for its descendant processes.
122 Upon termination of a process
123 that is orphaned (i.e., its immediate parent has already terminated)
124 and marked as having a subreaper,
125 the nearest still living ancestor subreaper
126 will receive a
127 .BR SIGCHLD
128 signal and be able to
129 .BR wait (2)
130 on the process to discover its termination status.
131 .TP
132 .BR PR_GET_CHILD_SUBREAPER " (since Linux 3.4)"
133 Return the "child subreaper" setting of the caller,
134 in the location pointed to by
135 .IR "(int\ *) arg2" .
136 .TP
137 .BR PR_SET_DUMPABLE " (since Linux 2.3.20)"
138 Set the state of the flag determining whether core dumps are produced
139 for the calling process upon delivery of a signal whose default behavior is
140 to produce a core dump.
141 (Normally, this flag is set for a process by default, but it is cleared
142 when a set-user-ID or set-group-ID program is executed and also by
143 various system calls that manipulate process UIDs and GIDs).
144 In kernels up to and including 2.6.12,
145 .I arg2
146 must be either 0 (process is not dumpable) or 1 (process is dumpable).
147 Between kernels 2.6.13 and 2.6.17, the value 2 was also permitted,
148 which caused any binary which normally would not be dumped
149 to be dumped readable by root only;
150 for security reasons, this feature has been removed.
151 .\" See http://marc.theaimsgroup.com/?l=linux-kernel&m=115270289030630&w=2
152 .\" Subject:    Fix prctl privilege escalation (CVE-2006-2451)
153 .\" From:       Marcel Holtmann <marcel () holtmann ! org>
154 .\" Date:       2006-07-12 11:12:00
155 (See also the description of
156 .I /proc/sys/fs/suid_dumpable
157 in
158 .BR proc (5).)
159 Processes that are not dumpable can not be attached via
160 .BR ptrace (2)
161 .BR PTRACE_ATTACH .
162 .TP
163 .BR PR_GET_DUMPABLE " (since Linux 2.3.20)"
164 Return (as the function result) the current state of the calling
165 process's dumpable flag.
166 .\" Since Linux 2.6.13, the dumpable flag can have the value 2,
167 .\" but in 2.6.13 PR_GET_DUMPABLE simply returns 1 if the dumpable
168 .\" flags has a nonzero value.  This was fixed in 2.6.14.
169 .TP
170 .BR PR_SET_ENDIAN " (since Linux 2.6.18, PowerPC only)"
171 Set the endian-ness of the calling process to the value given
172 in \fIarg2\fP, which should be one of the following:
173 .\" Respectively 0, 1, 2
174 .BR PR_ENDIAN_BIG ,
175 .BR PR_ENDIAN_LITTLE ,
176 or
177 .B PR_ENDIAN_PPC_LITTLE
178 (PowerPC pseudo little endian).
179 .TP
180 .BR PR_GET_ENDIAN " (since Linux 2.6.18, PowerPC only)"
181 Return the endian-ness of the calling process,
182 in the location pointed to by
183 .IR "(int\ *) arg2" .
184 .TP
185 .BR PR_SET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)"
186 Set floating-point emulation control bits to \fIarg2\fP.
187 Pass \fBPR_FPEMU_NOPRINT\fP to silently emulate fp operations accesses, or
188 \fBPR_FPEMU_SIGFPE\fP to not emulate fp operations and send
189 .B SIGFPE
190 instead.
191 .TP
192 .BR PR_GET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)"
193 Return floating-point emulation control bits,
194 in the location pointed to by
195 .IR "(int\ *) arg2" .
196 .TP
197 .BR PR_SET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)"
198 Set floating-point exception mode to \fIarg2\fP.
199 Pass \fBPR_FP_EXC_SW_ENABLE\fP to use FPEXC for FP exception enables,
200 \fBPR_FP_EXC_DIV\fP for floating-point divide by zero,
201 \fBPR_FP_EXC_OVF\fP for floating-point overflow,
202 \fBPR_FP_EXC_UND\fP for floating-point underflow,
203 \fBPR_FP_EXC_RES\fP for floating-point inexact result,
204 \fBPR_FP_EXC_INV\fP for floating-point invalid operation,
205 \fBPR_FP_EXC_DISABLED\fP for FP exceptions disabled,
206 \fBPR_FP_EXC_NONRECOV\fP for async nonrecoverable exception mode,
207 \fBPR_FP_EXC_ASYNC\fP for async recoverable exception mode,
208 \fBPR_FP_EXC_PRECISE\fP for precise exception mode.
209 .TP
210 .BR PR_GET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)"
211 Return floating-point exception mode,
212 in the location pointed to by
213 .IR "(int\ *) arg2" .
214 .TP
215 .BR PR_SET_KEEPCAPS " (since Linux 2.2.18)"
216 Set the state of the thread's "keep capabilities" flag,
217 which determines whether the threads's permitted
218 capability set is cleared when a change is made to the threads's user IDs
219 such that the threads's real UID, effective UID, and saved set-user-ID
220 all become nonzero when at least one of them previously had the value 0.
221 By default, the permitted capability set is cleared when such a change is made;
222 setting the "keep capabilities" flag prevents it from being cleared.
223 .I arg2
224 must be either 0 (permitted capabilities are cleared)
225 or 1 (permitted capabilities are kept).
226 (A thread's
227 .I effective
228 capability set is always cleared when such a credential change is made,
229 regardless of the setting of the "keep capabilities" flag.)
230 The "keep capabilities" value will be reset to 0 on subsequent calls to
231 .BR execve (2).
232 .TP
233 .BR PR_GET_KEEPCAPS " (since Linux 2.2.18)"
234 Return (as the function result) the current state of the calling threads's
235 "keep capabilities" flag.
236 .TP
237 .BR PR_SET_NAME " (since Linux 2.6.9)"
238 Set the process name for the calling thread,
239 using the value in the location pointed to by
240 .IR "(char\ *) arg2" .
241 The name can be up to 16 bytes long,
242 .\" TASK_COMM_LEN in include/linux/sched.h
243 and should be null-terminated if it contains fewer bytes.
244 .TP
245 .BR PR_GET_NAME " (since Linux 2.6.11)"
246 Return the name for the calling thread,
247 in the buffer pointed to by
248 .IR "(char\ *) arg2" .
249 The buffer should allow space for up to 16 bytes;
250 the returned string will be null-terminated if it is shorter than that.
251 .TP
252 .BR PR_SET_NO_NEW_PRIVS " (since Linux 3.5)"
253 Set the calling process's
254 .I no_new_privs
255 bit to the value in
256 .IR arg2 .
257 With
258 .I no_new_privs
259 set to 1,
260 .BR execve (2)
261 promises not to grant privileges to do anything
262 that could not have been done without the
263 .BR execve (2)
264 call (for example,
265 rendering the set-user-ID and set-group-ID permission bits,
266 and file capabilities non-functional).
267 Once set, this bit cannot be unset.
268 The setting of this bit is inherited by children created by
269 .BR fork (2)
270 and
271 .BR clone (2),
272 and preserved across
273 .BR execve (2).
274
275 For more information, see the kernel source file
276 .IR Documentation/prctl/no_new_privs.txt .
277 .TP
278 .BR PR_GET_NO_NEW_PRIVS " (since Linux 3.5)"
279 Return the value of the
280 .I no_new_privs
281 bit for the current process.
282 A value of 0 indicates the regular
283 .BR execve (2)
284 behavior.
285 A value of 1 indicates
286 .BR execve (2)
287 will operate in the privilege-restricting mode described above.
288 .TP
289 .BR PR_SET_PDEATHSIG " (since Linux 2.1.57)"
290 Set the parent process death signal
291 of the calling process to \fIarg2\fP (either a signal value
292 in the range 1..maxsig, or 0 to clear).
293 This is the signal that the calling process will get when its
294 parent dies.
295 This value is cleared for the child of a
296 .BR fork (2)
297 and (since Linux 2.4.36 / 2.6.23)
298 when executing a set-user-ID or set-group-ID binary.
299 .TP
300 .BR PR_GET_PDEATHSIG " (since Linux 2.3.15)"
301 Return the current value of the parent process death signal,
302 in the location pointed to by
303 .IR "(int\ *) arg2" .
304 .TP
305 .BR PR_SET_PTRACER " (since Linux 3.4)"
306 .\" commit 2d514487faf188938a4ee4fb3464eeecfbdcf8eb
307 .\" commit bf06189e4d14641c0148bea16e9dd24943862215
308 This is only meaningful when the Yama LSM is enabled and in mode 1
309 ("restricted ptrace", visible via
310 .IR /proc/sys/kernel/yama/ptrace_scope ).
311 When a "ptracer process ID" is passed in \fIarg2\fP,
312 the caller is declaring that the ptracer process can
313 .BR ptrace (2)
314 the calling process as if it were a direct process ancestor.
315 Each
316 .B PR_SET_PTRACER
317 operation replaces the previous "ptracer process ID".
318 Employing
319 .B PR_SET_PTRACER
320 with
321 .I arg2
322 set to 0 clears the caller's "ptracer process ID".
323 If
324 .I arg2
325 is
326 .BR PR_SET_PTRACER_ANY,
327 the ptrace restrictions introduced by Yama are effectively disabled for the
328 calling process.
329
330 For further information, see the kernel source file
331 .IR Documentation/security/Yama.txt .
332 .TP
333 .BR PR_SET_SECCOMP " (since Linux 2.6.23)"
334 .\" See http://thread.gmane.org/gmane.linux.kernel/542632
335 .\" [PATCH 0 of 2] seccomp updates
336 .\" andrea@cpushare.com
337 Set the secure computing (seccomp) mode for the calling thread, to limit
338 the available system calls.
339 The seccomp mode is selected via
340 .IR arg2 .
341 (The seccomp constants are defined in
342 .IR <linux/seccomp.h> .)
343
344 With
345 .IR arg2
346 set to
347 .BR SECCOMP_MODE_STRICT
348 the only system calls that the thread is permitted to make are
349 .BR read (2),
350 .BR write (2),
351 .BR _exit (2),
352 and
353 .BR sigreturn (2).
354 Other system calls result in the delivery of a
355 .BR SIGKILL
356 signal.
357 Strict secure computing mode is useful for number-crunching applications
358 that may need to execute untrusted byte code,
359 perhaps obtained by reading from a pipe or socket.
360 This operation is only available
361 if the kernel is configured with
362 .B CONFIG_SECCOMP
363 enabled.
364
365 With
366 .IR arg2
367 set to
368 .BR SECCOMP_MODE_FILTER " (since Linux 3.5)"
369 the system calls allowed are defined by a pointer
370 to a Berkeley Packet Filter passed in
371 .IR arg3 .
372 This argument is a pointer to
373 .IR "struct sock_fprog" ;
374 it can be designed to filter
375 arbitrary system calls and system call arguments.
376 This mode is only available if the kernel is configured with
377 .B CONFIG_SECCOMP_FILTER
378 enabled.
379
380 If
381 .BR SECCOMP_MODE_FILTER
382 filters permit
383 .BR fork (2),
384 then the seccomp mode is inherited by children created by
385 .BR fork (2);
386 if
387 .BR execve (2)
388 is permitted, then the seccomp mode is preserved across
389 .BR execve (2).
390 If the filters permit
391 .BR prctl ()
392 calls, then additional filters can be added;
393 they are run in order until the first non-allow result is seen.
394
395 For further information, see the kernel source file
396 .IR Documentation/prctl/seccomp_filter.txt .
397 .TP
398 .BR PR_GET_SECCOMP " (since Linux 2.6.23)"
399 Return the secure computing mode of the calling thread.
400 If the caller is not in secure computing mode, this operation returns 0;
401 if the caller is in strict secure computing mode, then the
402 .BR prctl ()
403 call will cause a
404 .B SIGKILL
405 signal to be sent to the process.
406 If the caller is in filter mode, and this system call is allowed by the
407 seccomp filters, it returns 2.
408 This operation is only available
409 if the kernel is configured with
410 .B CONFIG_SECCOMP
411 enabled.
412 .TP
413 .BR PR_SET_SECUREBITS " (since Linux 2.6.26)"
414 Set the "securebits" flags of the calling thread to the value supplied in
415 .IR arg2 .
416 See
417 .BR capabilities (7).
418 .TP
419 .BR PR_GET_SECUREBITS " (since Linux 2.6.26)"
420 Return (as the function result)
421 the "securebits" flags of the calling thread.
422 See
423 .BR capabilities (7).
424 .TP
425 .BR PR_GET_TID_ADDRESS " (since Linux 3.5)"
426 .\" commit 300f786b2683f8bb1ec0afb6e1851183a479c86d
427 Retrieve the
428 .I clear_child_tid
429 address set by
430 .BR set_tid_address (2)
431 and the
432 .BR clone (2)
433 .B CLONE_CHILD_CLEARTID
434 flag, in the location pointed to by
435 .IR "(int\ **)\ arg2" .
436 This feature is available only if the kernel is built with the
437 .BR CONFIG_CHECKPOINT_RESTORE
438 option enabled.
439 .TP
440 .BR PR_SET_TIMERSLACK " (since Linux 2.6.28)"
441 .\" See https://lwn.net/Articles/369549/
442 .\" commit 6976675d94042fbd446231d1bd8b7de71a980ada
443 Set the current timer slack for the calling thread to the nanosecond value
444 supplied in
445 .IR arg2 .
446 If
447 .I arg2
448 is less than or equal to zero,
449 .\" It seems that it's not possible to set the timer slack to zero;
450 .\" The minimum value is 1? Seems a little strange.
451 reset the current timer slack to the thread's default timer slack value.
452 The timer slack is used by the kernel to group timer expirations
453 for the calling thread that are close to one another;
454 as a consequence, timer expirations for the thread may be
455 up to the specified number of nanoseconds late (but will never expire early).
456 Grouping timer expirations can help reduce system power consumption
457 by minimizing CPU wake-ups.
458
459 The timer expirations affected by timer slack are those set by
460 .BR select (2),
461 .BR pselect (2),
462 .BR poll (2),
463 .BR ppoll (2),
464 .BR epoll_wait (2),
465 .BR epoll_pwait (2),
466 .BR clock_nanosleep (2),
467 .BR nanosleep (2),
468 and
469 .BR futex (2)
470 (and thus the library functions implemented via futexes, including
471 .\" List obtained by grepping for futex usage in glibc source
472 .BR pthread_cond_timedwait (3),
473 .BR pthread_mutex_timedlock (3),
474 .BR pthread_rwlock_timedrdlock (3),
475 .BR pthread_rwlock_timedwrlock (3),
476 and
477 .BR sem_timedwait (3)).
478
479 Timer slack is not applied to threads that are scheduled under
480 a realtime scheduling policy (see
481 .BR sched_setscheduler (2)).
482
483 Each thread has two associated timer slack values:
484 a "default" value, and a "current" value.
485 The current value is the one that governs grouping
486 of timer expirations.
487 When a new thread is created,
488 the two timer slack values are made the same as the current value
489 of the creating thread.
490 Thereafter, a thread can adjust its current timer slack value via
491 .BR PR_SET_TIMERSLACK
492 (the default value can't be changed).
493 The timer slack values of
494 .IR init
495 (PID 1), the ancestor of all processes,
496 are 50,000 nanoseconds (50 microseconds).
497 The timer slack values are preserved across
498 .BR execve (2).
499 .TP
500 .BR PR_GET_TIMERSLACK " (since Linux 2.6.28)"
501 Return the current timer slack value of the calling thread.
502 .TP
503 .BR PR_SET_TIMING " (since Linux 2.6.0-test4)"
504 Set whether to use (normal, traditional) statistical process timing or
505 accurate timestamp-based process timing, by passing
506 .B PR_TIMING_STATISTICAL
507 .\" 0
508 or
509 .B PR_TIMING_TIMESTAMP
510 .\" 1
511 to \fIarg2\fP.
512 .B PR_TIMING_TIMESTAMP
513 is not currently implemented
514 (attempting to set this mode will yield the error
515 .BR EINVAL ).
516 .\" PR_TIMING_TIMESTAMP doesn't do anything in 2.6.26-rc8,
517 .\" and looking at the patch history, it appears
518 .\" that it never did anything.
519 .TP
520 .BR PR_GET_TIMING " (since Linux 2.6.0-test4)"
521 Return (as the function result) which process timing method is currently
522 in use.
523 .TP
524 .BR PR_TASK_PERF_EVENTS_DISABLE " (since Linux 2.6.31)"
525 Disable all performance counters attached to the calling process,
526 regardless of whether the counters were created by
527 this process or another process.
528 Performance counters created by the calling process for other
529 processes are unaffected.
530 For more information on performance counters, see the Linux kernel source file
531 .IR tools/perf/design.txt .
532 .IP
533 Originally called
534 .BR PR_TASK_PERF_COUNTERS_DISABLE ;
535 .\" commit 1d1c7ddbfab358445a542715551301b7fc363e28
536 renamed (with same numerical value)
537 in Linux 2.6.32.
538 .TP
539 .BR PR_TASK_PERF_EVENTS_ENABLE " (since Linux 2.6.31)"
540 The converse of
541 .BR PR_TASK_PERF_EVENTS_DISABLE ;
542 enable performance counters attached to the calling process.
543 .IP
544 Originally called
545 .BR PR_TASK_PERF_COUNTERS_ENABLE ;
546 .\" commit 1d1c7ddbfab358445a542715551301b7fc363e28
547 renamed
548 .\" commit cdd6c482c9ff9c55475ee7392ec8f672eddb7be6
549 in Linux 2.6.32.
550 .TP
551 .BR PR_SET_TSC " (since Linux 2.6.26, x86 only)"
552 Set the state of the flag determining whether the timestamp counter
553 can be read by the process.
554 Pass
555 .B PR_TSC_ENABLE
556 to
557 .I arg2
558 to allow it to be read, or
559 .B PR_TSC_SIGSEGV
560 to generate a
561 .B SIGSEGV
562 when the process tries to read the timestamp counter.
563 .TP
564 .BR PR_GET_TSC " (since Linux 2.6.26, x86 only)"
565 Return the state of the flag determining whether the timestamp counter
566 can be read,
567 in the location pointed to by
568 .IR "(int\ *) arg2" .
569 .TP
570 .B PR_SET_UNALIGN
571 (Only on: ia64, since Linux 2.3.48; parisc, since Linux 2.6.15;
572 PowerPC, since Linux 2.6.18; Alpha, since Linux 2.6.22)
573 Set unaligned access control bits to \fIarg2\fP.
574 Pass
575 \fBPR_UNALIGN_NOPRINT\fP to silently fix up unaligned user accesses,
576 or \fBPR_UNALIGN_SIGBUS\fP to generate
577 .B SIGBUS
578 on unaligned user access.
579 .TP
580 .B PR_GET_UNALIGN
581 (see
582 .B PR_SET_UNALIGN
583 for information on versions and architectures)
584 Return unaligned access control bits, in the location pointed to by
585 .IR "(int\ *) arg2" .
586 .TP
587 .BR PR_MCE_KILL " (since Linux 2.6.32)"
588 Set the machine check memory corruption kill policy for the current thread.
589 If
590 .I arg2
591 is
592 .BR PR_MCE_KILL_CLEAR ,
593 clear the thread memory corruption kill policy and use the system-wide default.
594 (The system-wide default is defined by
595 .IR /proc/sys/vm/memory_failure_early_kill ;
596 see
597 .BR proc (5).)
598 If
599 .I arg2
600 is
601 .BR PR_MCE_KILL_SET ,
602 use a thread-specific memory corruption kill policy.
603 In this case,
604 .I arg3
605 defines whether the policy is
606 .I early kill
607 .RB ( PR_MCE_KILL_EARLY ),
608 .I late kill
609 .RB ( PR_MCE_KILL_LATE ),
610 or the system-wide default
611 .RB ( PR_MCE_KILL_DEFAULT ).
612 Early kill means that the thread receives a
613 .B SIGBUS
614 signal as soon as hardware memory corruption is detected inside
615 its address space.
616 In late kill mode, the process is only killed when it accesses a corrupted page.
617 See
618 .BR sigaction (2)
619 for more information on the
620 .BR SIGBUS
621 signal.
622 The policy is inherited by children.
623 The remaining unused
624 .BR prctl ()
625 arguments must be zero for future compatibility.
626 .TP
627 .BR PR_MCE_KILL_GET " (since Linux 2.6.32)"
628 Return the current per-process machine check kill policy.
629 All unused
630 .BR prctl ()
631 arguments must be zero.
632 .TP
633 .BR PR_SET_MM " (since Linux 3.3)"
634 Modify certain kernel memory map descriptor fields
635 of the calling process.
636 Usually these fields are set by the kernel and dynamic loader (see
637 .BR ld.so (8)
638 for more information) and a regular application should not use this feature.
639 However, there are cases, such as self-modifying programs,
640 where a program might find it useful to change its own memory map.
641 This feature is available only if the kernel is built with the
642 .BR CONFIG_CHECKPOINT_RESTORE
643 option enabled.
644 The calling process must have the
645 .BR CAP_SYS_RESOURCE
646 capability.
647 The value in
648 .I arg2
649 is one of the options below, while
650 .I arg3
651 provides a new value for the option.
652 .RS
653 .TP
654 .BR PR_SET_MM_START_CODE
655 Set the address above which the program text can run.
656 The corresponding memory area must be readable and executable,
657 but not writable or sharable (see
658 .BR mprotect (2)
659 and
660 .BR mmap (2)
661 for more information).
662 .TP
663 .BR PR_SET_MM_END_CODE
664 Set the address below which the program text can run.
665 The corresponding memory area must be readable and executable,
666 but not writable or sharable.
667 .TP
668 .BR PR_SET_MM_START_DATA
669 Set the address above which initialized and
670 uninitialized (bss) data are placed.
671 The corresponding memory area must be readable and writable,
672 but not executable or sharable.
673 .TP
674 .B PR_SET_MM_END_DATA
675 Set the address below which initialized and
676 uninitialized (bss) data are placed.
677 The corresponding memory area must be readable and writable,
678 but not executable or sharable.
679 .TP
680 .BR PR_SET_MM_START_STACK
681 Set the start address of the stack.
682 The corresponding memory area must be readable and writable.
683 .TP
684 .BR PR_SET_MM_START_BRK
685 Set the address above which the program heap can be expanded with
686 .BR brk (2)
687 call.
688 The address must be greater than the ending address of
689 the current program data segment.
690 In addition, the combined size of the resulting heap and
691 the size of the data segment can't exceed the
692 .BR RLIMIT_DATA
693 resource limit (see
694 .BR setrlimit (2)).
695 .TP
696 .BR PR_SET_MM_BRK
697 Set the current
698 .BR brk (2)
699 value.
700 The requirements for the address are the same as for the
701 .BR PR_SET_MM_START_BRK
702 option.
703 .\" FIXME The following (until ========) is not yet in mainline kernel,
704 .\" so commented out for the moment.
705 .\" .TP
706 .\" .BR PR_SET_MM_ARG_START
707 .\" Set the address above which the program command line is placed.
708 .\" .TP
709 .\" .BR PR_SET_MM_ARG_END
710 .\" Set the address below which the program command line is placed.
711 .\" .TP
712 .\" .BR PR_SET_MM_ENV_START
713 .\" Set the address above which the program environment is placed.
714 .\" .TP
715 .\" .BR PR_SET_MM_ENV_END
716 .\" Set the address below which the program environment is placed.
717 .\" .IP
718 .\" The address passed with
719 .\" .BR PR_SET_MM_ARG_START ,
720 .\" .BR PR_SET_MM_ARG_END ,
721 .\" .BR PR_SET_MM_ENV_START ,
722 .\" and
723 .\" .BR PR_SET_MM_ENV_END
724 .\" should belong to a process stack area.
725 .\" Thus, the corresponding memory area must be readable, writable, and
726 .\" (depending on the kernel configuration) have the
727 .\" .BR MAP_GROWSDOWN
728 .\" attribute set (see
729 .\" .BR mmap (2)).
730 .\" .TP
731 .\" .BR PR_SET_MM_AUXV
732 .\" Set a new auxiliary vector.
733 .\" The
734 .\" .I arg3
735 .\" argument should provide the address of the vector.
736 .\" The
737 .\" .I arg4
738 .\" is the size of the vector.
739 .\" .TP
740 .\" .BR PR_SET_MM_EXE_FILE
741 .\" Supersede the
742 .\" .IR /proc/pid/exe
743 .\" symbolic link with a new one pointing to a new executable file
744 .\" identified by the file descriptor provided in
745 .\" .I arg3
746 .\" argument.
747 .\" The file descriptor should be obtained with a regular
748 .\" .BR open (2)
749 .\" call.
750 .\" .IP
751 .\" To change the symbolic link, one needs to unmap all existing
752 .\" executable memory areas, including those created by the kernel itself
753 .\" (for example the kernel usually creates at least one executable
754 .\" memory area for the ELF
755 .\" .IR \.text
756 .\" section).
757 .\" .IP
758 .\" The second limitation is that such transitions can be done only once
759 .\" in a process life time.
760 .\" Any further attempts will be rejected.
761 .\" This should help system administrators to monitor unusual
762 .\" symbolic-link transitions over all process running in a system.
763 .\" ========== END FIXME
764 .RE
765 .\"
766 .SH RETURN VALUE
767 On success,
768 .BR PR_GET_DUMPABLE ,
769 .BR PR_GET_KEEPCAPS ,
770 .BR PR_GET_NO_NEW_PRIVS ,
771 .BR PR_CAPBSET_READ ,
772 .BR PR_GET_TIMING ,
773 .BR PR_GET_SECUREBITS ,
774 .BR PR_MCE_KILL_GET ,
775 and (if it returns)
776 .BR PR_GET_SECCOMP
777 return the nonnegative values described above.
778 All other
779 .I option
780 values return 0 on success.
781 On error, \-1 is returned, and
782 .I errno
783 is set appropriately.
784 .SH ERRORS
785 .TP
786 .B EFAULT
787 .I arg2
788 is an invalid address.
789 .TP
790 .B EINVAL
791 The value of
792 .I option
793 is not recognized.
794 .TP
795 .B EINVAL
796 .I option
797 is
798 .BR PR_MCE_KILL
799 or
800 .BR PR_MCE_KILL_GET
801 or
802 .BR PR_SET_MM ,
803 and unused
804 .BR prctl ()
805 arguments were not specified as zero.
806 .TP
807 .B EINVAL
808 .I arg2
809 is not valid value for this
810 .IR option .
811 .TP
812 .B EINVAL
813 .I option
814 is
815 .BR PR_SET_SECCOMP
816 or
817 .BR PR_GET_SECCOMP ,
818 and the kernel was not configured with
819 .BR CONFIG_SECCOMP .
820 .TP
821 .B EINVAL
822 .I option
823 is
824 .BR PR_SET_MM ,
825 and one of the following is true
826 .RS
827 .IP * 3
828 .I arg4
829 or
830 .I arg5
831 is nonzero;
832 .IP *
833 .I arg3
834 is greater than
835 .B TASK_SIZE
836 (the limit on the size of the user address space for this architecture);
837 .IP *
838 .I arg2
839 is
840 .BR PR_SET_MM_START_CODE ,
841 .BR PR_SET_MM_END_CODE ,
842 .BR PR_SET_MM_START_DATA ,
843 .BR PR_SET_MM_END_DATA ,
844 or
845 .BR PR_SET_MM_START_STACK,
846 and the permissions of the corresponding memory area are not as required;
847 .IP *
848 .I arg2
849 is
850 .BR PR_SET_MM_START_BRK
851 or
852 .BR PR_SET_MM_BRK ,
853 and
854 .I arg3
855 is less than or equal to the end of the data segment
856 or specifies a value that would cause the
857 .B RLIMIT_DATA
858 resource limit to be exceeded.
859 .RE
860 .TP
861 .B EINVAL
862 .I option
863 is
864 .BR PR_SET_PTRACER
865 and
866 .I arg2
867 is not 0,
868 .BR PR_SET_PTRACER_ANY ,
869 or the PID of an existing process.
870 .TP
871 .B EPERM
872 .I option
873 is
874 .BR PR_SET_SECUREBITS ,
875 and the caller does not have the
876 .B CAP_SETPCAP
877 capability,
878 or tried to unset a "locked" flag,
879 or tried to set a flag whose corresponding locked flag was set
880 (see
881 .BR capabilities (7)).
882 .TP
883 .B EPERM
884 .I option
885 is
886 .BR PR_SET_KEEPCAPS ,
887 and the callers's
888 .B SECURE_KEEP_CAPS_LOCKED
889 flag is set
890 (see
891 .BR capabilities (7)).
892 .TP
893 .B EPERM
894 .I option
895 is
896 .BR PR_CAPBSET_DROP ,
897 and the caller does not have the
898 .B CAP_SETPCAP
899 capability.
900 .TP
901 .B EPERM
902 .I option
903 is
904 .BR PR_SET_MM ,
905 and the caller does not have the
906 .B CAP_SYS_RESOURCE
907 capability.
908 .\" FIXME The following (until ========) is not yet in mainline kernel,
909 .\" so commented out for the moment.
910 .\" .TP
911 .\" .B EACCES
912 .\" .I option
913 .\" is
914 .\" .BR PR_SET_MM ,
915 .\" and
916 .\" .I arg3
917 .\" is
918 .\" .BR PR_SET_MM_EXE_FILE ,
919 .\" the file is not executable.
920 .\" .TP
921 .\" .B EBUSY
922 .\" .I option
923 .\" is
924 .\" .BR PR_SET_MM ,
925 .\" .I arg3
926 .\" is
927 .\" .BR PR_SET_MM_EXE_FILE ,
928 .\" and this the second attempt to change the
929 .\" .I /proc/pid/exe
930 .\" symbolic link, which is prohibited.
931 .\" .TP
932 .\" .B EBADF
933 .\" .I option
934 .\" is
935 .\" .BR PR_SET_MM ,
936 .\" .I arg3
937 .\" is
938 .\" .BR PR_SET_MM_EXE_FILE ,
939 .\" and the file descriptor passed in
940 .\" .I arg4
941 .\" is not valid.
942 .\" ========== END FIXME
943 .\" The following can't actually happen, because prctl() in
944 .\" seccomp mode will cause SIGKILL.
945 .\" .TP
946 .\" .B EPERM
947 .\" .I option
948 .\" is
949 .\" .BR PR_SET_SECCOMP ,
950 .\" and secure computing mode is already 1.
951 .SH VERSIONS
952 The
953 .BR prctl ()
954 system call was introduced in Linux 2.1.57.
955 .\" The library interface was added in glibc 2.0.6
956 .SH CONFORMING TO
957 This call is Linux-specific.
958 IRIX has a
959 .BR prctl ()
960 system call (also introduced in Linux 2.1.44
961 as irix_prctl on the MIPS architecture),
962 with prototype
963 .sp
964 .BI "ptrdiff_t prctl(int " option ", int " arg2 ", int " arg3 );
965 .sp
966 and options to get the maximum number of processes per user,
967 get the maximum number of processors the calling process can use,
968 find out whether a specified process is currently blocked,
969 get or set the maximum stack size, and so on.
970 .SH SEE ALSO
971 .BR signal (2),
972 .BR core (5)