1PRCTL(2)                   Linux Programmer's Manual                  PRCTL(2)
2
3
4

NAME

6       prctl - operations on a process
7

SYNOPSIS

9       #include <sys/prctl.h>
10
11       int prctl(int option, unsigned long arg2, unsigned long arg3,
12                 unsigned long arg4, unsigned long arg5);
13

DESCRIPTION

15       prctl()  is  called  with  a first argument describing what to do (with
16       values defined in <linux/prctl.h>), and further arguments with  a  sig‐
17       nificance depending on the first one.  The first argument can be:
18
19       PR_CAPBSET_READ (since Linux 2.6.25)
20              Return (as the function result) 1 if the capability specified in
21              arg2 is in the calling thread's capability bounding set, or 0 if
22              it   is   not.    (The   capability  constants  are  defined  in
23              <linux/capability.h>.)  The  capability  bounding  set  dictates
24              whether  the process can receive the capability through a file's
25              permitted capability set on a subsequent call to execve(2).
26
27              If the capability specified in arg2 is not valid, then the  call
28              fails with the error EINVAL.
29
30       PR_CAPBSET_DROP (since Linux 2.6.25)
31              If  the calling thread has the CAP_SETPCAP capability, then drop
32              the capability specified by arg2 from the calling thread's capa‐
33              bility  bounding  set.   Any children of the calling thread will
34              inherit the newly reduced bounding set.
35
36              The call fails with the error: EPERM if the calling thread  does
37              not  have  the  CAP_SETPCAP; EINVAL if arg2 does not represent a
38              valid capability; or EINVAL if file capabilities are not enabled
39              in the kernel, in which case bounding sets are not supported.
40
41       PR_SET_DUMPABLE (since Linux 2.3.20)
42              Set  the  state  of  the flag determining whether core dumps are
43              produced for this  process  upon  delivery  of  a  signal  whose
44              default behavior is to produce a core dump.  (Normally this flag
45              is set for a process by default, but it is cleared when  a  set-
46              user-ID  or set-group-ID program is executed and also by various
47              system calls that manipulate process UIDs and GIDs).  In kernels
48              up  to  and  including 2.6.12, arg2 must be either 0 (process is
49              not dumpable) or  1  (process  is  dumpable).   Between  kernels
50              2.6.13  and 2.6.17, the value 2 was also permitted, which caused
51              any binary which normally would not be dumped to be dumped read‐
52              able  by  root only; for security reasons, this feature has been
53              removed.       (See      also      the      description       of
54              /proc/sys/fs/suid_dumpable in proc(5).)
55
56       PR_GET_DUMPABLE (since Linux 2.3.20)
57              Return (as the function result) the current state of the calling
58              process's dumpable flag.
59
60       PR_SET_ENDIAN (since Linux 2.6.18, PowerPC only)
61              Set the endian-ness of the calling process to the value given in
62              arg2,  which  should  be  one  of  the following: PR_ENDIAN_BIG,
63              PR_ENDIAN_LITTLE, or PR_ENDIAN_PPC_LITTLE (PowerPC pseudo little
64              endian).
65
66       PR_GET_ENDIAN (since Linux 2.6.18, PowerPC only)
67              Return  the  endian-ness of the calling process, in the location
68              pointed to by (int *) arg2.
69
70       PR_SET_FPEMU (since Linux 2.4.18, 2.5.9, only on ia64)
71              Set  floating-point  emulation  control  bits  to  arg2.    Pass
72              PR_FPEMU_NOPRINT  to silently emulate fp operations accesses, or
73              PR_FPEMU_SIGFPE to not emulate fp  operations  and  send  SIGFPE
74              instead.
75
76       PR_GET_FPEMU (since Linux 2.4.18, 2.5.9, only on ia64)
77              Return  floating-point  emulation  control bits, in the location
78              pointed to by (int *) arg2.
79
80       PR_SET_FPEXC (since Linux 2.4.21, 2.5.32, only on PowerPC)
81              Set   floating-point   exception    mode    to    arg2.     Pass
82              PR_FP_EXC_SW_ENABLE  to  use  FPEXC  for  FP  exception enables,
83              PR_FP_EXC_DIV for floating-point divide by  zero,  PR_FP_EXC_OVF
84              for  floating-point  overflow,  PR_FP_EXC_UND for floating-point
85              underflow,  PR_FP_EXC_RES  for  floating-point  inexact  result,
86              PR_FP_EXC_INV     for    floating-point    invalid    operation,
87              PR_FP_EXC_DISABLED for FP exceptions disabled,  PR_FP_EXC_NONRE‐
88              COV  for  async  non-recoverable exception mode, PR_FP_EXC_ASYNC
89              for async recoverable exception mode, PR_FP_EXC_PRECISE for pre‐
90              cise exception mode.
91
92       PR_GET_FPEXC (since Linux 2.4.21, 2.5.32, only on PowerPC)
93              Return floating-point exception mode, in the location pointed to
94              by (int *) arg2.
95
96       PR_SET_KEEPCAPS (since Linux 2.2.18)
97              Set the state of the thread's "keep  capabilities"  flag,  which
98              determines  whether  the threads's effective and permitted capa‐
99              bility sets are cleared when a change is made to  the  threads's
100              user  IDs  such  that the threads's real UID, effective UID, and
101              saved set-user-ID all become non-zero when at least one of  them
102              previously  had the value 0.  (By default, these credential sets
103              are cleared).  arg2 must be either 0 (capabilities are  cleared)
104              or  1 (capabilities are kept).  This value will be reset to 0 on
105              subsequent calls to execve(2).
106
107       PR_GET_KEEPCAPS (since Linux 2.2.18)
108              Return (as the function result) the current state of the calling
109              threads's "keep capabilities" flag.
110
111       PR_SET_NAME (since Linux 2.6.9)
112              Set the process name for the calling process, using the value in
113              the location pointed to by (char *) arg2.  The name can be up to
114              16  bytes  long,  and  should  be null terminated if it contains
115              fewer bytes.
116
117       PR_GET_NAME (since Linux 2.6.11)
118              Return the process name for the calling process, in  the  buffer
119              pointed  to by (char *) arg2.  The buffer should allow space for
120              up to 16 bytes; the returned string will be null  terminated  if
121              it is shorter than that.
122
123       PR_SET_PDEATHSIG (since Linux 2.1.57)
124              Set  the  parent  process death signal of the calling process to
125              arg2 (either a signal value in the  range  1..maxsig,  or  0  to
126              clear).   This  is  the signal that the calling process will get
127              when its parent dies.  This value is cleared for the child of  a
128              fork(2).
129
130       PR_GET_PDEATHSIG (since Linux 2.3.15)
131              Return  the current value of the parent process death signal, in
132              the location pointed to by (int *) arg2.
133
134       PR_SET_SECCOMP (since Linux 2.6.23)
135              Set the secure computing mode for the calling  thread.   In  the
136              current  implementation,  arg2 must be 1.  After the secure com‐
137              puting mode has been set to 1, the only system  calls  that  the
138              thread is permitted to make are read(2), write(2), _exit(2), and
139              sigreturn(2).  Other system calls result in the  delivery  of  a
140              SIGKILL  signal.   Secure  computing  mode is useful for number-
141              crunching applications that may need to execute  untrusted  byte
142              code,  perhaps  obtained by reading from a pipe or socket.  This
143              operation is only available if the  kernel  is  configured  with
144              CONFIG_SECCOMP enabled.
145
146       PR_GET_SECCOMP (since Linux 2.6.23)
147              Return  the  secure  computing  mode of the calling thread.  Not
148              very useful for the current implementation (mode equals 1),  but
149              may  be useful for other possible future modes: if the caller is
150              not in secure computing mode, this operation returns 0;  if  the
151              caller  is  in secure computing mode, then the prctl() call will
152              cause a SIGKILL signal to be sent to the process.   This  opera‐
153              tion  is  only  available  if the kernel is configured with CON‐
154              FIG_SECCOMP enabled.
155
156       PR_SET_SECUREBITS (since Linux 2.6.26)
157              Set the "securebits" flags of the calling thread  to  the  value
158              supplied in arg2.  See capabilities(7).
159
160       PR_GET_SECUREBITS (since Linux 2.6.26)
161              Return  (as  the  function result) the "securebits" flags of the
162              calling thread.  See capabilities(7).
163
164       PR_SET_TIMING (since Linux 2.6.0-test4)
165              Set whether to use  (normal,  traditional)  statistical  process
166              timing  or  accurate  timestamp based process timing, by passing
167              PR_TIMING_STATISTICAL or PR_TIMING_TIMESTAMP to  arg2.   PR_TIM‐
168              ING_TIMESTAMP  is  not  currently implemented (attempting to set
169              this mode will yield the error EINVAL).
170
171       PR_GET_TIMING (since Linux 2.6.0-test4)
172              Return (as the function result) which process timing  method  is
173              currently in use.
174
175       PR_SET_TSC (since Linux 2.6.26, x86 only)
176              Set  the  state  of  the  flag determining whether the timestamp
177              counter can be read by the process.  Pass PR_TSC_ENABLE to  arg2
178              to  allow it to be read, or PR_TSC_SIGSEGV to generate a SIGSEGV
179              when the process tries to read the timestamp counter.
180
181       PR_GET_TSC (since Linux 2.6.26, x86 only)
182              Return the state of the flag determining whether  the  timestamp
183              counter can be read, in the location pointed to by (int *) arg2.
184
185       PR_SET_UNALIGN
186              (Only  on: ia64, since Linux 2.3.48; parisc, since Linux 2.6.15;
187              PowerPC, since Linux 2.6.18;  Alpha,  since  Linux  2.6.22)  Set
188              unaligned  access control bits to arg2.  Pass PR_UNALIGN_NOPRINT
189              to silently fix up unaligned user accesses, or PR_UNALIGN_SIGBUS
190              to generate SIGBUS on unaligned user access.
191
192       PR_GET_UNALIGN
193              (see  PR_SET_UNALIGN  for  information on versions and architec‐
194              tures) Return unaligned access control  bits,  in  the  location
195              pointed to by (int *) arg2.
196

