]>
Commit | Line | Data |
---|---|---|
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 |
52 | prctl \- 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 | 62 | is called with a first argument describing what to do |
1a329b56 | 63 | (with values defined in \fI<linux/prctl.h>\fP), and further |
c4bb193f | 64 | arguments with a significance depending on the first one. |
fea681da MK |
65 | The first argument can be: |
66 | .TP | |
2e781e20 | 67 | .BR PR_CAPBSET_READ " (since Linux 2.6.25)" |
8ab8b43f MK |
68 | Return (as the function result) 1 if the capability specified in |
69 | .I arg2 | |
70 | is in the calling thread's capability bounding set, | |
71 | or 0 if it is not. | |
72 | (The capability constants are defined in | |
73 | .IR <linux/capability.h> .) | |
74 | The capability bounding set dictates | |
75 | whether the process can receive the capability through a | |
2914a14d | 76 | file's permitted capability set on a subsequent call to |
8ab8b43f MK |
77 | .BR execve (2). |
78 | ||
79 | If the capability specified in | |
80 | .I arg2 | |
81 | is not valid, then the call fails with the error | |
82 | .BR EINVAL . | |
83 | .TP | |
84 | .BR PR_CAPBSET_DROP " (since Linux 2.6.25)" | |
85 | If the calling thread has the | |
86 | .B CAP_SETPCAP | |
87 | capability, then drop the capability specified by | |
88 | .I arg2 | |
89 | from the calling thread's capability bounding set. | |
90 | Any children of the calling thread will inherit the newly | |
91 | reduced bounding set. | |
92 | ||
93 | The call fails with the error: | |
94 | .B EPERM | |
2914a14d | 95 | if the calling thread does not have the |
8ab8b43f MK |
96 | .BR CAP_SETPCAP ; |
97 | .BR EINVAL | |
98 | if | |
99 | .I arg2 | |
100 | does not represent a valid capability; or | |
101 | .BR EINVAL | |
102 | if file capabilities are not enabled in the kernel, | |
103 | in which case bounding sets are not supported. | |
104 | .TP | |
88989295 MK |
105 | .BR PR_SET_DUMPABLE " (since Linux 2.3.20)" |
106 | Set the state of the flag determining whether core dumps are produced | |
107 | for this process upon delivery of a signal whose default behavior is | |
108 | to produce a core dump. | |
109 | (Normally this flag is set for a process by default, but it is cleared | |
110 | when a set-user-ID or set-group-ID program is executed and also by | |
111 | various system calls that manipulate process UIDs and GIDs). | |
112 | In kernels up to and including 2.6.12, | |
8ab8b43f | 113 | .I arg2 |
88989295 MK |
114 | must be either 0 (process is not dumpable) or 1 (process is dumpable). |
115 | Between kernels 2.6.13 and 2.6.17, the value 2 was also permitted, | |
116 | which caused any binary which normally would not be dumped | |
117 | to be dumped readable by root only; | |
118 | for 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 | |
125 | in | |
126 | .BR proc (5).) | |
cadcf1b1 | 127 | Processes 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)" |
132 | Return (as the function result) the current state of the calling | |
133 | process'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 | 139 | Set the endian-ness of the calling process to the value given |
64536a1b | 140 | in \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 , | |
144 | or | |
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)" |
149 | Return the endian-ness of the calling process, | |
150 | in 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 |
154 | Set floating-point emulation control bits to \fIarg2\fP. |
155 | Pass \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 | |
158 | instead. | |
e87fdd92 | 159 | .TP |
8ab8b43f MK |
160 | .BR PR_GET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)" |
161 | Return floating-point emulation control bits, | |
162 | in 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 |
166 | Set floating-point exception mode to \fIarg2\fP. |
167 | Pass \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)" |
179 | Return floating-point exception mode, | |
180 | in the location pointed to by | |
181 | .IR "(int\ *) arg2" . | |
182 | .TP | |
88989295 MK |
183 | .BR PR_SET_KEEPCAPS " (since Linux 2.2.18)" |
184 | Set the state of the thread's "keep capabilities" flag, | |
028cb080 MK |
185 | which determines whether the threads's permitted |
186 | capability set is cleared when a change is made to the threads's user IDs | |
88989295 | 187 | such that the threads's real UID, effective UID, and saved set-user-ID |
c7094399 | 188 | all become nonzero when at least one of them previously had the value 0. |
028cb080 MK |
189 | By default, the permitted capability set is cleared when such a change is made; |
190 | setting the "keep capabilities" flag prevents it from being cleared. | |
88989295 | 191 | .I arg2 |
028cb080 MK |
192 | must be either 0 (permitted capabilities are cleared) |
193 | or 1 (permitted capabilities are kept). | |
194 | (A thread's | |
195 | .I effective | |
196 | capability set is always cleared when such a credential change is made, | |
197 | regardless of the setting of the "keep capabilities" flag.) | |
198 | The "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)" | |
202 | Return (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)" | |
206 | Set the process name for the calling process, | |
207 | using the value in the location pointed to by | |
208 | .IR "(char\ *) arg2" . | |
209 | The name can be up to 16 bytes long, | |
210 | .\" TASK_COMM_LEN in include/linux/sched.h | |
bd74a873 | 211 | and should be null-terminated if it contains fewer bytes. |
88989295 MK |
212 | .TP |
213 | .BR PR_GET_NAME " (since Linux 2.6.11)" | |
214 | Return the process name for the calling process, | |
215 | in the buffer pointed to by | |
216 | .IR "(char\ *) arg2" . | |
217 | The buffer should allow space for up to 16 bytes; | |
bd74a873 | 218 | the 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 |
221 | Set the calling process's |
222 | .I no_new_privs | |
223 | bit to the value in | |
224 | .IR arg2 . | |
225 | With | |
226 | .I Ino_new_privs | |
227 | set to 1, | |
228 | .BR execve (2) | |
229 | promises not | |
f83fe154 | 230 | to grant the privilege to do anything that could not have been done |
0fcc276f MK |
231 | without thecw |
232 | .BR execve (2) | |
233 | call (for example, rendering set-user-ID, set-group-ID, and file | |
234 | capabilities non-functional). | |
235 | When enabled, this value is inherited across | |
236 | .BR fork (2), | |
237 | .BR clone (2), | |
238 | and | |
239 | .BR execve (2) | |
240 | and cannot be unset. | |
f83fe154 KC |
241 | .TP |
242 | .BR PR_GET_NO_NEW_PRIVS " (since Linux 3.5)" | |
0fcc276f MK |
243 | Return the value of the |
244 | .I no_new_privs | |
245 | bit for the current process. | |
246 | A value of 0 indicates the regular | |
247 | .BR execve (2) | |
248 | behavior. | |
249 | A value of 1 indicates | |
250 | .BR execve (2) | |
251 | will operate in the privilege restricting mode described above. | |
f83fe154 | 252 | .TP |
88989295 MK |
253 | .BR PR_SET_PDEATHSIG " (since Linux 2.1.57)" |
254 | Set the parent process death signal | |
255 | of the calling process to \fIarg2\fP (either a signal value | |
256 | in the range 1..maxsig, or 0 to clear). | |
257 | This is the signal that the calling process will get when its | |
258 | parent dies. | |
259 | This value is cleared for the child of a | |
c7c7235c MK |
260 | .BR fork (2) |
261 | and (since Linux 2.5.36 / 2.6.23) | |
9a830e62 | 262 | when executing a set-user_ID or set-group-ID binary. |
88989295 MK |
263 | .TP |
264 | .BR PR_GET_PDEATHSIG " (since Linux 2.3.15)" | |
265 | Return the current value of the parent process death signal, | |
266 | in 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 |
273 | Set the secure computing (seccomp) mode for the calling thread, to limit |
274 | the available system calls. | |
34447828 KC |
275 | The seccomp mode is selected via |
276 | .IR arg2 . | |
277 | (The seccomp constants are defined in | |
278 | .IR <linux/seccomp.h> .) | |
279 | ||
280 | With | |
8ab8b43f | 281 | .IR arg2 |
34447828 KC |
282 | set to |
283 | .BR SECCOMP_MODE_STRICT | |
8ab8b43f MK |
284 | the only system calls that the thread is permitted to make are |
285 | .BR read (2), | |
286 | .BR write (2), | |