]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright (C) 1998 Andries Brouwer (aeb@cwi.nl) |
73d3ac53 | 2 | .\" and Copyright (C) 2002, 2006, 2008, 2012, 2013 Michael Kerrisk <mtk.manpages@gmail.com> |
af5f9508 | 3 | .\" and Copyright Guillem Jover <guillem@hadrons.org> |
3cd5e983 | 4 | .\" and Copyright (C) 2014 Dave Hansen / Intel |
fea681da | 5 | .\" |
93015253 | 6 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
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. | |
4b72fb64 | 26 | .\" %%%LICENSE_END |
fea681da MK |
27 | .\" |
28 | .\" Modified Thu Nov 11 04:19:42 MET 1999, aeb: added PR_GET_PDEATHSIG | |
29 | .\" Modified 27 Jun 02, Michael Kerrisk | |
c13182ef | 30 | .\" Added PR_SET_DUMPABLE, PR_GET_DUMPABLE, |
fea681da | 31 | .\" PR_SET_KEEPCAPS, PR_GET_KEEPCAPS |
e87fdd92 MK |
32 | .\" Modified 2006-08-30 Guillem Jover <guillem@hadrons.org> |
33 | .\" Updated Linux versions where the options where introduced. | |
34 | .\" Added PR_SET_TIMING, PR_GET_TIMING, PR_SET_NAME, PR_GET_NAME, | |
35 | .\" PR_SET_UNALIGN, PR_GET_UNALIGN, PR_SET_FPEMU, PR_GET_FPEMU, | |
36 | .\" PR_SET_FPEXC, PR_GET_FPEXC | |
8ab8b43f MK |
37 | .\" 2008-04-29 Serge Hallyn, Document PR_CAPBSET_READ and PR_CAPBSET_DROP |
38 | .\" 2008-06-13 Erik Bosman, <ejbosman@cs.vu.nl> | |
39 | .\" Document PR_GET_TSC and PR_SET_TSC. | |
40 | .\" 2008-06-15 mtk, Document PR_SET_SECCOMP, PR_GET_SECCOMP | |
bc02b3ea | 41 | .\" 2009-10-03 Andi Kleen, document PR_MCE_KILL |
06afe673 | 42 | .\" 2012-04 Cyrill Gorcunov, Document PR_SET_MM |
bc02b3ea MK |
43 | .\" 2012-04-25 Michael Kerrisk, Document PR_TASK_PERF_EVENTS_DISABLE and |
44 | .\" PR_TASK_PERF_EVENTS_ENABLE | |
34447828 | 45 | .\" 2012-09-20 Kees Cook, update PR_SET_SECCOMP for mode 2 |
f83fe154 | 46 | .\" 2012-09-20 Kees Cook, document PR_SET_NO_NEW_PRIVS, PR_GET_NO_NEW_PRIVS |
934487a0 MK |
47 | .\" 2012-10-25 Michael Kerrisk, Document PR_SET_TIMERSLACK and |
48 | .\" PR_GET_TIMERSLACK | |
491b2e75 | 49 | .\" 2013-01-10 Kees Cook, document PR_SET_PTRACER |
31cc8387 | 50 | .\" 2012-02-04 Michael Kerrisk, document PR_{SET,GET}_CHILD_SUBREAPER |
03979794 | 51 | .\" 2014-11-10 Dave Hansen, document PR_MPX_{EN,DIS}ABLE_MANAGEMENT |
fea681da | 52 | .\" |
e14baeeb | 53 | .\" |
8538a62b | 54 | .TH PRCTL 2 2018-02-02 "Linux" "Linux Programmer's Manual" |
fea681da MK |
55 | .SH NAME |
56 | prctl \- operations on a process | |
57 | .SH SYNOPSIS | |
521bf584 | 58 | .nf |
fea681da | 59 | .B #include <sys/prctl.h> |
68e4db0a | 60 | .PP |
521bf584 MK |
61 | .BI "int prctl(int " option ", unsigned long " arg2 ", unsigned long " arg3 , |
62 | .BI " unsigned long " arg4 ", unsigned long " arg5 ); | |
63 | .fi | |
fea681da | 64 | .SH DESCRIPTION |
e511ffb6 | 65 | .BR prctl () |
fea681da | 66 | is called with a first argument describing what to do |
1a329b56 | 67 | (with values defined in \fI<linux/prctl.h>\fP), and further |
c4bb193f | 68 | arguments with a significance depending on the first one. |
fea681da | 69 | The first argument can be: |
03547431 MK |
70 | .\" |
71 | .TP | |
72 | .BR PR_CAP_AMBIENT " (since Linux 4.3)" | |
73 | .\" commit 58319057b7847667f0c9585b9de0e8932b0fdb08 | |
1a52f4f6 MK |
74 | Reads or changes the ambient capability set of the calling thread, |
75 | according to the value of | |
03547431 MK |
76 | .IR arg2 , |
77 | which must be one of the following: | |
78 | .RS | |
79 | .\" | |
80 | .TP | |
81 | .B PR_CAP_AMBIENT_RAISE | |
82 | The capability specified in | |
83 | .I arg3 | |
84 | is added to the ambient set. | |
85 | The specified capability must already be present in | |
86 | both the permitted and the inheritable sets of the process. | |
87 | This operation is not permitted if the | |
88 | .B SECBIT_NO_CAP_AMBIENT_RAISE | |
89 | securebit is set. | |
90 | .TP | |
91 | .B PR_CAP_AMBIENT_LOWER | |
92 | The capability specified in | |
93 | .I arg3 | |
94 | is removed from the ambient set. | |
95 | .TP | |
96 | .B PR_CAP_AMBIENT_IS_SET | |
97 | The | |
bf7bc8b8 | 98 | .BR prctl () |
03547431 MK |
99 | call returns 1 if the capability in |
100 | .I arg3 | |
101 | is in the ambient set and 0 if it is not. | |
102 | .TP | |
103 | .BR PR_CAP_AMBIENT_CLEAR_ALL | |
104 | All capabilities will be removed from the ambient set. | |
105 | This operation requires setting | |
106 | .I arg3 | |
107 | to zero. | |
108 | .RE | |
269e3b97 MK |
109 | .IP |
110 | In all of the above operations, | |
111 | .I arg4 | |
112 | and | |
113 | .I arg5 | |
114 | must be specified as 0. | |
cf086650 MK |
115 | .IP |
116 | Higher-level interfaces layered on top of the above operations are | |
117 | provided in the | |
118 | .BR libcap (3) | |
119 | library in the form of | |
120 | .BR cap_get_ambient (3), | |
121 | .BR cap_set_ambient (3), | |
122 | and | |
123 | .BR cap_reset_ambient (3). | |
fea681da | 124 | .TP |
2e781e20 | 125 | .BR PR_CAPBSET_READ " (since Linux 2.6.25)" |
8ab8b43f MK |
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 | |
2914a14d | 134 | file's permitted capability set on a subsequent call to |
8ab8b43f | 135 | .BR execve (2). |
efeece04 | 136 | .IP |
8ab8b43f MK |
137 | If the capability specified in |
138 | .I arg2 | |
139 | is not valid, then the call fails with the error | |
140 | .BR EINVAL . | |
d9a0d1d7 MK |
141 | .IP |
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). | |
8ab8b43f MK |
146 | .TP |
147 | .BR PR_CAPBSET_DROP " (since Linux 2.6.25)" | |
148 | If the calling thread has the | |
149 | .B CAP_SETPCAP | |
af53fcb5 | 150 | capability within its user namespace, then drop the capability specified by |
8ab8b43f MK |
151 | .I arg2 |
152 | from the calling thread's capability bounding set. | |
153 | Any children of the calling thread will inherit the newly | |
154 | reduced bounding set. | |
efeece04 | 155 | .IP |
8ab8b43f MK |
156 | The call fails with the error: |
157 | .B EPERM | |
2914a14d | 158 | if the calling thread does not have the |
8ab8b43f MK |
159 | .BR CAP_SETPCAP ; |
160 | .BR EINVAL | |
161 | if | |
162 | .I arg2 | |
163 | does not represent a valid capability; or | |
164 | .BR EINVAL | |
165 | if file capabilities are not enabled in the kernel, | |
166 | in which case bounding sets are not supported. | |
d9a0d1d7 MK |
167 | .IP |
168 | A higher-level interface layered on top of this operation is provided in the | |
169 | .BR libcap (3) | |
170 | library in the form of | |
171 | .BR cap_drop_bound (3). | |
73d3ac53 MK |
172 | .TP |
173 | .BR PR_SET_CHILD_SUBREAPER " (since Linux 3.4)" | |
174 | .\" commit ebec18a6d3aa1e7d84aab16225e87fd25170ec2b | |
175 | If | |
176 | .I arg2 | |
177 | is nonzero, | |
178 | set the "child subreaper" attribute of the calling process; | |
179 | if | |
180 | .I arg2 | |
181 | is zero, unset the attribute. | |
efeece04 | 182 | .IP |
fbc63931 | 183 | A subreaper fulfills the role of |
73d3ac53 MK |
184 | .BR init (1) |
185 | for its descendant processes. | |
fbc63931 MK |
186 | When a process becomes orphaned |
187 | (i.e., its immediate parent terminates) | |
188 | then that process will be reparented to | |
189 | the nearest still living ancestor subreaper. | |
190 | Subsequently, calls to | |
191 | .BR getppid () | |
192 | in the orphaned process will now return the PID of the subreaper process, | |
193 | and when the orphan terminates, it is the subreaper process that | |
73d3ac53 MK |
194 | will receive a |
195 | .BR SIGCHLD | |
1a8e1c2f | 196 | signal and will be able to |
73d3ac53 MK |
197 | .BR wait (2) |
198 | on the process to discover its termination status. | |
efeece04 | 199 | .IP |
d59a7572 MK |
200 | The setting of this bit is not inherited by children created by |
201 | .BR fork (2) | |
202 | and | |
203 | .BR clone (2). | |
204 | The setting is preserved across | |
205 | .BR execve (2). | |
efeece04 | 206 | .IP |
94e460d4 MK |
207 | Establishing a subreaper process is useful in session management frameworks |
208 | where a hierarchical group of processes is managed by a subreaper process | |
209 | that needs to be informed when one of the processes\(emfor example, | |
210 | a double-forked daemon\(emterminates | |
211 | (perhaps so that it can restart that process). | |
212 | Some | |
213 | .BR init (1) | |
214 | frameworks (e.g., | |
215 | .BR systemd (1)) | |
216 | employ a subreaper process for similar reasons. | |
73d3ac53 MK |
217 | .TP |
218 | .BR PR_GET_CHILD_SUBREAPER " (since Linux 3.4)" | |
219 | Return the "child subreaper" setting of the caller, | |
220 | in the location pointed to by | |
221 | .IR "(int\ *) arg2" . | |
8ab8b43f | 222 | .TP |
88989295 | 223 | .BR PR_SET_DUMPABLE " (since Linux 2.3.20)" |
2d7fc98d MK |
224 | Set the state of the "dumpable" flag, |
225 | which determines whether core dumps are produced for the calling process | |
226 | upon delivery of a signal whose default behavior is to produce a core dump. | |
efeece04 | 227 | .IP |
88989295 | 228 | In kernels up to and including 2.6.12, |
8ab8b43f | 229 | .I arg2 |
8aad30d7 MK |
230 | must be either 0 |
231 | .RB ( SUID_DUMP_DISABLE , | |
232 | process is not dumpable) or 1 | |
233 | .RB ( SUID_DUMP_USER , | |
234 | process is dumpable). | |
0de51ed1 MK |
235 | Between kernels 2.6.13 and 2.6.17, |
236 | .\" commit abf75a5033d4da7b8a7e92321d74021d1fcfb502 | |
237 | the value 2 was also permitted, | |
88989295 MK |
238 | which caused any binary which normally would not be dumped |
239 | to be dumped readable by root only; | |
240 | for security reasons, this feature has been removed. | |
241 | .\" See http://marc.theaimsgroup.com/?l=linux-kernel&m=115270289030630&w=2 | |
242 | .\" Subject: Fix prctl privilege escalation (CVE-2006-2451) | |
243 | .\" From: Marcel Holtmann <marcel () holtmann ! org> | |
244 | .\" Date: 2006-07-12 11:12:00 | |
245 | (See also the description of | |
2d7fc98d | 246 | .I /proc/sys/fs/\:suid_dumpable |
88989295 MK |
247 | in |
248 | .BR proc (5).) | |
efeece04 | 249 | .IP |
2d7fc98d MK |
250 | Normally, this flag is set to 1. |
251 | However, it is reset to the current value contained in the file | |
252 | .IR /proc/sys/fs/\:suid_dumpable | |
253 | (which by default has the value 0), | |
a644bc48 | 254 | in the following circumstances: |
2d7fc98d MK |
255 | .\" See kernel/cred.c::commit_creds() (Linux 3.18 sources) |
256 | .RS | |
41f90bb7 | 257 | .IP * 3 |
a644bc48 | 258 | The process's effective user or group ID is changed. |
2d7fc98d | 259 | .IP * |
a644bc48 | 260 | The process's filesystem user or group ID is changed (see |
2d7fc98d MK |
261 | .BR credentials (7)). |
262 | .IP * | |
a644bc48 | 263 | The process executes |
2d7fc98d | 264 | .RB ( execve (2)) |
41f90bb7 MK |
265 | a set-user-ID or set-group-ID program, resulting in a change |
266 | of either the effective user ID or the effective group ID. | |
27ce08bf KF |
267 | .IP * |
268 | The process executes | |
269 | .RB ( execve (2)) | |
270 | a program that has file capabilities (see | |
271 | .BR capabilities (7)), | |
41f90bb7 | 272 | .\" See kernel/cred.c::commit_creds() |
27ce08bf | 273 | but only if the permitted capabilities |
41f90bb7 | 274 | gained exceed those already permitted for the process. |
5d28ea3e | 275 | .\" Also certain namespace operations; |
2d7fc98d MK |
276 | .RE |
277 | .IP | |
cadcf1b1 | 278 | Processes that are not dumpable can not be attached via |
6fdbc779 | 279 | .BR ptrace (2) |
982d8cf7 MK |
280 | .BR PTRACE_ATTACH ; |
281 | see | |
282 | .BR ptrace (2) | |
283 | for further details. | |
efeece04 | 284 | .IP |
161946a2 MK |
285 | If a process is not dumpable, |
286 | the ownership of files in the process's | |
287 | .IR /proc/[pid] | |
288 | directory is affected as described in | |
289 | .BR proc (5). | |
64536a1b | 290 | .TP |
88989295 MK |
291 | .BR PR_GET_DUMPABLE " (since Linux 2.3.20)" |
292 | Return (as the function result) the current state of the calling | |
293 | process's dumpable flag. | |
294 | .\" Since Linux 2.6.13, the dumpable flag can have the value 2, | |
295 | .\" but in 2.6.13 PR_GET_DUMPABLE simply returns 1 if the dumpable | |
c7094399 | 296 | .\" flags has a nonzero value. This was fixed in 2.6.14. |
64536a1b | 297 | .TP |
8ab8b43f | 298 | .BR PR_SET_ENDIAN " (since Linux 2.6.18, PowerPC only)" |
c13182ef | 299 | Set the endian-ness of the calling process to the value given |
64536a1b | 300 | in \fIarg2\fP, which should be one of the following: |
8ab8b43f | 301 | .\" Respectively 0, 1, 2 |
64536a1b MK |
302 | .BR PR_ENDIAN_BIG , |
303 | .BR PR_ENDIAN_LITTLE , | |
304 | or | |
0daa9e92 | 305 | .B PR_ENDIAN_PPC_LITTLE |
64536a1b | 306 | (PowerPC pseudo little endian). |
e87fdd92 | 307 | .TP |
8ab8b43f MK |
308 | .BR PR_GET_ENDIAN " (since Linux 2.6.18, PowerPC only)" |
309 | Return the endian-ness of the calling process, | |
310 | in the location pointed to by | |
311 | .IR "(int\ *) arg2" . | |
64a53a67 ES |
312 | .TP |
313 | .BR PR_SET_FP_MODE " (since Linux 4.0, only on MIPS)" | |
89507305 MK |
314 | .\" commit 9791554b45a2acc28247f66a5fd5bbc212a6b8c8 |
315 | On the MIPS architecture, | |
316 | user-space code can be built using an ABI which permits linking | |
317 | with code that has more restrictive floating-point (FP) requirements. | |
318 | For example, user-space code may be built to target the O32 FPXX ABI | |
b3073df8 | 319 | and linked with code built for either one of the more restrictive |
89507305 | 320 | FP32 or FP64 ABIs. |
b3073df8 | 321 | When more restrictive code is linked in, |
89507305 MK |
322 | the overall requirement for the process is to use the more |
323 | restrictive floating-point mode. | |
efeece04 | 324 | .IP |
07d6076e | 325 | Because the kernel has no means of knowing in advance |
89507305 | 326 | which mode the process should be executed in, |
07d6076e MK |
327 | and because these restrictions can |
328 | change over the lifetime of the process, the | |
329 | .B PR_SET_FP_MODE | |
330 | operation is provided to allow control of the floating-point mode | |
331 | from user space. | |
efeece04 | 332 | .IP |
64a53a67 ES |
333 | .\" https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking |
334 | The | |
335 | .I (unsigned int) arg2 | |
89507305 | 336 | argument is a bit mask describing the floating-point mode used: |
64a53a67 ES |
337 | .RS |
338 | .TP | |
fb90e0c7 | 339 | .BR PR_FP_MODE_FR |
64a53a67 ES |
340 | When this bit is |
341 | .I unset | |
342 | (so called | |
343 | .BR FR=0 " or " FR0 | |
41a926bf MK |
344 | mode), the 32 floating-point registers are 32 bits wide, |
345 | and 64-bit registers are represented as a pair of registers | |
b3073df8 | 346 | (even- and odd- numbered, |
89507305 MK |
347 | with the even-numbered register containing the lower 32 bits, |
348 | and the odd-numbered register containing the higher 32 bits). | |
efeece04 | 349 | .IP |
64a53a67 ES |
350 | When this bit is |
351 | .I set | |
07d6076e | 352 | (on supported hardware), |
41a926bf | 353 | the 32 floating-point registers are 64 bits wide (so called |
64a53a67 | 354 | .BR FR=1 " or " FR1 |
89507305 | 355 | mode). |
b3073df8 | 356 | Note that modern MIPS implementations (MIPS R6 and newer) support |
64a53a67 ES |
357 | .B FR=1 |
358 | mode only. | |
efeece04 MK |
359 | .IP |
360 | .IP | |
89507305 | 361 | Applications that use the O32 FP32 ABI can operate only when this bit is |
64a53a67 ES |
362 | .I unset |
363 | .RB ( FR=0 ; | |
364 | or they can be used with FRE enabled, see below). | |
89507305 MK |
365 | Applications that use the O32 FP64 ABI |
366 | (and the O32 FP64A ABI, which exists to | |
367 | provide the ability to operate with existing FP32 code; see below) | |
368 | can operate only when this bit is | |
64a53a67 ES |
369 | .I set |
370 | .RB ( FR=1 ). | |
ffb0dafc | 371 | Applications that use the O32 FPXX ABI can operate with either |
07d6076e MK |
372 | .BR FR=0 |
373 | or | |
374 | .BR FR=1 . | |
64a53a67 | 375 | .TP |
fb90e0c7 | 376 | .BR PR_FP_MODE_FRE |
07d6076e | 377 | Enable emulation of 32-bit floating-point mode. |
b3073df8 | 378 | When this mode is enabled, |
07d6076e MK |
379 | it emulates 32-bit floating-point operations |
380 | by raising a reserved-instruction exception | |
b3073df8 | 381 | on every instruction that uses 32-bit formats and |
89507305 MK |
382 | the kernel then handles the instruction in software. |
383 | (The problem lies in the discrepancy of handling odd-numbered registers | |
384 | which are the high 32 bits of 64-bit registers with even numbers in | |
64a53a67 | 385 | .B FR=0 |
89507305 | 386 | mode and the lower 32-bit parts of odd-numbered 64-bit registers in |
64a53a67 | 387 | .B FR=1 |
89507305 MK |
388 | mode.) |
389 | Enabling this bit is necessary when code with the O32 FP32 ABI should operate | |
390 | with code with compatible the O32 FPXX or O32 FP64A ABIs (which require | |
64a53a67 | 391 | .B FR=1 |
b3073df8 MK |
392 | FPU mode) or when it is executed on newer hardware (MIPS R6 onwards) |
393 | which lacks | |
64a53a67 | 394 | .B FR=0 |
89507305 | 395 | mode support when a binary with the FP32 ABI is used. |
64a53a67 | 396 | .IP |
89507305 MK |
397 | Note that this mode makes sense only when the FPU is in 64-bit mode |
398 | .RB ( FR=1 ). | |
64a53a67 | 399 | .IP |
89507305 | 400 | Note that the use of emulation inherently has a significant performance hit |
b3073df8 | 401 | and should be avoided if possible. |
64a53a67 ES |
402 | .RE |
403 | .IP | |
07d6076e MK |
404 | In the N32/N64 ABI, 64-bit floating-point mode is always used, |
405 | so FPU emulation is not required and the FPU always operates in | |
64a53a67 ES |
406 | .B FR=1 |
407 | mode. | |
408 | .IP | |
07d6076e MK |
409 | This option is mainly intended for use by the dynamic linker |
410 | .RB ( ld.so (8)). | |
64a53a67 | 411 | .IP |
89507305 MK |
412 | The arguments |
413 | .IR arg3 , | |
414 | .IR arg4 , | |
415 | and | |
416 | .IR arg5 | |
64a53a67 ES |
417 | are ignored. |
418 | .TP | |
419 | .BR PR_GET_FP_MODE " (since Linux 4.0, only on MIPS)" | |
89507305 | 420 | Get the current floating-point mode (see the description of |
64a53a67 ES |
421 | .B PR_SET_FP_MODE |
422 | for details). | |
efeece04 | 423 | .IP |
89507305 | 424 | On success, |
07d6076e | 425 | the call returns a bit mask which represents the current floating-point mode. |
efeece04 | 426 | .IP |
89507305 MK |
427 | The arguments |
428 | .IR arg2 , | |
429 | .IR arg3 , | |
430 | .IR arg4 , | |
431 | and | |
432 | .IR arg5 | |
64a53a67 | 433 | are ignored. |
8ab8b43f | 434 | .TP |
8ab8b43f | 435 | .BR PR_SET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)" |
e87fdd92 | 436 | Set floating-point emulation control bits to \fIarg2\fP. |
7626d2ce MK |
437 | Pass |
438 | .B PR_FPEMU_NOPRINT | |
439 | to silently emulate floating-point operation accesses, or | |
440 | .B PR_FPEMU_SIGFPE | |
441 | to not emulate floating-point operations and send | |
8bd58774 MK |
442 | .B SIGFPE |
443 | instead. | |
e87fdd92 | 444 | .TP |
8ab8b43f MK |
445 | .BR PR_GET_FPEMU " (since Linux 2.4.18, 2.5.9, only on ia64)" |
446 | Return floating-point emulation control bits, | |
447 | in the location pointed to by | |
448 | .IR "(int\ *) arg2" . | |
e87fdd92 | 449 | .TP |
8ab8b43f | 450 | .BR PR_SET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)" |
1c44bd5b MK |
451 | Set floating-point exception mode to \fIarg2\fP. |
452 | Pass \fBPR_FP_EXC_SW_ENABLE\fP to use FPEXC for FP exception enables, | |
c45bd688 MK |
453 | \fBPR_FP_EXC_DIV\fP for floating-point divide by zero, |
454 | \fBPR_FP_EXC_OVF\fP for floating-point overflow, | |
455 | \fBPR_FP_EXC_UND\fP for floating-point underflow, | |
456 | \fBPR_FP_EXC_RES\fP for floating-point inexact result, | |
457 | \fBPR_FP_EXC_INV\fP for floating-point invalid operation, | |
e87fdd92 | 458 | \fBPR_FP_EXC_DISABLED\fP for FP exceptions disabled, |
b28f6e56 | 459 | \fBPR_FP_EXC_NONRECOV\fP for async nonrecoverable exception mode, |
e87fdd92 MK |
460 | \fBPR_FP_EXC_ASYNC\fP for async recoverable exception mode, |
461 | \fBPR_FP_EXC_PRECISE\fP for precise exception mode. | |
462 | .TP | |
8ab8b43f MK |
463 | .BR PR_GET_FPEXC " (since Linux 2.4.21, 2.5.32, only on PowerPC)" |
464 | Return floating-point exception mode, | |
465 | in the location pointed to by | |
466 | .IR "(int\ *) arg2" . | |
467 | .TP | |
88989295 | 468 | .BR PR_SET_KEEPCAPS " (since Linux 2.2.18)" |
03361448 MK |
469 | Set the state of the calling thread's "keep capabilities" flag. |
470 | The effect if this flag is described in | |
471 | .BR capabilities (7). | |
88989295 | 472 | .I arg2 |
03361448 MK |
473 | must be either 0 (clear the flag) |
474 | or 1 (set the flag). | |
028cb080 | 475 | The "keep capabilities" value will be reset to 0 on subsequent calls to |
88989295 MK |
476 | .BR execve (2). |
477 | .TP | |
478 | .BR PR_GET_KEEPCAPS " (since Linux 2.2.18)" | |
88ee5c1c | 479 | Return (as the function result) the current state of the calling thread's |
88989295 | 480 | "keep capabilities" flag. |
03361448 MK |
481 | See |
482 | .BR capabilities (7) | |
483 | for a description of this flag. | |
88989295 | 484 | .TP |
03547431 | 485 | .BR PR_MCE_KILL " (since Linux 2.6.32)" |
eb359b3e | 486 | Set the machine check memory corruption kill policy for the calling thread. |
03547431 MK |
487 | If |
488 | .I arg2 | |
489 | is | |
490 | .BR PR_MCE_KILL_CLEAR , | |
491 | clear the thread memory corruption kill policy and use the system-wide default. | |
492 | (The system-wide default is defined by | |
493 | .IR /proc/sys/vm/memory_failure_early_kill ; | |
494 | see | |
495 | .BR proc (5).) | |
496 | If | |
497 | .I arg2 | |
498 | is | |
499 | .BR PR_MCE_KILL_SET , | |
500 | use a thread-specific memory corruption kill policy. | |
501 | In this case, | |
502 | .I arg3 | |
503 | defines whether the policy is | |
504 | .I early kill | |
505 | .RB ( PR_MCE_KILL_EARLY ), | |
506 | .I late kill | |
507 | .RB ( PR_MCE_KILL_LATE ), | |
508 | or the system-wide default | |
509 | .RB ( PR_MCE_KILL_DEFAULT ). | |
510 | Early kill means that the thread receives a | |
511 | .B SIGBUS | |
512 | signal as soon as hardware memory corruption is detected inside | |
513 | its address space. | |
514 | In late kill mode, the process is killed only when it accesses a corrupted page. | |
515 | See | |
516 | .BR sigaction (2) | |
517 | for more information on the | |
518 | .BR SIGBUS | |
519 | signal. | |
520 | The policy is inherited by children. | |
521 | The remaining unused | |
522 | .BR prctl () | |
523 | arguments must be zero for future compatibility. | |
88989295 | 524 | .TP |
03547431 MK |
525 | .BR PR_MCE_KILL_GET " (since Linux 2.6.32)" |
526 | Return the current per-process machine check kill policy. | |
527 | All unused | |
528 | .BR prctl () | |
529 | arguments must be zero. | |
88989295 | 530 | .TP |
03547431 MK |
531 | .BR PR_SET_MM " (since Linux 3.3)" |
532 | .\" commit 028ee4be34a09a6d48bdf30ab991ae933a7bc036 | |
533 | Modify certain kernel memory map descriptor fields | |
534 | of the calling process. | |
535 | Usually these fields are set by the kernel and dynamic loader (see | |
536 | .BR ld.so (8) | |
537 | for more information) and a regular application should not use this feature. | |
538 | However, there are cases, such as self-modifying programs, | |
539 | where a program might find it useful to change its own memory map. | |
efeece04 | 540 | .IP |
03547431 MK |
541 | The calling process must have the |
542 | .BR CAP_SYS_RESOURCE | |
543 | capability. | |
544 | The value in | |
545 | .I arg2 | |
546 | is one of the options below, while | |
547 | .I arg3 | |
548 | provides a new value for the option. | |
a87d0921 MF |
549 | The |
550 | .I arg4 | |
551 | and | |
552 | .I arg5 | |
553 | arguments must be zero if unused. | |
efeece04 | 554 | .IP |
261c7e1d | 555 | Before Linux 3.10, |
d2eeb68f | 556 | .\" commit 52b3694157e3aa6df871e283115652ec6f2d31e0 |
261c7e1d MF |
557 | this feature is available only if the kernel is built with the |
558 | .BR CONFIG_CHECKPOINT_RESTORE | |
559 | option enabled. | |
03547431 MK |
560 | .RS |
561 | .TP | |
562 | .BR PR_SET_MM_START_CODE | |
563 | Set the address above which the program text can run. | |
564 | The corresponding memory area must be readable and executable, | |
997d21e1 | 565 | but not writable or shareable (see |
03547431 | 566 | .BR mprotect (2) |
0fcc276f | 567 | and |
03547431 MK |
568 | .BR mmap (2) |
569 | for more information). | |
f83fe154 | 570 | .TP |
03547431 MK |
571 | .BR PR_SET_MM_END_CODE |
572 | Set the address below which the program text can run. | |
573 | The corresponding memory area must be readable and executable, | |
997d21e1 | 574 | but not writable or shareable. |
f83fe154 | 575 | .TP |
03547431 MK |
576 | .BR PR_SET_MM_START_DATA |
577 | Set the address above which initialized and | |
578 | uninitialized (bss) data are placed. | |
579 | The corresponding memory area must be readable and writable, | |
997d21e1 | 580 | but not executable or shareable. |
88989295 | 581 | .TP |
03547431 MK |
582 | .B PR_SET_MM_END_DATA |
583 | Set the address below which initialized and | |
584 | uninitialized (bss) data are placed. | |
585 | The corresponding memory area must be readable and writable, | |
997d21e1 | 586 | but not executable or shareable. |
88989295 | 587 | .TP |
03547431 MK |
588 | .BR PR_SET_MM_START_STACK |
589 | Set the start address of the stack. | |
590 | The corresponding memory area must be readable and writable. | |
491b2e75 | 591 | .TP |
03547431 MK |
592 | .BR PR_SET_MM_START_BRK |
593 | Set the address above which the program heap can be expanded with | |
594 | .BR brk (2) | |
595 | call. | |
596 | The address must be greater than the ending address of | |
597 | the current program data segment. | |
598 | In addition, the combined size of the resulting heap and | |
599 | the size of the data segment can't exceed the | |
600 | .BR RLIMIT_DATA | |
601 | resource limit (see | |
602 | .BR setrlimit (2)). | |
603 | .TP | |
604 | .BR PR_SET_MM_BRK | |
605 | Set the current | |
606 | .BR brk (2) | |
607 | value. | |
608 | The requirements for the address are the same as for the | |
609 | .BR PR_SET_MM_START_BRK | |
610 | option. | |
11ac5b51 | 611 | .PP |
03547431 MK |
612 | The following options are available since Linux 3.5. |
613 | .\" commit fe8c7f5cbf91124987106faa3bdf0c8b955c4cf7 | |
614 | .TP | |
615 | .BR PR_SET_MM_ARG_START | |
616 | Set the address above which the program command line is placed. | |
617 | .TP | |
618 | .BR PR_SET_MM_ARG_END | |
619 | Set the address below which the program command line is placed. | |
620 | .TP | |
621 | .BR PR_SET_MM_ENV_START | |
622 | Set the address above which the program environment is placed. | |
623 | .TP | |
624 | .BR PR_SET_MM_ENV_END | |
625 | Set the address below which the program environment is placed. | |
626 | .IP | |
627 | The address passed with | |
628 | .BR PR_SET_MM_ARG_START , | |
629 | .BR PR_SET_MM_ARG_END , | |
630 | .BR PR_SET_MM_ENV_START , | |
631 | and | |
632 | .BR PR_SET_MM_ENV_END | |
633 | should belong to a process stack area. | |
634 | Thus, the corresponding memory area must be readable, writable, and | |
635 | (depending on the kernel configuration) have the | |
636 | .BR MAP_GROWSDOWN | |
637 | attribute set (see | |
638 | .BR mmap (2)). | |
639 | .TP | |
640 | .BR PR_SET_MM_AUXV | |
641 | Set a new auxiliary vector. | |
642 | The | |
643 | .I arg3 | |
644 | argument should provide the address of the vector. | |
645 | The | |
646 | .I arg4 | |
647 | is the size of the vector. | |
648 | .TP | |
649 | .BR PR_SET_MM_EXE_FILE | |
650 | .\" commit b32dfe377102ce668775f8b6b1461f7ad428f8b6 | |
651 | Supersede the | |
652 | .IR /proc/pid/exe | |
653 | symbolic link with a new one pointing to a new executable file | |
654 | identified by the file descriptor provided in | |
655 | .I arg3 | |
656 | argument. | |
657 | The file descriptor should be obtained with a regular | |
658 | .BR open (2) | |
659 | call. | |
660 | .IP | |
661 | To change the symbolic link, one needs to unmap all existing | |
662 | executable memory areas, including those created by the kernel itself | |
663 | (for example the kernel usually creates at least one executable | |
664 | memory area for the ELF | |
665 | .IR \.text | |
666 | section). | |
667 | .IP | |
642df17c | 668 | In Linux 4.9 and earlier, the |
47bc9cec | 669 | .\" commit 3fb4afd9a504c2386b8435028d43283216bf588e |
47bc9cec | 670 | .BR PR_SET_MM_EXE_FILE |
642df17c MK |
671 | operation can be performed only once in a process's lifetime; |
672 | attempting to perform the operation a second time results in the error | |
673 | .BR EPERM . | |
674 | This restriction was enforced for security reasons that were subsequently | |
675 | deemed specious, | |
676 | and the restriction was removed in Linux 4.10 because some | |
677 | user-space applications needed to perform this operation more than once. | |
11ac5b51 | 678 | .PP |
7e3236a5 MF |
679 | The following options are available since Linux 3.18. |
680 | .\" commit f606b77f1a9e362451aca8f81d8f36a3a112139e | |
681 | .TP | |
682 | .BR PR_SET_MM_MAP | |
683 | Provides one-shot access to all the addresses by passing in a | |
684 | .I struct prctl_mm_map | |
685 | (as defined in \fI<linux/prctl.h>\fP). | |
686 | The | |
687 | .I arg4 | |
688 | argument should provide the size of the struct. | |
efeece04 | 689 | .IP |
7e3236a5 MF |
690 | This feature is available only if the kernel is built with the |
691 | .BR CONFIG_CHECKPOINT_RESTORE | |
692 | option enabled. | |
693 | .TP | |
694 | .BR PR_SET_MM_MAP_SIZE | |
695 | Returns the size of the | |
696 | .I struct prctl_mm_map | |
697 | the kernel expects. | |
698 | This allows user space to find a compatible struct. | |
699 | The | |
700 | .I arg4 | |
701 | argument should be a pointer to an unsigned int. | |
efeece04 | 702 | .IP |
7e3236a5 MF |
703 | This feature is available only if the kernel is built with the |
704 | .BR CONFIG_CHECKPOINT_RESTORE | |
705 | option enabled. | |
03547431 MK |
706 | .RE |
707 | .TP | |
708 | .BR PR_MPX_ENABLE_MANAGEMENT ", " PR_MPX_DISABLE_MANAGEMENT " (since Linux 3.19) " | |
709 | .\" commit fe3d197f84319d3bce379a9c0dc17b1f48ad358c | |
710 | .\" See also http://lwn.net/Articles/582712/ | |
711 | .\" See also https://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler | |
712 | Enable or disable kernel management of Memory Protection eXtensions (MPX) | |
713 | bounds tables. | |
714 | The | |
715 | .IR arg2 , | |
716 | .IR arg3 , | |
717 | .IR arg4 , | |
718 | and | |
719 | .IR arg5 | |
720 | .\" commit e9d1b4f3c60997fe197bf0243cb4a41a44387a88 | |
721 | arguments must be zero. | |
efeece04 | 722 | .IP |
03547431 MK |
723 | MPX is a hardware-assisted mechanism for performing bounds checking on |
724 | pointers. | |
725 | It consists of a set of registers storing bounds information | |
726 | and a set of special instruction prefixes that tell the CPU on which | |
727 | instructions it should do bounds enforcement. | |
728 | There is a limited number of these registers and | |
729 | when there are more pointers than registers, | |
730 | their contents must be "spilled" into a set of tables. | |
731 | These tables are called "bounds tables" and the MPX | |
732 | .BR prctl () | |
733 | operations control | |
734 | whether the kernel manages their allocation and freeing. | |
efeece04 | 735 | .IP |
03547431 MK |
736 | When management is enabled, the kernel will take over allocation |
737 | and freeing of the bounds tables. | |
738 | It does this by trapping the #BR exceptions that result | |
739 | at first use of missing bounds tables and | |
740 | instead of delivering the exception to user space, | |
741 | it allocates the table and populates the bounds directory | |
742 | with the location of the new table. | |
743 | For freeing, the kernel checks to see if bounds tables are | |
744 | present for memory which is not allocated, and frees them if so. | |
efeece04 | 745 | .IP |
03547431 MK |
746 | Before enabling MPX management using |
747 | .BR PR_MPX_ENABLE_MANAGEMENT , | |
748 | the application must first have allocated a user-space buffer for | |
749 | the bounds directory and placed the location of that directory in the | |
750 | .I bndcfgu | |
751 | register. | |
efeece04 | 752 | .IP |
a23d8efa | 753 | These calls fail if the CPU or kernel does not support MPX. |
03547431 MK |
754 | Kernel support for MPX is enabled via the |
755 | .BR CONFIG_X86_INTEL_MPX | |
756 | configuration option. | |
757 | You can check whether the CPU supports MPX by looking for the 'mpx' | |
758 | CPUID bit, like with the following command: | |
efeece04 | 759 | .IP |
03547431 | 760 | cat /proc/cpuinfo | grep ' mpx ' |
efeece04 | 761 | .IP |
03547431 MK |
762 | A thread may not switch in or out of long (64-bit) mode while MPX is |
763 | enabled. | |
efeece04 | 764 | .IP |
03547431 | 765 | All threads in a process are affected by these calls. |
efeece04 | 766 | .IP |
03547431 MK |
767 | The child of a |
768 | .BR fork (2) | |
769 | inherits the state of MPX management. | |
770 | During | |
771 | .BR execve (2), | |
772 | MPX management is reset to a state as if | |
773 | .BR PR_MPX_DISABLE_MANAGEMENT | |
774 | had been called. | |
efeece04 | 775 | .IP |
03547431 MK |
776 | For further information on Intel MPX, see the kernel source file |
777 | .IR Documentation/x86/intel_mpx.txt . | |
778 | .TP | |
779 | .BR PR_SET_NAME " (since Linux 2.6.9)" | |
780 | Set the name of the calling thread, | |
781 | using the value in the location pointed to by | |
782 | .IR "(char\ *) arg2" . | |
783 | The name can be up to 16 bytes long, | |
784 | .\" TASK_COMM_LEN in include/linux/sched.h | |
785 | including the terminating null byte. | |
786 | (If the length of the string, including the terminating null byte, | |
787 | exceeds 16 bytes, the string is silently truncated.) | |
788 | This is the same attribute that can be set via | |
789 | .BR pthread_setname_np (3) | |
790 | and retrieved using | |
791 | .BR pthread_getname_np (3). | |
792 | The attribute is likewise accessible via | |
793 | .IR /proc/self/task/[tid]/comm , | |
794 | where | |
795 | .I tid | |
796 | is the name of the calling thread. | |
797 | .TP | |
798 | .BR PR_GET_NAME " (since Linux 2.6.11)" | |
799 | Return the name of the calling thread, | |
800 | in the buffer pointed to by | |
801 | .IR "(char\ *) arg2" . | |
802 | The buffer should allow space for up to 16 bytes; | |
803 | the returned string will be null-terminated. | |
804 | .TP | |
805 | .BR PR_SET_NO_NEW_PRIVS " (since Linux 3.5)" | |
40dfb5ba | 806 | Set the calling thread's |
03547431 MK |
807 | .I no_new_privs |
808 | bit to the value in | |
809 | .IR arg2 . | |
810 | With | |
811 | .I no_new_privs | |
812 | set to 1, | |
813 | .BR execve (2) | |
814 | promises not to grant privileges to do anything | |
815 | that could not have been done without the | |
816 | .BR execve (2) | |
817 | call (for example, | |
818 | rendering the set-user-ID and set-group-ID mode bits, | |
819 | and file capabilities non-functional). | |
820 | Once set, this bit cannot be unset. | |
821 | The setting of this bit is inherited by children created by | |
822 | .BR fork (2) | |
823 | and | |
824 | .BR clone (2), | |
825 | and preserved across | |
826 | .BR execve (2). | |
efeece04 | 827 | .IP |
c70fea6e MK |
828 | Since Linux 4.10, |
829 | the value of a thread's | |
830 | .I no_new_privs | |
831 | bit can be viewed via the | |
832 | .I NoNewPrivs | |
833 | field in the | |
834 | .IR /proc/[pid]/status | |
835 | file. | |
efeece04 | 836 | .IP |
03547431 | 837 | For more information, see the kernel source file |
a84a5830 ES |
838 | .IR Documentation/userspace\-api/no_new_privs.rst |
839 | .\" commit 40fde647ccb0ae8c11d256d271e24d385eed595b | |
840 | (or | |
841 | .IR Documentation/prctl/no_new_privs.txt | |
842 | before Linux 4.13). | |
4d850396 MK |
843 | See also |
844 | .BR seccomp (2). | |
03547431 MK |
845 | .TP |
846 | .BR PR_GET_NO_NEW_PRIVS " (since Linux 3.5)" | |
847 | Return (as the function result) the value of the | |
848 | .I no_new_privs | |
40dfb5ba | 849 | bit for the calling thread. |
03547431 MK |
850 | A value of 0 indicates the regular |
851 | .BR execve (2) | |
852 | behavior. | |
853 | A value of 1 indicates | |
854 | .BR execve (2) | |
855 | will operate in the privilege-restricting mode described above. | |
856 | .TP | |
857 | .BR PR_SET_PDEATHSIG " (since Linux 2.1.57)" | |
858 | Set the parent death signal | |
859 | of the calling process to \fIarg2\fP (either a signal value | |
860 | in the range 1..maxsig, or 0 to clear). | |
861 | This is the signal that the calling process will get when its | |
862 | parent dies. | |
c5236575 | 863 | .IP |
03547431 MK |
864 | This value is cleared for the child of a |
865 | .BR fork (2) | |
866 | and (since Linux 2.4.36 / 2.6.23) | |
867 | when executing a set-user-ID or set-group-ID binary, | |
868 | or a binary that has associated capabilities (see | |
869 | .BR capabilities (7)). | |
870 | This value is preserved across | |
871 | .BR execve (2). | |
efeece04 | 872 | .IP |
03547431 MK |
873 | .IR Warning : |
874 | .\" https://bugzilla.kernel.org/show_bug.cgi?id=43300 | |
875 | the "parent" in this case is considered to be the | |
876 | .I thread | |
877 | that created this process. | |
878 | In other words, the signal will be sent when that thread terminates | |
879 | (via, for example, | |
880 | .BR pthread_exit (3)), | |
881 | rather than after all of the threads in the parent process terminate. | |
882 | .TP | |
883 | .BR PR_GET_PDEATHSIG " (since Linux 2.3.15)" | |
884 | Return the current value of the parent process death signal, | |
885 | in the location pointed to by | |
886 | .IR "(int\ *) arg2" . | |
887 | .TP | |
888 | .BR PR_SET_PTRACER " (since Linux 3.4)" | |
889 | .\" commit 2d514487faf188938a4ee4fb3464eeecfbdcf8eb | |
890 | .\" commit bf06189e4d14641c0148bea16e9dd24943862215 | |
891 | This is meaningful only when the Yama LSM is enabled and in mode 1 | |
892 | ("restricted ptrace", visible via | |
893 | .IR /proc/sys/kernel/yama/ptrace_scope ). | |
894 | When a "ptracer process ID" is passed in \fIarg2\fP, | |
895 | the caller is declaring that the ptracer process can | |
896 | .BR ptrace (2) | |
897 | the calling process as if it were a direct process ancestor. | |
898 | Each | |
899 | .B PR_SET_PTRACER | |
900 | operation replaces the previous "ptracer process ID". | |
901 | Employing | |
902 | .B PR_SET_PTRACER | |
903 | with | |
904 | .I arg2 | |
905 | set to 0 clears the caller's "ptracer process ID". | |
906 | If | |
907 | .I arg2 | |
908 | is | |
909 | .BR PR_SET_PTRACER_ANY , | |
910 | the ptrace restrictions introduced by Yama are effectively disabled for the | |
911 | calling process. | |
efeece04 | 912 | .IP |
03547431 | 913 | For further information, see the kernel source file |
6744a500 ES |
914 | .IR Documentation/admin\-guide/LSM/Yama.rst |
915 | .\" commit 90bb766440f2147486a2acc3e793d7b8348b0c22 | |
916 | (or | |
917 | .IR Documentation/security/Yama.txt | |
918 | before Linux 4.13). | |
03547431 MK |
919 | .TP |
920 | .BR PR_SET_SECCOMP " (since Linux 2.6.23)" | |
921 | .\" See http://thread.gmane.org/gmane.linux.kernel/542632 | |
922 | .\" [PATCH 0 of 2] seccomp updates | |
923 | .\" andrea@cpushare.com | |
924 | Set the secure computing (seccomp) mode for the calling thread, to limit | |
925 | the available system calls. | |
926 | The more recent | |
927 | .BR seccomp (2) | |
928 | system call provides a superset of the functionality of | |
929 | .BR PR_SET_SECCOMP . | |
efeece04 | 930 | .IP |
03547431 MK |
931 | The seccomp mode is selected via |
932 | .IR arg2 . | |
933 | (The seccomp constants are defined in | |
934 | .IR <linux/seccomp.h> .) | |
efeece04 | 935 | .IP |
34447828 | 936 | With |
8ab8b43f | 937 | .IR arg2 |
34447828 | 938 | set to |
b1248a9d | 939 | .BR SECCOMP_MODE_STRICT , |
8ab8b43f MK |
940 | the only system calls that the thread is permitted to make are |
941 | .BR read (2), | |
942 | .BR write (2), | |
85fbef74 MK |
943 | .BR _exit (2) |
944 | (but not | |
945 | .BR exit_group (2)), | |
fea681da | 946 | and |
8ab8b43f MK |
947 | .BR sigreturn (2). |
948 | Other system calls result in the delivery of a | |
949 | .BR SIGKILL | |
950 | signal. | |
34447828 | 951 | Strict secure computing mode is useful for number-crunching applications |
8ab8b43f MK |
952 | that may need to execute untrusted byte code, |
953 | perhaps obtained by reading from a pipe or socket. | |
33a0ccb2 | 954 | This operation is available only |
d6ef3d57 MK |
955 | if the kernel is configured with |
956 | .B CONFIG_SECCOMP | |
957 | enabled. | |
efeece04 | 958 | .IP |
34447828 KC |
959 | With |
960 | .IR arg2 | |
961 | set to | |
b1248a9d | 962 | .BR SECCOMP_MODE_FILTER " (since Linux 3.5)," |
6239dfb2 MK |
963 | the system calls allowed are defined by a pointer |
964 | to a Berkeley Packet Filter passed in | |
965 | .IR arg3 . | |
966 | This argument is a pointer to | |
967 | .IR "struct sock_fprog" ; | |
968 | it can be designed to filter | |
d6ef3d57 | 969 | arbitrary system calls and system call arguments. |
33a0ccb2 | 970 | This mode is available only if the kernel is configured with |
d6ef3d57 MK |
971 | .B CONFIG_SECCOMP_FILTER |
972 | enabled. | |
efeece04 | 973 | .IP |
1733db35 MK |
974 | If |
975 | .BR SECCOMP_MODE_FILTER | |
976 | filters permit | |
977 | .BR fork (2), | |
990e3887 | 978 | then the seccomp mode is inherited by children created by |
1733db35 MK |
979 | .BR fork (2); |
980 | if | |
981 | .BR execve (2) | |
fa1d2749 | 982 | is permitted, then the seccomp mode is preserved across |
1733db35 MK |
983 | .BR execve (2). |
984 | If the filters permit | |
a26ec136 | 985 | .BR prctl () |
1733db35 MK |
986 | calls, then additional filters can be added; |
987 | they are run in order until the first non-allow result is seen. | |
efeece04 | 988 | .IP |
6239dfb2 | 989 | For further information, see the kernel source file |
28d96036 ES |
990 | .IR Documentation/userspace\-api/seccomp_filter.rst |
991 | .\" commit c061f33f35be0ccc80f4b8e0aea5dfd2ed7e01a3 | |
992 | (or | |
993 | .IR Documentation/prctl/seccomp_filter.txt | |
994 | before Linux 4.13). | |
8ab8b43f MK |
995 | .TP |
996 | .BR PR_GET_SECCOMP " (since Linux 2.6.23)" | |
5e91816c MK |
997 | Return (as the function result) |
998 | the secure computing mode of the calling thread. | |
34447828 KC |
999 | If the caller is not in secure computing mode, this operation returns 0; |
1000 | if the caller is in strict secure computing mode, then the | |
8ab8b43f MK |
1001 | .BR prctl () |
1002 | call will cause a | |
1003 | .B SIGKILL | |
1004 | signal to be sent to the process. | |
d6ef3d57 | 1005 | If the caller is in filter mode, and this system call is allowed by the |
8eeb062d MK |
1006 | seccomp filters, it returns 2; otherwise, the process is killed with a |
1007 | .BR SIGKILL | |
1008 | signal. | |
33a0ccb2 | 1009 | This operation is available only |
d6ef3d57 MK |
1010 | if the kernel is configured with |
1011 | .B CONFIG_SECCOMP | |
1012 | enabled. | |
efeece04 | 1013 | .IP |
787843e7 MK |
1014 | Since Linux 3.8, the |
1015 | .IR Seccomp | |
1016 | field of the | |
1017 | .IR /proc/[pid]/status | |
1018 | file provides a method of obtaining the same information, | |
1019 | without the risk that the process is killed; see | |
1020 | .BR proc (5). | |
88989295 MK |
1021 | .TP |
1022 | .BR PR_SET_SECUREBITS " (since Linux 2.6.26)" | |
1023 | Set the "securebits" flags of the calling thread to the value supplied in | |
03547431 MK |
1024 | .IR arg2 . |
1025 | See | |
1026 | .BR capabilities (7). | |
88989295 | 1027 | .TP |
03547431 MK |
1028 | .BR PR_GET_SECUREBITS " (since Linux 2.6.26)" |
1029 | Return (as the function result) | |
1030 | the "securebits" flags of the calling thread. | |
1031 | See | |
1032 | .BR capabilities (7). | |
1033 | .TP | |
dd08fcca | 1034 | .BR PR_GET_SPECULATION_CTRL " (since Linux 4.17)" |
a01c1cbc MK |
1035 | Returns the state of the speculation misfeature specified in |
1036 | .IR arg2 . | |
1037 | Currently, the only permitted value for this argument is | |
2feab5d3 MK |
1038 | .BR PR_SPEC_STORE_BYPASS |
1039 | (otherwise the call fails with the error | |
1040 | .BR ENODEV ). | |
1041 | .IP | |
1042 | The return value uses bits 0-3 with the following meaning: | |
e23acd79 KRW |
1043 | .RS |
1044 | .TP | |
1045 | .BR PR_SPEC_PRCTL | |
2feab5d3 | 1046 | Mitigation can be controlled per thread by |
e23acd79 KRW |
1047 | .B PR_SET_SPECULATION_CTRL |
1048 | .TP | |
1049 | .BR PR_SPEC_ENABLE | |
1050 | The speculation feature is enabled, mitigation is disabled. | |
1051 | .TP | |
1052 | .BR PR_SPEC_DISABLE | |
1053 | The speculation feature is disabled, mitigation is enabled | |
1054 | .TP | |
1055 | .BR PR_SPEC_FORCE_DISABLE | |
1056 | Same as | |
1057 | .B PR_SPEC_DISABLE | |
1058 | but cannot be undone. | |
1059 | .RE | |
1060 | .IP | |
2feab5d3 | 1061 | If all bits are 0, |
e23acd79 KRW |
1062 | then the CPU is not affected by the speculation misfeature. |
1063 | .IP | |
1064 | If | |
1065 | .B PR_SPEC_PRCTL | |
2feab5d3 | 1066 | is set, then per-thread control of the mitigation is available. |
ac3756bc | 1067 | If not set, |
e36dfb81 | 1068 | .BR prctl () |
e23acd79 | 1069 | for the speculation misfeature will fail. |
a01c1cbc MK |
1070 | .IP |
1071 | The | |
e36dfb81 MK |
1072 | .IR arg3 , |
1073 | .IR arg4 , | |
e23acd79 KRW |
1074 | and |
1075 | .I arg5 | |
a01c1cbc | 1076 | arguments must be specified as 0; otherwise the call fails with the error |
e36dfb81 | 1077 | .BR EINVAL . |
e23acd79 | 1078 | .TP |
dd08fcca MK |
1079 | .BR PR_SET_SPECULATION_CTRL " (since Linux 4.17)" |
1080 | .\" commit b617cfc858161140d69cc0b5cc211996b557a1c7 | |
1081 | .\" commit 356e4bfff2c5489e016fdb925adbf12a1e3950ee | |
a01c1cbc MK |
1082 | Sets the state of the speculation misfeature specified in |
1083 | .IR arg2 . | |
1084 | Currently, the only permitted value for this argument is | |
2feab5d3 MK |
1085 | .B PR_SPEC_STORE_BYPASS |
1086 | (otherwise the call fails with the error | |
1087 | .BR ENODEV ). | |
a01c1cbc | 1088 | This setting is a per-thread attribute. |
ac3756bc | 1089 | The |
e23acd79 | 1090 | .IR arg3 |
a01c1cbc MK |
1091 | argument is used to hand in the control value, |
1092 | which is one of the following: | |
e23acd79 KRW |
1093 | .RS |
1094 | .TP | |
1095 | .BR PR_SPEC_ENABLE | |
1096 | The speculation feature is enabled, mitigation is disabled. | |
1097 | .TP | |
1098 | .BR PR_SPEC_DISABLE | |
1099 | The speculation feature is disabled, mitigation is enabled | |
1100 | .TP | |
1101 | .BR PR_SPEC_FORCE_DISABLE | |
1102 | Same as | |
1103 | .B PR_SPEC_DISABLE | |
ac3756bc MK |
1104 | but cannot be undone. |
1105 | A subsequent | |
e23acd79 KRW |
1106 | .B |
1107 | prctl(..., PR_SPEC_ENABLE) | |
2feab5d3 | 1108 | will fail with the error |
e36dfb81 | 1109 | .BR EPERM . |
e23acd79 KRW |
1110 | .RE |
1111 | .IP | |
1112 | Any other value in | |
1113 | .IR arg3 | |
2feab5d3 | 1114 | will result in the call failing with the error |
e23acd79 | 1115 | .BR ERANGE . |
a01c1cbc MK |
1116 | .IP |
1117 | The | |
2feab5d3 | 1118 | .I arg4 |
e23acd79 KRW |
1119 | and |
1120 | .I arg5 | |
a01c1cbc | 1121 | arguments must be specified as 0; otherwise the call fails with the error |
e36dfb81 | 1122 | .BR EINVAL . |
e23acd79 | 1123 | .IP |
a01c1cbc MK |
1124 | The speculation feature can also be controlled by the |
1125 | .B spec_store_bypass_disable | |
1126 | boot parameter. | |
1127 | This parameter may enforce a read-only policy which will result in the | |
1128 | .BR prctl (2) | |
1129 | call failing with the error | |
e23acd79 | 1130 | .BR ENXIO . |
a01c1cbc MK |
1131 | For further details, see the kernel source file |
1132 | .IR Documentation/admin-guide/kernel-parameters.txt . | |
e23acd79 | 1133 | .TP |
03547431 MK |
1134 | .BR PR_SET_THP_DISABLE " (since Linux 3.15)" |
1135 | .\" commit a0715cc22601e8830ace98366c0c2bd8da52af52 | |
1136 | Set the state of the "THP disable" flag for the calling thread. | |
1137 | If | |
1138 | .I arg2 | |
1139 | has a nonzero value, the flag is set, otherwise it is cleared. | |
1140 | Setting this flag provides a method | |
1141 | for disabling transparent huge pages | |
1142 | for jobs where the code cannot be modified, and using a malloc hook with | |
1143 | .BR madvise (2) | |
1144 | is not an option (i.e., statically allocated data). | |
1145 | The setting of the "THP disable" flag is inherited by a child created via | |
1146 | .BR fork (2) | |
1147 | and is preserved across | |
1148 | .BR execve (2). | |
1149 | .\" | |
06afe673 MK |
1150 | .TP |
1151 | .BR PR_TASK_PERF_EVENTS_DISABLE " (since Linux 2.6.31)" | |
1152 | Disable all performance counters attached to the calling process, | |
1153 | regardless of whether the counters were created by | |
1154 | this process or another process. | |
1155 | Performance counters created by the calling process for other | |
1156 | processes are unaffected. | |
66a9882e | 1157 | For more information on performance counters, see the Linux kernel source file |
06afe673 MK |
1158 | .IR tools/perf/design.txt . |
1159 | .IP | |
03547431 MK |
1160 | Originally called |
1161 | .BR PR_TASK_PERF_COUNTERS_DISABLE ; | |
1162 | .\" commit 1d1c7ddbfab358445a542715551301b7fc363e28 | |
b0ea1ea3 | 1163 | renamed (retaining the same numerical value) |
03547431 MK |
1164 | in Linux 2.6.32. |
1165 | .\" | |
03979794 | 1166 | .TP |
03547431 MK |
1167 | .BR PR_TASK_PERF_EVENTS_ENABLE " (since Linux 2.6.31)" |
1168 | The converse of | |
1169 | .BR PR_TASK_PERF_EVENTS_DISABLE ; | |
1170 | enable performance counters attached to the calling process. | |
1171 | .IP | |
1172 | Originally called | |
1173 | .BR PR_TASK_PERF_COUNTERS_ENABLE ; | |
1174 | .\" commit 1d1c7ddbfab358445a542715551301b7fc363e28 | |
1175 | renamed | |
1176 | .\" commit cdd6c482c9ff9c55475ee7392ec8f672eddb7be6 | |
1177 | in Linux 2.6.32. | |
1178 | .\" | |
1179 | .TP | |
1180 | .BR PR_GET_THP_DISABLE " (since Linux 3.15)" | |
1181 | Return (via the function result) the current setting of the "THP disable" | |
1182 | flag for the calling thread: | |
1183 | either 1, if the flag is set, or 0, if it is not. | |
1184 | .TP | |
1185 | .BR PR_GET_TID_ADDRESS " (since Linux 3.5)" | |
1186 | .\" commit 300f786b2683f8bb1ec0afb6e1851183a479c86d | |
1187 | Retrieve the | |
1188 | .I clear_child_tid | |
1189 | address set by | |
1190 | .BR set_tid_address (2) | |
1191 | and the | |
1192 | .BR clone (2) | |
1193 | .B CLONE_CHILD_CLEARTID | |
1194 | flag, in the location pointed to by | |
1195 | .IR "(int\ **)\ arg2" . | |
1196 | This feature is available only if the kernel is built with the | |
1197 | .BR CONFIG_CHECKPOINT_RESTORE | |
c7f2f9ed MK |
1198 | option enabled. |
1199 | Note that since the | |
1200 | .BR prctl () | |
1201 | system call does not have a compat implementation for | |
1202 | the AMD64 x32 and MIPS n32 ABIs, | |
1203 | and the kernel writes out a pointer using the kernel's pointer size, | |
1204 | this operation expects a user-space buffer of 8 (not 4) bytes on these ABIs. | |
03547431 MK |
1205 | .TP |
1206 | .BR PR_SET_TIMERSLACK " (since Linux 2.6.28)" | |
1207 | .\" See https://lwn.net/Articles/369549/ | |
1208 | .\" commit 6976675d94042fbd446231d1bd8b7de71a980ada | |
3780f8a5 MK |
1209 | Each thread has two associated timer slack values: |
1210 | a "default" value, and a "current" value. | |
1211 | This operation sets the "current" timer slack value for the calling thread. | |
1212 | If the nanosecond value supplied in | |
1213 | .IR arg2 | |
1214 | is greater than zero, then the "current" value is set to this value. | |
03547431 MK |
1215 | If |
1216 | .I arg2 | |
1217 | is less than or equal to zero, | |
1218 | .\" It seems that it's not possible to set the timer slack to zero; | |
1219 | .\" The minimum value is 1? Seems a little strange. | |
3780f8a5 MK |
1220 | the "current" timer slack is reset to the |
1221 | thread's "default" timer slack value. | |
efeece04 | 1222 | .IP |
3780f8a5 | 1223 | The "current" timer slack is used by the kernel to group timer expirations |
03547431 MK |
1224 | for the calling thread that are close to one another; |
1225 | as a consequence, timer expirations for the thread may be | |
1226 | up to the specified number of nanoseconds late (but will never expire early). | |
1227 | Grouping timer expirations can help reduce system power consumption | |
1228 | by minimizing CPU wake-ups. | |
efeece04 | 1229 | .IP |
03547431 MK |
1230 | The timer expirations affected by timer slack are those set by |
1231 | .BR select (2), | |
1232 | .BR pselect (2), | |
1233 | .BR poll (2), | |
1234 | .BR ppoll (2), | |
1235 | .BR epoll_wait (2), | |
1236 | .BR epoll_pwait (2), | |
1237 | .BR clock_nanosleep (2), | |
1238 | .BR nanosleep (2), | |
1239 | and | |
1240 | .BR futex (2) | |
1241 | (and thus the library functions implemented via futexes, including | |
1242 | .\" List obtained by grepping for futex usage in glibc source | |
1243 | .BR pthread_cond_timedwait (3), | |
1244 | .BR pthread_mutex_timedlock (3), | |
1245 | .BR pthread_rwlock_timedrdlock (3), | |
1246 | .BR pthread_rwlock_timedwrlock (3), | |
1247 | and | |
1248 | .BR sem_timedwait (3)). | |
efeece04 | 1249 | .IP |
03547431 MK |
1250 | Timer slack is not applied to threads that are scheduled under |
1251 | a real-time scheduling policy (see | |
1252 | .BR sched_setscheduler (2)). | |
efeece04 | 1253 | .IP |
03547431 | 1254 | When a new thread is created, |
3780f8a5 | 1255 | the two timer slack values are made the same as the "current" value |
03547431 | 1256 | of the creating thread. |
3780f8a5 MK |
1257 | Thereafter, a thread can adjust its "current" timer slack value via |
1258 | .BR PR_SET_TIMERSLACK . | |
1259 | The "default" value can't be changed. | |
03547431 MK |
1260 | The timer slack values of |
1261 | .IR init | |
1262 | (PID 1), the ancestor of all processes, | |
1263 | are 50,000 nanoseconds (50 microseconds). | |
1264 | The timer slack values are preserved across | |
1265 | .BR execve (2). | |
efeece04 | 1266 | .IP |
c1f78aba MK |
1267 | Since Linux 4.6, the "current" timer slack value of any process |
1268 | can be examined and changed via the file | |
1269 | .IR /proc/[pid]/timerslack_ns . | |
1270 | See | |
1271 | .BR proc (5). | |
e81a96ec | 1272 | .TP |
03547431 MK |
1273 | .BR PR_GET_TIMERSLACK " (since Linux 2.6.28)" |
1274 | Return (as the function result) | |
3780f8a5 | 1275 | the "current" timer slack value of the calling thread. |
4bf25b89 | 1276 | .TP |
d6bec36e MK |
1277 | .BR PR_SET_TIMING " (since Linux 2.6.0)" |
1278 | .\" Precisely: Linux 2.6.0-test4 | |
03547431 MK |
1279 | Set whether to use (normal, traditional) statistical process timing or |
1280 | accurate timestamp-based process timing, by passing | |
1281 | .B PR_TIMING_STATISTICAL | |
1282 | .\" 0 | |
1283 | or | |
1284 | .B PR_TIMING_TIMESTAMP | |
1285 | .\" 1 | |
1286 | to \fIarg2\fP. | |
1287 | .B PR_TIMING_TIMESTAMP | |
1288 | is not currently implemented | |
1289 | (attempting to set this mode will yield the error | |
1290 | .BR EINVAL ). | |
1291 | .\" PR_TIMING_TIMESTAMP doesn't do anything in 2.6.26-rc8, | |
1292 | .\" and looking at the patch history, it appears | |
1293 | .\" that it never did anything. | |
4bf25b89 | 1294 | .TP |
d6bec36e MK |
1295 | .BR PR_GET_TIMING " (since Linux 2.6.0)" |
1296 | .\" Precisely: Linux 2.6.0-test4 | |
03547431 MK |
1297 | Return (as the function result) which process timing method is currently |
1298 | in use. | |
4bf25b89 | 1299 | .TP |
03547431 MK |
1300 | .BR PR_SET_TSC " (since Linux 2.6.26, x86 only)" |
1301 | Set the state of the flag determining whether the timestamp counter | |
1302 | can be read by the process. | |
1303 | Pass | |
1304 | .B PR_TSC_ENABLE | |
1305 | to | |
1306 | .I arg2 | |
1307 | to allow it to be read, or | |
1308 | .B PR_TSC_SIGSEGV | |
1309 | to generate a | |
1310 | .B SIGSEGV | |
1311 | when the process tries to read the timestamp counter. | |
4bf25b89 | 1312 | .TP |
03547431 MK |
1313 | .BR PR_GET_TSC " (since Linux 2.6.26, x86 only)" |
1314 | Return the state of the flag determining whether the timestamp counter | |
1315 | can be read, | |
1316 | in the location pointed to by | |
1317 | .IR "(int\ *) arg2" . | |
1318 | .TP | |
1319 | .B PR_SET_UNALIGN | |
1320 | (Only on: ia64, since Linux 2.3.48; parisc, since Linux 2.6.15; | |
0e2c6b8c ES |
1321 | PowerPC, since Linux 2.6.18; Alpha, since Linux 2.6.22; |
1322 | .\" sh: 94ea5e449ae834af058ef005d16a8ad44fcf13d6 | |
1323 | .\" tile: 2f9ac29eec71a696cb0dcc5fb82c0f8d4dac28c9 | |
1324 | sh, since Linux 2.6.34; tile, since Linux 3.12) | |
03547431 MK |
1325 | Set unaligned access control bits to \fIarg2\fP. |
1326 | Pass | |
1327 | \fBPR_UNALIGN_NOPRINT\fP to silently fix up unaligned user accesses, | |
1328 | or \fBPR_UNALIGN_SIGBUS\fP to generate | |
1329 | .B SIGBUS | |
2da72a43 MK |
1330 | on unaligned user access. |
1331 | Alpha also supports an additional flag with the value | |
1332 | of 4 and no corresponding named constant, | |
1333 | which instructs kernel to not fix up | |
0e2c6b8c | 1334 | unaligned accesses (it is analogous to providing the |
2da72a43 MK |
1335 | .BR UAC_NOFIX |
1336 | flag in | |
1337 | .BR SSI_NVPAIRS | |
1338 | operation of the | |
1339 | .BR setsysinfo () | |
1340 | system call on Tru64). | |
03547431 MK |
1341 | .TP |
1342 | .B PR_GET_UNALIGN | |
1343 | (see | |
1344 | .B PR_SET_UNALIGN | |
1345 | for information on versions and architectures) | |
1346 | Return unaligned access control bits, in the location pointed to by | |
0e2c6b8c | 1347 | .IR "(unsigned int\ *) arg2" . |
47297adb | 1348 | .SH RETURN VALUE |
8ab8b43f MK |
1349 | On success, |
1350 | .BR PR_GET_DUMPABLE , | |
1351 | .BR PR_GET_KEEPCAPS , | |
f83fe154 | 1352 | .BR PR_GET_NO_NEW_PRIVS , |
5745985f | 1353 | .BR PR_GET_THP_DISABLE , |
8ab8b43f MK |
1354 | .BR PR_CAPBSET_READ , |
1355 | .BR PR_GET_TIMING , | |
c42db321 | 1356 | .BR PR_GET_TIMERSLACK , |
8ab8b43f | 1357 | .BR PR_GET_SECUREBITS , |
ed31c572 | 1358 | .BR PR_MCE_KILL_GET , |
0c3e75cb | 1359 | .BR PR_CAP_AMBIENT + PR_CAP_AMBIENT_IS_SET , |
8ab8b43f MK |
1360 | and (if it returns) |
1361 | .BR PR_GET_SECCOMP | |
2fda57bd | 1362 | return the nonnegative values described above. |
fea681da MK |
1363 | All other |
1364 | .I option | |
1365 | values return 0 on success. | |
1366 | On error, \-1 is returned, and | |
1367 | .I errno | |
1368 | is set appropriately. | |
1369 | .SH ERRORS | |
1370 | .TP | |
0478944d MK |
1371 | .B EACCES |
1372 | .I option | |
1373 | is | |
4ab9f1db MK |
1374 | .BR PR_SET_SECCOMP |
1375 | and | |
1376 | .I arg2 | |
1377 | is | |
1378 | .BR SECCOMP_MODE_FILTER , | |
1379 | but the process does not have the | |
1380 | .BR CAP_SYS_ADMIN | |
1381 | capability or has not set the | |
1382 | .IR no_new_privs | |
1383 | attribute (see the discussion of | |
1384 | .BR PR_SET_NO_NEW_PRIVS | |
1385 | above). | |
1386 | .TP | |
1387 | .B EACCES | |
1388 | .I option | |
1389 | is | |
0478944d MK |
1390 | .BR PR_SET_MM , |
1391 | and | |
1392 | .I arg3 | |
1393 | is | |
1394 | .BR PR_SET_MM_EXE_FILE , | |
1395 | the file is not executable. | |
1396 | .TP | |
1397 | .B EBADF | |
1398 | .I option | |
1399 | is | |
1400 | .BR PR_SET_MM , | |
1401 | .I arg3 | |
1402 | is | |
1403 | .BR PR_SET_MM_EXE_FILE , | |
1404 | and the file descriptor passed in | |
1405 | .I arg4 | |
1406 | is not valid. | |
1407 | .TP | |
1408 | .B EBUSY | |
1409 | .I option | |
1410 | is | |
1411 | .BR PR_SET_MM , | |
1412 | .I arg3 | |
1413 | is | |
1414 | .BR PR_SET_MM_EXE_FILE , | |
1415 | and this the second attempt to change the | |
1416 | .I /proc/pid/exe | |
1417 | symbolic link, which is prohibited. | |
1418 | .TP | |
8ab8b43f MK |
1419 | .B EFAULT |
1420 | .I arg2 | |
1421 | is an invalid address. | |
1422 | .TP | |
e35a0512 KC |
1423 | .B EFAULT |
1424 | .I option | |
1425 | is | |
1426 | .BR PR_SET_SECCOMP , | |
1427 | .I arg2 | |
1428 | is | |
1429 | .BR SECCOMP_MODE_FILTER , | |
1430 | the system was built with | |
64c626f7 | 1431 | .BR CONFIG_SECCOMP_FILTER , |
e35a0512 KC |
1432 | and |
1433 | .I arg3 | |
1434 | is an invalid address. | |
1435 | .TP | |
fea681da MK |
1436 | .B EINVAL |
1437 | The value of | |
1438 | .I option | |