RETURN VALUE

198       On    success,   PR_GET_DUMPABLE,   PR_GET_KEEPCAPS,   PR_CAPBSET_READ,
199       PR_GET_TIMING, PR_GET_SECUREBITS, and (if  it  returns)  PR_GET_SECCOMP
200       return  the non-negative values described above.  All other option val‐
201       ues return 0 on success.  On error, -1 is returned, and  errno  is  set
202       appropriately.
203

ERRORS

205       EFAULT arg2 is an invalid address.
206
207       EINVAL The value of option is not recognized.
208
209       EINVAL arg2 is not valid value for this option.
210
211       EINVAL option  is  PR_SET_SECCOMP or PR_SET_SECCOMP, and the kernel was
212              not configured with CONFIG_SECCOMP.
213
214       EPERM  option is PR_SET_SECUREBITS, and the caller does  not  have  the
215              CAP_SETPCAP  capability,  or  tried to unset a "locked" flag, or
216              tried to set a flag whose corresponding locked flag was set (see
217              capabilities(7)).
218
219       EPERM  option     is     PR_SET_KEEPCAPS,     and     the     callers's
220              SECURE_KEEP_CAPS_LOCKED flag is set (see capabilities(7)).
221
222       EPERM  option is PR_CAPBSET_DROP, and the  caller  does  not  have  the
223              CAP_SETPCAP capability.
224

VERSIONS

226       The prctl() system call was introduced in Linux 2.1.57.
227

CONFORMING TO

229       This  call  is  Linux-specific.   IRIX  has a prctl() system call (also
230       introduced in Linux 2.1.44 as irix_prctl  on  the  MIPS  architecture),
231       with prototype
232
233       ptrdiff_t prctl(int option, int arg2, int arg3);
234
235       and  options  to  get the maximum number of processes per user, get the
236       maximum number of processors the calling  process  can  use,  find  out
237       whether  a specified process is currently blocked, get or set the maxi‐
238       mum stack size, etc.
239

SEE ALSO

241       signal(2), core(5)
242

COLOPHON

244       This page is part of release 3.22 of the Linux  man-pages  project.   A
245       description  of  the project, and information about reporting bugs, can
246       be found at http://www.kernel.org/doc/man-pages/.
247
248
249
250Linux                             2008-07-16                          PRCTL(2)
Impressum