]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/prctl.2
prctl.2: Minor edits to Kee's patch
[thirdparty/man-pages.git] / man2 / prctl.2
CommitLineData
fea681da
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" Copyright (C) 1998 Andries Brouwer (aeb@cwi.nl)
c11b1abf 4.\" and Copyright (C) 2002 Michael Kerrisk <mtk.manpages@gmail.com>
af5f9508 5.\" and Copyright Guillem Jover <guillem@hadrons.org>
fea681da
MK
6.\"
7.\" Permission is granted to make and distribute verbatim copies of this
8.\" manual provided the copyright notice and this permission notice are
9.\" preserved on all copies.
10.\"
11.\" Permission is granted to copy and distribute modified versions of this
12.\" manual under the conditions for verbatim copying, provided that the
13.\" entire resulting derived work is distributed under the terms of a
14.\" permission notice identical to this one.
c13182ef 15.\"
fea681da
MK
16.\" Since the Linux kernel and libraries are constantly changing, this
17.\" manual page may be incorrect or out-of-date. The author(s) assume no
18.\" responsibility for errors or omissions, or for damages resulting from
19.\" the use of the information contained herein. The author(s) may not
20.\" have taken the same level of care in the production of this manual,
21.\" which is licensed free of charge, as they might when working
22.\" professionally.
c13182ef 23.\"
fea681da
MK
24.\" Formatted or processed versions of this manual, if unaccompanied by
25.\" the source, must acknowledge the copyright and authors of this work.
26.\"
27.\" Modified Thu Nov 11 04:19:42 MET 1999, aeb: added PR_GET_PDEATHSIG
28.\" Modified 27 Jun 02, Michael Kerrisk
c13182ef 29.\" Added PR_SET_DUMPABLE, PR_GET_DUMPABLE,
fea681da 30.\" PR_SET_KEEPCAPS, PR_GET_KEEPCAPS
e87fdd92
MK
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
8ab8b43f
MK
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
bc02b3ea 40.\" 2009-10-03 Andi Kleen, document PR_MCE_KILL
06afe673 41.\" 2012-04 Cyrill Gorcunov, Document PR_SET_MM
bc02b3ea
MK
42.\" 2012-04-25 Michael Kerrisk, Document PR_TASK_PERF_EVENTS_DISABLE and
43.\" PR_TASK_PERF_EVENTS_ENABLE
34447828 44.\" 2012-09-20 Kees Cook, update PR_SET_SECCOMP for mode 2
f83fe154 45.\" 2012-09-20 Kees Cook, document PR_SET_NO_NEW_PRIVS, PR_GET_NO_NEW_PRIVS
fea681da 46.\"
e14baeeb 47.\" FIXME: Document PR_SET_TIMERSLACK and PR_GET_TIMERSLACK (new in 2.6.28)
bc02b3ea 48.\" commit 6976675d94042fbd446231d1bd8b7de71a980ada
e14baeeb 49.\"
34447828 50.TH PRCTL 2 2012-10-22 "Linux" "Linux Programmer's Manual"
fea681da
MK
51.SH NAME
52prctl \- operations on a process
53.SH SYNOPSIS
521bf584 54.nf
fea681da
MK
55.B #include <sys/prctl.h>
56.sp
521bf584
MK
57.BI "int prctl(int " option ", unsigned long " arg2 ", unsigned long " arg3 ,
58.BI " unsigned long " arg4 ", unsigned long " arg5 );
59.fi
fea681da 60.SH DESCRIPTION
e511ffb6 61.BR prctl ()
fea681da 62is called with a first argument describing what to do
1a329b56 63(with values defined in \fI<linux/prctl.h>\fP), and further
c4bb193f 64arguments with a significance depending on the first one.
fea681da
MK
65The first argument can be:
66.TP
2e781e20 67.BR PR_CAPBSET_READ " (since Linux 2.6.25)"
8ab8b43f
MK
68Return (as the function result) 1 if the capability specified in
69.I arg2
70is in the calling thread's capability bounding set,
71or 0 if it is not.
72(The capability constants are defined in
73.IR <linux/capability.h> .)
74The capability bounding set dictates
75whether the process can receive the capability through a
2914a14d 76file's permitted capability set on a subsequent call to
8ab8b43f
MK
77.BR execve (2).
78
79If the capability specified in
80.I arg2
81is not valid, then the call fails with the error
82.BR EINVAL .
83.TP
84.BR PR_CAPBSET_DROP " (since Linux 2.6.25)"
85If the calling thread has the
86.B CAP_SETPCAP
87capability, then drop the capability specified by
88.I arg2
89from the calling thread's capability bounding set.
90Any children of the calling thread will inherit the newly
91reduced bounding set.
92
93The call fails with the error:
94.B EPERM
2914a14d 95if the calling thread does not have the
8ab8b43f
MK
96.BR CAP_SETPCAP ;
97.BR EINVAL
98if
99.I arg2
100does not represent a valid capability; or
101.BR EINVAL
102if file capabilities are not enabled in the kernel,
103in which case bounding sets are not supported.
104.TP
88989295
MK
105.BR PR_SET_DUMPABLE " (since Linux 2.3.20)"
106Set the state of the flag determining whether core dumps are produced
107for this process upon delivery of a signal whose default behavior is
108to produce a core dump.
109(Normally this flag is set for a process by default, but it is cleared
110when a set-user-ID or set-group-ID program is executed and also by
111various system calls that manipulate process UIDs and GIDs).
112In kernels up to and including 2.6.12,
8ab8b43f 113.I arg2
88989295
MK
114must be either 0 (process is not dumpable) or 1 (process is dumpable).
115Between kernels 2.6.13 and 2.6.17, the value 2 was also permitted,
116which caused any binary which normally would not be dumped
117to be dumped readable by root only;
118for security reasons, this feature has been removed.
119.\" See http://marc.theaimsgroup.com/?l=linux-kernel&m=115270289030630&w=2
120.\" Subject: Fix prctl privilege escalation (CVE-2006-2451)
121.\" From: Marcel Holtmann <marcel () holtmann ! org>
122.\" Date: 2006-07-12 11:12:00
123(See also the description of
124.I /proc/sys/fs/suid_dumpable
125in
126.BR proc (5).)
cadcf1b1 127Processes that are not dumpable can not be attached via
6fdbc779 128.BR ptrace (2)
cadcf1b1 129.BR PTRACE_ATTACH .
64536a1b 130.TP
88989295
MK
131.BR PR_GET_DUMPABLE " (since Linux 2.3.20)"
132Return (as the function result) the current state of the calling
133process's dumpable flag.
134.\" Since Linux 2.6.13, the dumpable flag can have the value 2,
135.\" but in 2.6.13 PR_GET_DUMPABLE simply returns 1 if the dumpable
c7094399 136.\" flags has a nonzero value. This was fixed in 2.6.14.
64536a1b 137.TP
8ab8b43f 138.BR PR_SET_ENDIAN " (since Linux 2.6.18, PowerPC only)"
c13182ef 139Set the endian-ness of the calling process to the value given
64536a1b 140in \fIarg2\fP, which should be one of the following:
8ab8b43f 141.\" Respectively 0, 1, 2
64536a1b
MK
142.BR PR_ENDIAN_BIG ,
143.BR PR_ENDIAN_LITTLE ,
144or
0daa9e92 145.B PR_ENDIAN_PPC_LITTLE
64536a1b 146(PowerPC pseudo little endian).
e87fdd92 147.TP
8ab8b43f
MK
148.BR PR_GET_ENDIAN " (since Linux 2.6.18, PowerPC only)"
149Return the endian-ness of the calling process,
150in the location pointed to by
151.IR "(int\ *) arg2" .
152.TP
8ab8b43f 153.BR PR_SET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)"
e87fdd92
MK
154Set floating-point emulation control bits to \fIarg2\fP.
155Pass \fBPR_FPEMU_NOPRINT\fP to silently emulate fp operations accesses, or
8bd58774
MK
156\fBPR_FPEMU_SIGFPE\fP to not emulate fp operations and send
157.B SIGFPE
158instead.
e87fdd92 159.TP
8ab8b43f
MK
160.BR PR_GET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)"
161Return floating-point emulation control bits,
162in the location pointed to by
163.IR "(int\ *) arg2" .
e87fdd92 164.TP
8ab8b43f 165.BR PR_SET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)"
1c44bd5b
MK
166Set floating-point exception mode to \fIarg2\fP.
167Pass \fBPR_FP_EXC_SW_ENABLE\fP to use FPEXC for FP exception enables,
c45bd688
MK
168\fBPR_FP_EXC_DIV\fP for floating-point divide by zero,
169\fBPR_FP_EXC_OVF\fP for floating-point overflow,
170\fBPR_FP_EXC_UND\fP for floating-point underflow,
171\fBPR_FP_EXC_RES\fP for floating-point inexact result,
172\fBPR_FP_EXC_INV\fP for floating-point invalid operation,
e87fdd92 173\fBPR_FP_EXC_DISABLED\fP for FP exceptions disabled,
b28f6e56 174\fBPR_FP_EXC_NONRECOV\fP for async nonrecoverable exception mode,
e87fdd92
MK
175\fBPR_FP_EXC_ASYNC\fP for async recoverable exception mode,
176\fBPR_FP_EXC_PRECISE\fP for precise exception mode.
177.TP
8ab8b43f
MK
178.BR PR_GET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)"
179Return floating-point exception mode,
180in the location pointed to by
181.IR "(int\ *) arg2" .
182.TP
88989295
MK
183.BR PR_SET_KEEPCAPS " (since Linux 2.2.18)"
184Set the state of the thread's "keep capabilities" flag,
028cb080
MK
185which determines whether the threads's permitted
186capability set is cleared when a change is made to the threads's user IDs
88989295 187such that the threads's real UID, effective UID, and saved set-user-ID
c7094399 188all become nonzero when at least one of them previously had the value 0.
028cb080
MK
189By default, the permitted capability set is cleared when such a change is made;
190setting the "keep capabilities" flag prevents it from being cleared.
88989295 191.I arg2
028cb080
MK
192must be either 0 (permitted capabilities are cleared)
193or 1 (permitted capabilities are kept).
194(A thread's
195.I effective
196capability set is always cleared when such a credential change is made,
197regardless of the setting of the "keep capabilities" flag.)
198The "keep capabilities" value will be reset to 0 on subsequent calls to
88989295
MK
199.BR execve (2).
200.TP
201.BR PR_GET_KEEPCAPS " (since Linux 2.2.18)"
202Return (as the function result) the current state of the calling threads's
203"keep capabilities" flag.
204.TP
205.BR PR_SET_NAME " (since Linux 2.6.9)"
206Set the process name for the calling process,
207using the value in the location pointed to by
208.IR "(char\ *) arg2" .
209The name can be up to 16 bytes long,
210.\" TASK_COMM_LEN in include/linux/sched.h
bd74a873 211and should be null-terminated if it contains fewer bytes.
88989295
MK
212.TP
213.BR PR_GET_NAME " (since Linux 2.6.11)"
214Return the process name for the calling process,
215in the buffer pointed to by
216.IR "(char\ *) arg2" .
217The buffer should allow space for up to 16 bytes;
bd74a873 218the returned string will be null-terminated if it is shorter than that.
88989295 219.TP
f83fe154 220.BR PR_SET_NO_NEW_PRIVS " (since Linux 3.5)"
0fcc276f
MK
221Set the calling process's
222.I no_new_privs
223bit to the value in
224.IR arg2 .
225With
226.I Ino_new_privs
227set to 1,
228.BR execve (2)
229promises not
f83fe154 230to grant the privilege to do anything that could not have been done
0fcc276f
MK
231without thecw
232.BR execve (2)
233call (for example, rendering set-user-ID, set-group-ID, and file
234capabilities non-functional).
235When enabled, this value is inherited across
236.BR fork (2),
237.BR clone (2),
238and
239.BR execve (2)
240and cannot be unset.
f83fe154
KC
241.TP
242.BR PR_GET_NO_NEW_PRIVS " (since Linux 3.5)"
0fcc276f
MK
243Return the value of the
244.I no_new_privs
245bit for the current process.
246A value of 0 indicates the regular
247.BR execve (2)
248behavior.
249A value of 1 indicates
250.BR execve (2)
251will operate in the privilege restricting mode described above.
f83fe154 252.TP
88989295
MK
253.BR PR_SET_PDEATHSIG " (since Linux 2.1.57)"
254Set the parent process death signal
255of the calling process to \fIarg2\fP (either a signal value
256in the range 1..maxsig, or 0 to clear).
257This is the signal that the calling process will get when its
258parent dies.
259This value is cleared for the child of a
c7c7235c
MK
260.BR fork (2)
261and (since Linux 2.5.36 / 2.6.23)
9a830e62 262when executing a set-user_ID or set-group-ID binary.
88989295
MK
263.TP
264.BR PR_GET_PDEATHSIG " (since Linux 2.3.15)"
265Return the current value of the parent process death signal,
266in the location pointed to by
267.IR "(int\ *) arg2" .
268.TP
8ab8b43f
MK
269.BR PR_SET_SECCOMP " (since Linux 2.6.23)"
270.\" See http://thread.gmane.org/gmane.linux.kernel/542632
271.\" [PATCH 0 of 2] seccomp updates
272.\" andrea@cpushare.com
d6ef3d57
MK
273Set the secure computing (seccomp) mode for the calling thread, to limit
274the available system calls.
34447828
KC
275The seccomp mode is selected via
276.IR arg2 .
277(The seccomp constants are defined in
278.IR <linux/seccomp.h> .)
279
280With
8ab8b43f 281.IR arg2
34447828
KC
282set to
283.BR SECCOMP_MODE_STRICT
8ab8b43f
MK
284the only system calls that the thread is permitted to make are
285.BR read (2),
286.BR write (2),