Print this page
uts: Allow for address space randomisation.
Randomise the base addresses of shared objects, non-fixed mappings, the
stack and the heap. Introduce a service, svc:/system/process-security,
and a tool psecflags(1) to control and observe it
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/procfs.h
+++ new/usr/src/uts/common/sys/procfs.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26 /*
27 27 * Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
28 28 */
29 29
30 30 #ifndef _SYS_PROCFS_H
31 31 #define _SYS_PROCFS_H
32 32
33 33 #ifdef __cplusplus
34 34 extern "C" {
35 35 #endif
36 36
37 37 /*
38 38 * This definition is temporary. Structured proc is the preferred API,
39 39 * and the older ioctl-based interface will be removed in a future version
40 40 * of Solaris. Until then, by default, including <sys/procfs.h> will
41 41 * provide the older ioctl-based /proc definitions. To get the structured
42 42 * /proc definitions, either include <procfs.h> or define _STRUCTURED_PROC
43 43 * to be 1 before including <sys/procfs.h>.
44 44 */
45 45 #ifndef _STRUCTURED_PROC
46 46 #define _STRUCTURED_PROC 0
47 47 #endif
48 48
49 49 #if !defined(_KERNEL) && _STRUCTURED_PROC == 0
50 50
51 51 #include <sys/old_procfs.h>
52 52
53 53 #else /* !defined(_KERNEL) && _STRUCTURED_PROC == 0 */
54 54
55 55 #include <sys/feature_tests.h>
56 56 #include <sys/types.h>
↓ open down ↓ |
56 lines elided |
↑ open up ↑ |
57 57 #include <sys/time_impl.h>
58 58 #include <sys/signal.h>
59 59 #include <sys/siginfo.h>
60 60 #include <sys/fault.h>
61 61 #include <sys/syscall.h>
62 62 #include <sys/pset.h>
63 63 #include <sys/procfs_isa.h>
64 64 #include <sys/priv.h>
65 65 #include <sys/stat.h>
66 66 #include <sys/param.h>
67 +#include <sys/secflags.h>
67 68
68 69 /*
69 70 * System call interfaces for /proc.
70 71 */
71 72
72 73 /*
73 74 * Control codes (long values) for messages written to ctl and lwpctl files.
74 75 */
75 76 #define PCNULL 0L /* null request, advance to next message */
76 77 #define PCSTOP 1L /* direct process or lwp to stop and wait for stop */
77 78 #define PCDSTOP 2L /* direct process or lwp to stop */
78 79 #define PCWSTOP 3L /* wait for process or lwp to stop, no timeout */
79 80 #define PCTWSTOP 4L /* wait for stop, with long millisecond timeout arg */
80 81 #define PCRUN 5L /* make process/lwp runnable, w/ long flags argument */
81 82 #define PCCSIG 6L /* clear current signal from lwp */
82 83 #define PCCFAULT 7L /* clear current fault from lwp */
83 84 #define PCSSIG 8L /* set current signal from siginfo_t argument */
84 85 #define PCKILL 9L /* post a signal to process/lwp, long argument */
85 86 #define PCUNKILL 10L /* delete a pending signal from process/lwp, long arg */
86 87 #define PCSHOLD 11L /* set lwp signal mask from sigset_t argument */
87 88 #define PCSTRACE 12L /* set traced signal set from sigset_t argument */
88 89 #define PCSFAULT 13L /* set traced fault set from fltset_t argument */
89 90 #define PCSENTRY 14L /* set traced syscall entry set from sysset_t arg */
90 91 #define PCSEXIT 15L /* set traced syscall exit set from sysset_t arg */
91 92 #define PCSET 16L /* set modes from long argument */
92 93 #define PCUNSET 17L /* unset modes from long argument */
93 94 #define PCSREG 18L /* set lwp general registers from prgregset_t arg */
94 95 #define PCSFPREG 19L /* set lwp floating-point registers from prfpregset_t */
95 96 #define PCSXREG 20L /* set lwp extra registers from prxregset_t arg */
96 97 #define PCNICE 21L /* set nice priority from long argument */
97 98 #define PCSVADDR 22L /* set %pc virtual address from long argument */
98 99 #define PCWATCH 23L /* set/unset watched memory area from prwatch_t arg */
99 100 #define PCAGENT 24L /* create agent lwp with regs from prgregset_t arg */
100 101 #define PCREAD 25L /* read from the address space via priovec_t arg */
101 102 #define PCWRITE 26L /* write to the address space via priovec_t arg */
102 103 #define PCSCRED 27L /* set process credentials from prcred_t argument */
103 104 #define PCSASRS 28L /* set ancillary state registers from asrset_t arg */
104 105 #define PCSPRIV 29L /* set process privileges from prpriv_t argument */
105 106 #define PCSZONE 30L /* set zoneid from zoneid_t argument */
106 107 #define PCSCREDX 31L /* as PCSCRED but with supplemental groups */
107 108 /*
108 109 * PCRUN long operand flags.
109 110 */
110 111 #define PRCSIG 0x01 /* clear current signal, if any */
111 112 #define PRCFAULT 0x02 /* clear current fault, if any */
112 113 #define PRSTEP 0x04 /* direct the lwp to single-step */
113 114 #define PRSABORT 0x08 /* abort syscall, if in syscall */
114 115 #define PRSTOP 0x10 /* set directed stop request */
115 116
116 117 /*
117 118 * lwp status file. /proc/<pid>/lwp/<lwpid>/lwpstatus
118 119 */
119 120 #define PRCLSZ 8 /* maximum size of scheduling class name */
120 121 #define PRSYSARGS 8 /* maximum number of syscall arguments */
121 122 typedef struct lwpstatus {
122 123 int pr_flags; /* flags (see below) */
123 124 id_t pr_lwpid; /* specific lwp identifier */
124 125 short pr_why; /* reason for lwp stop, if stopped */
125 126 short pr_what; /* more detailed reason */
126 127 short pr_cursig; /* current signal, if any */
127 128 short pr_pad1;
128 129 siginfo_t pr_info; /* info associated with signal or fault */
129 130 sigset_t pr_lwppend; /* set of signals pending to the lwp */
130 131 sigset_t pr_lwphold; /* set of signals blocked by the lwp */
131 132 struct sigaction pr_action; /* signal action for current signal */
132 133 stack_t pr_altstack; /* alternate signal stack info */
133 134 uintptr_t pr_oldcontext; /* address of previous ucontext */
134 135 short pr_syscall; /* system call number (if in syscall) */
135 136 short pr_nsysarg; /* number of arguments to this syscall */
136 137 int pr_errno; /* errno for failed syscall, 0 if successful */
137 138 long pr_sysarg[PRSYSARGS]; /* arguments to this syscall */
138 139 long pr_rval1; /* primary syscall return value */
139 140 long pr_rval2; /* second syscall return value, if any */
140 141 char pr_clname[PRCLSZ]; /* scheduling class name */
141 142 timestruc_t pr_tstamp; /* real-time time stamp of stop */
142 143 timestruc_t pr_utime; /* lwp user cpu time */
143 144 timestruc_t pr_stime; /* lwp system cpu time */
144 145 int pr_filler[11 - 2 * sizeof (timestruc_t) / sizeof (int)];
145 146 int pr_errpriv; /* missing privilege */
146 147 uintptr_t pr_ustack; /* address of stack boundary data (stack_t) */
147 148 ulong_t pr_instr; /* current instruction */
148 149 prgregset_t pr_reg; /* general registers */
149 150 prfpregset_t pr_fpreg; /* floating-point registers */
150 151 } lwpstatus_t;
151 152
152 153 /*
153 154 * process status file. /proc/<pid>/status
154 155 */
155 156 typedef struct pstatus {
156 157 int pr_flags; /* flags (see below) */
157 158 int pr_nlwp; /* number of active lwps in the process */
158 159 pid_t pr_pid; /* process id */
159 160 pid_t pr_ppid; /* parent process id */
160 161 pid_t pr_pgid; /* process group id */
161 162 pid_t pr_sid; /* session id */
162 163 id_t pr_aslwpid; /* historical; now always zero */
163 164 id_t pr_agentid; /* lwp id of the /proc agent lwp, if any */
164 165 sigset_t pr_sigpend; /* set of process pending signals */
165 166 uintptr_t pr_brkbase; /* address of the process heap */
166 167 size_t pr_brksize; /* size of the process heap, in bytes */
167 168 uintptr_t pr_stkbase; /* address of the process stack */
168 169 size_t pr_stksize; /* size of the process stack, in bytes */
169 170 timestruc_t pr_utime; /* process user cpu time */
170 171 timestruc_t pr_stime; /* process system cpu time */
171 172 timestruc_t pr_cutime; /* sum of children's user times */
172 173 timestruc_t pr_cstime; /* sum of children's system times */
↓ open down ↓ |
96 lines elided |
↑ open up ↑ |
173 174 sigset_t pr_sigtrace; /* set of traced signals */
174 175 fltset_t pr_flttrace; /* set of traced faults */
175 176 sysset_t pr_sysentry; /* set of system calls traced on entry */
176 177 sysset_t pr_sysexit; /* set of system calls traced on exit */
177 178 char pr_dmodel; /* data model of the process (see below) */
178 179 char pr_pad[3];
179 180 taskid_t pr_taskid; /* task id */
180 181 projid_t pr_projid; /* project id */
181 182 int pr_nzomb; /* number of zombie lwps in the process */
182 183 zoneid_t pr_zoneid; /* zone id */
183 - int pr_filler[15]; /* reserved for future use */
184 + psecflags_t pr_secflags; /* security flags */
185 + int pr_filler[13]; /* reserved for future use */
184 186 lwpstatus_t pr_lwp; /* status of the representative lwp */
185 187 } pstatus_t;
186 188
187 189 /*
188 190 * pr_flags (same values appear in both pstatus_t and lwpstatus_t pr_flags).
189 191 *
190 192 * These flags do *not* apply to psinfo_t.pr_flag or lwpsinfo_t.pr_flag
191 193 * (which are both deprecated).
192 194 */
193 195 /* The following flags apply to the specific or representative lwp */
194 196 #define PR_STOPPED 0x00000001 /* lwp is stopped */
195 197 #define PR_ISTOP 0x00000002 /* lwp is stopped on an event of interest */
196 198 #define PR_DSTOP 0x00000004 /* lwp has a stop directive in effect */
197 199 #define PR_STEP 0x00000008 /* lwp has a single-step directive in effect */
198 200 #define PR_ASLEEP 0x00000010 /* lwp is sleeping in a system call */
199 201 #define PR_PCINVAL 0x00000020 /* contents of pr_instr undefined */
200 202 #define PR_ASLWP 0x00000040 /* obsolete flag; never set */
201 203 #define PR_AGENT 0x00000080 /* this lwp is the /proc agent lwp */
202 204 #define PR_DETACH 0x00000100 /* this is a detached lwp */
203 205 #define PR_DAEMON 0x00000200 /* this is a daemon lwp */
204 206 #define PR_IDLE 0x00000400 /* lwp is a cpu's idle thread */
205 207 /* The following flags apply to the process, not to an individual lwp */
206 208 #define PR_ISSYS 0x00001000 /* this is a system process */
207 209 #define PR_VFORKP 0x00002000 /* process is the parent of a vfork()d child */
208 210 #define PR_ORPHAN 0x00004000 /* process's process group is orphaned */
209 211 #define PR_NOSIGCHLD 0x00008000 /* process will not generate SIGCHLD on exit */
210 212 #define PR_WAITPID 0x00010000 /* only waitid(P_PID, pid) can reap the child */
211 213 /* The following process flags are modes settable by PCSET/PCUNSET */
212 214 #define PR_FORK 0x00100000 /* inherit-on-fork is in effect */
213 215 #define PR_RLC 0x00200000 /* run-on-last-close is in effect */
214 216 #define PR_KLC 0x00400000 /* kill-on-last-close is in effect */
215 217 #define PR_ASYNC 0x00800000 /* asynchronous-stop is in effect */
216 218 #define PR_MSACCT 0x01000000 /* micro-state usage accounting is in effect */
217 219 #define PR_BPTADJ 0x02000000 /* breakpoint trap pc adjustment is in effect */
218 220 #define PR_PTRACE 0x04000000 /* ptrace-compatibility mode is in effect */
219 221 #define PR_MSFORK 0x08000000 /* micro-state accounting inherited on fork */
220 222
221 223 /*
222 224 * See <sys/procfs_isa.h> for possible values of pr_dmodel.
223 225 */
224 226
225 227 /*
226 228 * Reasons for stopping (pr_why).
227 229 */
228 230 #define PR_REQUESTED 1
229 231 #define PR_SIGNALLED 2
230 232 #define PR_SYSENTRY 3
231 233 #define PR_SYSEXIT 4
232 234 #define PR_JOBCONTROL 5
233 235 #define PR_FAULTED 6
234 236 #define PR_SUSPENDED 7
235 237 #define PR_CHECKPOINT 8
236 238
237 239 /*
238 240 * lwp ps(1) information file. /proc/<pid>/lwp/<lwpid>/lwpsinfo
239 241 */
240 242 #define PRFNSZ 16 /* Maximum size of execed filename */
241 243 typedef struct lwpsinfo {
242 244 int pr_flag; /* lwp flags (DEPRECATED; do not use) */
243 245 id_t pr_lwpid; /* lwp id */
244 246 uintptr_t pr_addr; /* internal address of lwp */
245 247 uintptr_t pr_wchan; /* wait addr for sleeping lwp */
246 248 char pr_stype; /* synchronization event type */
247 249 char pr_state; /* numeric lwp state */
248 250 char pr_sname; /* printable character for pr_state */
249 251 char pr_nice; /* nice for cpu usage */
250 252 short pr_syscall; /* system call number (if in syscall) */
251 253 char pr_oldpri; /* pre-SVR4, low value is high priority */
252 254 char pr_cpu; /* pre-SVR4, cpu usage for scheduling */
253 255 int pr_pri; /* priority, high value is high priority */
254 256 /* The following percent number is a 16-bit binary */
255 257 /* fraction [0 .. 1] with the binary point to the */
256 258 /* right of the high-order bit (1.0 == 0x8000) */
257 259 ushort_t pr_pctcpu; /* % of recent cpu time used by this lwp */
258 260 ushort_t pr_pad;
259 261 timestruc_t pr_start; /* lwp start time, from the epoch */
260 262 timestruc_t pr_time; /* usr+sys cpu time for this lwp */
261 263 char pr_clname[PRCLSZ]; /* scheduling class name */
262 264 char pr_name[PRFNSZ]; /* name of system lwp */
263 265 processorid_t pr_onpro; /* processor which last ran this lwp */
264 266 processorid_t pr_bindpro; /* processor to which lwp is bound */
265 267 psetid_t pr_bindpset; /* processor set to which lwp is bound */
266 268 int pr_lgrp; /* lwp home lgroup */
267 269 int pr_filler[4]; /* reserved for future use */
268 270 } lwpsinfo_t;
269 271
270 272 /*
271 273 * process ps(1) information file. /proc/<pid>/psinfo
272 274 */
273 275 #define PRARGSZ 80 /* number of chars of arguments */
274 276 typedef struct psinfo {
275 277 int pr_flag; /* process flags (DEPRECATED; do not use) */
276 278 int pr_nlwp; /* number of active lwps in the process */
277 279 pid_t pr_pid; /* unique process id */
278 280 pid_t pr_ppid; /* process id of parent */
279 281 pid_t pr_pgid; /* pid of process group leader */
280 282 pid_t pr_sid; /* session id */
281 283 uid_t pr_uid; /* real user id */
282 284 uid_t pr_euid; /* effective user id */
283 285 gid_t pr_gid; /* real group id */
284 286 gid_t pr_egid; /* effective group id */
285 287 uintptr_t pr_addr; /* address of process */
286 288 size_t pr_size; /* size of process image in Kbytes */
287 289 size_t pr_rssize; /* resident set size in Kbytes */
288 290 size_t pr_pad1;
289 291 dev_t pr_ttydev; /* controlling tty device (or PRNODEV) */
290 292 /* The following percent numbers are 16-bit binary */
291 293 /* fractions [0 .. 1] with the binary point to the */
292 294 /* right of the high-order bit (1.0 == 0x8000) */
293 295 ushort_t pr_pctcpu; /* % of recent cpu time used by all lwps */
294 296 ushort_t pr_pctmem; /* % of system memory used by process */
295 297 timestruc_t pr_start; /* process start time, from the epoch */
296 298 timestruc_t pr_time; /* usr+sys cpu time for this process */
297 299 timestruc_t pr_ctime; /* usr+sys cpu time for reaped children */
298 300 char pr_fname[PRFNSZ]; /* name of execed file */
299 301 char pr_psargs[PRARGSZ]; /* initial characters of arg list */
300 302 int pr_wstat; /* if zombie, the wait() status */
301 303 int pr_argc; /* initial argument count */
302 304 uintptr_t pr_argv; /* address of initial argument vector */
303 305 uintptr_t pr_envp; /* address of initial environment vector */
304 306 char pr_dmodel; /* data model of the process */
305 307 char pr_pad2[3];
306 308 taskid_t pr_taskid; /* task id */
307 309 projid_t pr_projid; /* project id */
308 310 int pr_nzomb; /* number of zombie lwps in the process */
309 311 poolid_t pr_poolid; /* pool id */
310 312 zoneid_t pr_zoneid; /* zone id */
311 313 id_t pr_contract; /* process contract */
312 314 int pr_filler[1]; /* reserved for future use */
313 315 lwpsinfo_t pr_lwp; /* information for representative lwp */
314 316 } psinfo_t;
315 317
316 318 #define PRNODEV (dev_t)(-1) /* non-existent device */
317 319
318 320 /*
319 321 * Memory-map interface. /proc/<pid>/map /proc/<pid>/rmap
320 322 */
321 323 #define PRMAPSZ 64
322 324 typedef struct prmap {
323 325 uintptr_t pr_vaddr; /* virtual address of mapping */
324 326 size_t pr_size; /* size of mapping in bytes */
325 327 char pr_mapname[PRMAPSZ]; /* name in /proc/<pid>/object */
326 328 offset_t pr_offset; /* offset into mapped object, if any */
327 329 int pr_mflags; /* protection and attribute flags (see below) */
328 330 int pr_pagesize; /* pagesize (bytes) for this mapping */
329 331 int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
330 332 int pr_filler[1]; /* filler for future expansion */
331 333 } prmap_t;
332 334
333 335 /*
334 336 * HAT memory-map interface. /proc/<pid>/xmap
335 337 */
336 338 typedef struct prxmap {
337 339 uintptr_t pr_vaddr; /* virtual address of mapping */
338 340 size_t pr_size; /* size of mapping in bytes */
339 341 char pr_mapname[PRMAPSZ]; /* name in /proc/<pid>/object */
340 342 offset_t pr_offset; /* offset into mapped object, if any */
341 343 int pr_mflags; /* protection and attribute flags (see below) */
342 344 int pr_pagesize; /* pagesize (bytes) for this mapping */
343 345 int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
344 346 dev_t pr_dev; /* st_dev from stat64() of mapped object, or PRNODEV */
345 347 uint64_t pr_ino; /* st_ino from stat64() of mapped object, if any */
346 348 size_t pr_rss; /* pages of resident memory */
347 349 size_t pr_anon; /* pages of resident anonymous memory */
348 350 size_t pr_locked; /* pages of locked memory */
349 351 size_t pr_pad; /* currently unused */
350 352 uint64_t pr_hatpagesize; /* pagesize of the hat mapping */
351 353 #ifdef _ILP32
352 354 ulong_t pr_filler[6]; /* filler for future expansion */
353 355 #else
354 356 ulong_t pr_filler[7]; /* filler for future expansion */
355 357 #endif
356 358 } prxmap_t;
357 359
358 360
359 361 /* Protection and attribute flags */
360 362 #define MA_READ 0x04 /* readable by the traced process */
361 363 #define MA_WRITE 0x02 /* writable by the traced process */
362 364 #define MA_EXEC 0x01 /* executable by the traced process */
363 365 #define MA_SHARED 0x08 /* changes are shared by mapped object */
364 366 #define MA_ANON 0x40 /* anonymous memory (e.g. /dev/zero) */
365 367 #define MA_ISM 0x80 /* intimate shared mem (shared MMU resources) */
366 368 #define MA_NORESERVE 0x100 /* mapped with MAP_NORESERVE */
367 369 #define MA_SHM 0x200 /* System V shared memory */
368 370 #define MA_RESERVED1 0x400 /* reserved for future use */
369 371
370 372 /*
371 373 * These are obsolete and unreliable.
372 374 * They are included here only for historical compatibility.
373 375 */
374 376 #define MA_BREAK 0x10 /* grown by brk(2) */
375 377 #define MA_STACK 0x20 /* grown automatically on stack faults */
376 378
377 379 /*
378 380 * Process credentials. PCSCRED and /proc/<pid>/cred
379 381 */
380 382 typedef struct prcred {
381 383 uid_t pr_euid; /* effective user id */
382 384 uid_t pr_ruid; /* real user id */
383 385 uid_t pr_suid; /* saved user id (from exec) */
384 386 gid_t pr_egid; /* effective group id */
385 387 gid_t pr_rgid; /* real group id */
386 388 gid_t pr_sgid; /* saved group id (from exec) */
387 389 int pr_ngroups; /* number of supplementary groups */
388 390 gid_t pr_groups[1]; /* array of supplementary groups */
389 391 } prcred_t;
390 392
391 393 /*
392 394 * Process privileges. PCSPRIV and /proc/<pid>/priv
393 395 */
394 396 typedef struct prpriv {
395 397 uint32_t pr_nsets; /* number of privilege set */
396 398 uint32_t pr_setsize; /* size of privilege set */
397 399 uint32_t pr_infosize; /* size of supplementary data */
398 400 priv_chunk_t pr_sets[1]; /* array of sets */
399 401 } prpriv_t;
400 402
401 403 /*
402 404 * Watchpoint interface. PCWATCH and /proc/<pid>/watch
403 405 */
404 406 typedef struct prwatch {
405 407 uintptr_t pr_vaddr; /* virtual address of watched area */
406 408 size_t pr_size; /* size of watched area in bytes */
407 409 int pr_wflags; /* watch type flags */
408 410 int pr_pad;
409 411 } prwatch_t;
410 412
411 413 /* pr_wflags */
412 414 #define WA_READ 0x04 /* trap on read access */
413 415 #define WA_WRITE 0x02 /* trap on write access */
414 416 #define WA_EXEC 0x01 /* trap on execute access */
415 417 #define WA_TRAPAFTER 0x08 /* trap after instruction completes */
416 418
417 419 /*
418 420 * PCREAD/PCWRITE I/O interface.
419 421 */
420 422 typedef struct priovec {
421 423 void *pio_base; /* buffer in controlling process */
422 424 size_t pio_len; /* size of read/write request */
423 425 off_t pio_offset; /* virtual address in target process */
424 426 } priovec_t;
425 427
426 428 /*
427 429 * Resource usage. /proc/<pid>/usage /proc/<pid>/lwp/<lwpid>/lwpusage
428 430 */
429 431 typedef struct prusage {
430 432 id_t pr_lwpid; /* lwp id. 0: process or defunct */
431 433 int pr_count; /* number of contributing lwps */
432 434 timestruc_t pr_tstamp; /* current time stamp */
433 435 timestruc_t pr_create; /* process/lwp creation time stamp */
434 436 timestruc_t pr_term; /* process/lwp termination time stamp */
435 437 timestruc_t pr_rtime; /* total lwp real (elapsed) time */
436 438 timestruc_t pr_utime; /* user level cpu time */
437 439 timestruc_t pr_stime; /* system call cpu time */
438 440 timestruc_t pr_ttime; /* other system trap cpu time */
439 441 timestruc_t pr_tftime; /* text page fault sleep time */
440 442 timestruc_t pr_dftime; /* data page fault sleep time */
441 443 timestruc_t pr_kftime; /* kernel page fault sleep time */
442 444 timestruc_t pr_ltime; /* user lock wait sleep time */
443 445 timestruc_t pr_slptime; /* all other sleep time */
444 446 timestruc_t pr_wtime; /* wait-cpu (latency) time */
445 447 timestruc_t pr_stoptime; /* stopped time */
446 448 timestruc_t filltime[6]; /* filler for future expansion */
447 449 ulong_t pr_minf; /* minor page faults */
448 450 ulong_t pr_majf; /* major page faults */
449 451 ulong_t pr_nswap; /* swaps */
450 452 ulong_t pr_inblk; /* input blocks */
451 453 ulong_t pr_oublk; /* output blocks */
452 454 ulong_t pr_msnd; /* messages sent */
453 455 ulong_t pr_mrcv; /* messages received */
454 456 ulong_t pr_sigs; /* signals received */
455 457 ulong_t pr_vctx; /* voluntary context switches */
456 458 ulong_t pr_ictx; /* involuntary context switches */
457 459 ulong_t pr_sysc; /* system calls */
458 460 ulong_t pr_ioch; /* chars read and written */
459 461 ulong_t filler[10]; /* filler for future expansion */
460 462 } prusage_t;
461 463
462 464 /*
463 465 * Page data file. /proc/<pid>/pagedata
464 466 */
465 467
466 468 /* page data file header */
467 469 typedef struct prpageheader {
468 470 timestruc_t pr_tstamp; /* real time stamp */
469 471 long pr_nmap; /* number of address space mappings */
470 472 long pr_npage; /* total number of pages */
471 473 } prpageheader_t;
472 474
473 475 /* page data mapping header */
474 476 typedef struct prasmap {
475 477 uintptr_t pr_vaddr; /* virtual address of mapping */
476 478 size_t pr_npage; /* number of pages in mapping */
477 479 char pr_mapname[PRMAPSZ]; /* name in /proc/<pid>/object */
478 480 offset_t pr_offset; /* offset into mapped object, if any */
479 481 int pr_mflags; /* protection and attribute flags */
480 482 int pr_pagesize; /* pagesize (bytes) for this mapping */
481 483 int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
482 484 int pr_filler[1]; /* filler for future expansion */
483 485 } prasmap_t;
484 486
485 487 /*
486 488 * pr_npage bytes (plus 0-7 null bytes to round up to an 8-byte boundary)
487 489 * follow each mapping header, each containing zero or more of these flags.
488 490 */
489 491 #define PG_REFERENCED 0x02 /* page referenced since last read */
490 492 #define PG_MODIFIED 0x01 /* page modified since last read */
491 493 #define PG_HWMAPPED 0x04 /* page is present and mapped */
492 494
493 495 /*
494 496 * Open files. Only in core files (for now). Note that we'd like to use
495 497 * the stat or stat64 structure, but both of these structures are unfortunately
496 498 * not consistent between 32 and 64 bit modes. To keep our lives simpler, we
497 499 * just define our own structure with types that are not sensitive to this
498 500 * difference. Also, it turns out that pfiles omits a lot of info from the
499 501 * struct stat (e.g. times, device sizes, etc.) so we don't bother adding those
500 502 * here.
501 503 */
502 504 typedef struct prfdinfo {
503 505 int pr_fd;
504 506 mode_t pr_mode;
505 507
506 508 uid_t pr_uid;
507 509 gid_t pr_gid;
508 510
509 511 major_t pr_major; /* think stat.st_dev */
510 512 minor_t pr_minor;
511 513
512 514 major_t pr_rmajor; /* think stat.st_rdev */
513 515 minor_t pr_rminor;
514 516
515 517 ino64_t pr_ino;
516 518 off64_t pr_offset;
517 519 off64_t pr_size;
518 520
519 521 int pr_fileflags; /* fcntl(F_GETXFL), etc */
520 522 int pr_fdflags; /* fcntl(F_GETFD), etc. */
521 523
522 524 char pr_path[MAXPATHLEN];
523 525 } prfdinfo_t;
524 526
525 527 /*
526 528 * Header for /proc/<pid>/lstatus /proc/<pid>/lpsinfo /proc/<pid>/lusage
527 529 */
528 530 typedef struct prheader {
529 531 long pr_nent; /* number of entries */
530 532 long pr_entsize; /* size of each entry, in bytes */
531 533 } prheader_t;
532 534
533 535 /*
534 536 * Macros for manipulating sets of flags.
535 537 * sp must be a pointer to one of sigset_t, fltset_t, or sysset_t.
536 538 * flag must be a member of the enumeration corresponding to *sp.
537 539 */
538 540
539 541 /* turn on all flags in set */
540 542 #define prfillset(sp) \
541 543 { register int _i_ = sizeof (*(sp))/sizeof (uint32_t); \
542 544 while (_i_) ((uint32_t *)(sp))[--_i_] = (uint32_t)0xFFFFFFFF; }
543 545
544 546 /* turn off all flags in set */
545 547 #define premptyset(sp) \
546 548 { register int _i_ = sizeof (*(sp))/sizeof (uint32_t); \
547 549 while (_i_) ((uint32_t *)(sp))[--_i_] = (uint32_t)0; }
548 550
549 551 /* turn on specified flag in set */
550 552 #define praddset(sp, flag) \
551 553 ((void)(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) ? \
552 554 (((uint32_t *)(sp))[((flag)-1)/32] |= (1U<<(((flag)-1)%32))) : 0))
553 555
554 556 /* turn off specified flag in set */
555 557 #define prdelset(sp, flag) \
556 558 ((void)(((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) ? \
557 559 (((uint32_t *)(sp))[((flag)-1)/32] &= ~(1U<<(((flag)-1)%32))) : 0))
558 560
559 561 /* query: != 0 iff flag is turned on in set */
560 562 #define prismember(sp, flag) \
561 563 (((unsigned)((flag)-1) < 32*sizeof (*(sp))/sizeof (uint32_t)) && \
562 564 (((uint32_t *)(sp))[((flag)-1)/32] & (1U<<(((flag)-1)%32))))
563 565
564 566 #if defined(_SYSCALL32)
565 567
566 568 /*
567 569 * dev32_t version of PRNODEV
568 570 */
569 571 #define PRNODEV32 (dev32_t)(-1)
570 572
571 573 /*
572 574 * Kernel view of /proc structures for _ILP32 programs.
573 575 */
574 576
575 577 /*
576 578 * _ILP32 lwp status file. /proc/<pid>/lwp/<lwpid>/lwpstatus
577 579 */
578 580 typedef struct lwpstatus32 {
579 581 int pr_flags; /* flags */
580 582 id32_t pr_lwpid; /* specific lwp identifier */
581 583 short pr_why; /* reason for lwp stop, if stopped */
582 584 short pr_what; /* more detailed reason */
583 585 short pr_cursig; /* current signal, if any */
584 586 short pr_pad1;
585 587 siginfo32_t pr_info; /* info associated with signal or fault */
586 588 sigset_t pr_lwppend; /* set of signals pending to the lwp */
587 589 sigset_t pr_lwphold; /* set of signals blocked by the lwp */
588 590 struct sigaction32 pr_action; /* signal action for current signal */
589 591 stack32_t pr_altstack; /* alternate signal stack info */
590 592 caddr32_t pr_oldcontext; /* address of previous ucontext */
591 593 short pr_syscall; /* system call number (if in syscall) */
592 594 short pr_nsysarg; /* number of arguments to this syscall */
593 595 int pr_errno; /* errno for failed syscall, 0 if successful */
594 596 int32_t pr_sysarg[PRSYSARGS]; /* arguments to this syscall */
595 597 int32_t pr_rval1; /* primary syscall return value */
596 598 int32_t pr_rval2; /* second syscall return value, if any */
597 599 char pr_clname[PRCLSZ]; /* scheduling class name */
598 600 timestruc32_t pr_tstamp; /* real-time time stamp of stop */
599 601 timestruc32_t pr_utime; /* lwp user cpu time */
600 602 timestruc32_t pr_stime; /* lwp system cpu time */
601 603 int pr_filler[11 - 2 * sizeof (timestruc32_t) / sizeof (int)];
602 604 int pr_errpriv; /* missing privilege */
603 605 caddr32_t pr_ustack; /* address of stack boundary data (stack32_t) */
604 606 uint32_t pr_instr; /* current instruction */
605 607 prgregset32_t pr_reg; /* general registers */
606 608 prfpregset32_t pr_fpreg; /* floating-point registers */
607 609 } lwpstatus32_t;
608 610
609 611 /*
610 612 * _ILP32 process status file. /proc/<pid>/status
611 613 */
612 614 typedef struct pstatus32 {
613 615 int pr_flags; /* flags */
614 616 int pr_nlwp; /* number of active lwps in the process */
615 617 pid32_t pr_pid; /* process id */
616 618 pid32_t pr_ppid; /* parent process id */
617 619 pid32_t pr_pgid; /* process group id */
618 620 pid32_t pr_sid; /* session id */
619 621 id32_t pr_aslwpid; /* historical; now always zero */
620 622 id32_t pr_agentid; /* lwp id of the /proc agent lwp, if any */
621 623 sigset_t pr_sigpend; /* set of process pending signals */
622 624 caddr32_t pr_brkbase; /* address of the process heap */
623 625 size32_t pr_brksize; /* size of the process heap, in bytes */
624 626 caddr32_t pr_stkbase; /* address of the process stack */
625 627 size32_t pr_stksize; /* size of the process stack, in bytes */
626 628 timestruc32_t pr_utime; /* process user cpu time */
627 629 timestruc32_t pr_stime; /* process system cpu time */
628 630 timestruc32_t pr_cutime; /* sum of children's user times */
629 631 timestruc32_t pr_cstime; /* sum of children's system times */
↓ open down ↓ |
436 lines elided |
↑ open up ↑ |
630 632 sigset_t pr_sigtrace; /* set of traced signals */
631 633 fltset_t pr_flttrace; /* set of traced faults */
632 634 sysset_t pr_sysentry; /* set of system calls traced on entry */
633 635 sysset_t pr_sysexit; /* set of system calls traced on exit */
634 636 char pr_dmodel; /* data model of the process */
635 637 char pr_pad[3];
636 638 id32_t pr_taskid; /* task id */
637 639 id32_t pr_projid; /* project id */
638 640 int pr_nzomb; /* number of zombie lwps in the process */
639 641 id32_t pr_zoneid; /* zone id */
640 - int pr_filler[15]; /* reserved for future use */
642 + psecflags_t pr_secflags; /* security flags */
643 + int pr_filler[13]; /* reserved for future use */
641 644 lwpstatus32_t pr_lwp; /* status of the representative lwp */
642 645 } pstatus32_t;
643 646
644 647 /*
645 648 * _ILP32 lwp ps(1) information file. /proc/<pid>/lwp/<lwpid>/lwpsinfo
646 649 */
647 650 typedef struct lwpsinfo32 {
648 651 int pr_flag; /* lwp flags */
649 652 id32_t pr_lwpid; /* lwp id */
650 653 caddr32_t pr_addr; /* internal address of lwp */
651 654 caddr32_t pr_wchan; /* wait addr for sleeping lwp */
652 655 char pr_stype; /* synchronization event type */
653 656 char pr_state; /* numeric lwp state */
654 657 char pr_sname; /* printable character for pr_state */
655 658 char pr_nice; /* nice for cpu usage */
656 659 short pr_syscall; /* system call number (if in syscall) */
657 660 char pr_oldpri; /* pre-SVR4, low value is high priority */
658 661 char pr_cpu; /* pre-SVR4, cpu usage for scheduling */
659 662 int pr_pri; /* priority, high value is high priority */
660 663 /* The following percent number is a 16-bit binary */
661 664 /* fraction [0 .. 1] with the binary point to the */
662 665 /* right of the high-order bit (1.0 == 0x8000) */
663 666 ushort_t pr_pctcpu; /* % of recent cpu time used by this lwp */
664 667 ushort_t pr_pad;
665 668 timestruc32_t pr_start; /* lwp start time, from the epoch */
666 669 timestruc32_t pr_time; /* usr+sys cpu time for this lwp */
667 670 char pr_clname[PRCLSZ]; /* scheduling class name */
668 671 char pr_name[PRFNSZ]; /* name of system lwp */
669 672 processorid_t pr_onpro; /* processor which last ran this lwp */
670 673 processorid_t pr_bindpro; /* processor to which lwp is bound */
671 674 psetid_t pr_bindpset; /* processor set to which lwp is bound */
672 675 int pr_lgrp; /* lwp home lgroup */
673 676 int pr_filler[4]; /* reserved for future use */
674 677 } lwpsinfo32_t;
675 678
676 679 /*
677 680 * _ILP32 process ps(1) information file. /proc/<pid>/psinfo
678 681 */
679 682 typedef struct psinfo32 {
680 683 int pr_flag; /* process flags */
681 684 int pr_nlwp; /* number of active lwps in the process */
682 685 pid32_t pr_pid; /* unique process id */
683 686 pid32_t pr_ppid; /* process id of parent */
684 687 pid32_t pr_pgid; /* pid of process group leader */
685 688 pid32_t pr_sid; /* session id */
686 689 uid32_t pr_uid; /* real user id */
687 690 uid32_t pr_euid; /* effective user id */
688 691 gid32_t pr_gid; /* real group id */
689 692 gid32_t pr_egid; /* effective group id */
690 693 caddr32_t pr_addr; /* address of process */
691 694 size32_t pr_size; /* size of process image in Kbytes */
692 695 size32_t pr_rssize; /* resident set size in Kbytes */
693 696 size32_t pr_pad1;
694 697 dev32_t pr_ttydev; /* controlling tty device (or PRNODEV) */
695 698 ushort_t pr_pctcpu; /* % of recent cpu time used by all lwps */
696 699 ushort_t pr_pctmem; /* % of system memory used by process */
697 700 timestruc32_t pr_start; /* process start time, from the epoch */
698 701 timestruc32_t pr_time; /* usr+sys cpu time for this process */
699 702 timestruc32_t pr_ctime; /* usr+sys cpu time for reaped children */
700 703 char pr_fname[PRFNSZ]; /* name of execed file */
701 704 char pr_psargs[PRARGSZ]; /* initial characters of arg list */
702 705 int pr_wstat; /* if zombie, the wait() status */
703 706 int pr_argc; /* initial argument count */
704 707 caddr32_t pr_argv; /* address of initial argument vector */
705 708 caddr32_t pr_envp; /* address of initial environment vector */
706 709 char pr_dmodel; /* data model of the process */
707 710 char pr_pad2[3];
708 711 id32_t pr_taskid; /* task id */
709 712 id32_t pr_projid; /* project id */
710 713 int pr_nzomb; /* number of zombie lwps in the process */
711 714 id32_t pr_poolid; /* pool id */
712 715 id32_t pr_zoneid; /* zone id */
713 716 id32_t pr_contract; /* process contract */
714 717 int pr_filler[1]; /* reserved for future use */
715 718 lwpsinfo32_t pr_lwp; /* information for representative lwp */
716 719 } psinfo32_t;
717 720
718 721 /*
719 722 * _ILP32 Memory-management interface. /proc/<pid>/map /proc/<pid>/rmap
720 723 */
721 724 typedef struct prmap32 {
722 725 caddr32_t pr_vaddr; /* virtual address of mapping */
723 726 size32_t pr_size; /* size of mapping in bytes */
724 727 char pr_mapname[64]; /* name in /proc/<pid>/object */
725 728 offset_t pr_offset; /* offset into mapped object, if any */
726 729 int pr_mflags; /* protection and attribute flags */
727 730 int pr_pagesize; /* pagesize (bytes) for this mapping */
728 731 int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
729 732 int pr_filler[1]; /* filler for future expansion */
730 733 } prmap32_t;
731 734
732 735 /*
733 736 * _ILP32 HAT memory-map interface. /proc/<pid>/xmap
734 737 */
735 738 typedef struct prxmap32 {
736 739 caddr32_t pr_vaddr; /* virtual address of mapping */
737 740 size32_t pr_size; /* size of mapping in bytes */
738 741 char pr_mapname[PRMAPSZ]; /* name in /proc/<pid>/object */
739 742 offset_t pr_offset; /* offset into mapped object, if any */
740 743 int pr_mflags; /* protection and attribute flags (see below) */
741 744 int pr_pagesize; /* pagesize (bytes) for this mapping */
742 745 int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
743 746 dev32_t pr_dev; /* st_dev from stat64() of mapped object, or PRNODEV */
744 747 uint64_t pr_ino; /* st_ino from stat64() of mapped object, if any */
745 748 uint32_t pr_rss; /* pages of resident memory */
746 749 uint32_t pr_anon; /* pages of resident anonymous memory */
747 750 uint32_t pr_locked; /* pages of locked memory */
748 751 uint32_t pr_pad; /* currently unused */
749 752 uint64_t pr_hatpagesize; /* pagesize of the hat mapping */
750 753 uint32_t pr_filler[6]; /* filler for future expansion */
751 754 } prxmap32_t;
752 755
753 756 /*
754 757 * _ILP32 Process credentials. PCSCRED and /proc/<pid>/cred
755 758 */
756 759 typedef struct prcred32 {
757 760 uid32_t pr_euid; /* effective user id */
758 761 uid32_t pr_ruid; /* real user id */
759 762 uid32_t pr_suid; /* saved user id (from exec) */
760 763 gid32_t pr_egid; /* effective group id */
761 764 gid32_t pr_rgid; /* real group id */
762 765 gid32_t pr_sgid; /* saved group id (from exec) */
763 766 int pr_ngroups; /* number of supplementary groups */
764 767 gid32_t pr_groups[1]; /* array of supplementary groups */
765 768 } prcred32_t;
766 769
767 770 /*
768 771 * _ILP32 Watchpoint interface. PCWATCH and /proc/<pid>/watch
769 772 */
770 773 typedef struct prwatch32 {
771 774 caddr32_t pr_vaddr; /* virtual address of watched area */
772 775 size32_t pr_size; /* size of watched area in bytes */
773 776 int pr_wflags; /* watch type flags */
774 777 int pr_pad;
775 778 } prwatch32_t;
776 779
777 780 /*
778 781 * _ILP32 PCREAD/PCWRITE I/O interface.
779 782 */
780 783 typedef struct priovec32 {
781 784 caddr32_t pio_base; /* buffer in controlling process */
782 785 size32_t pio_len; /* size of read/write request */
783 786 off32_t pio_offset; /* virtual address in target process */
784 787 } priovec32_t;
785 788
786 789 /*
787 790 * _ILP32 Resource usage. /proc/<pid>/usage /proc/<pid>/lwp/<lwpid>/lwpusage
788 791 */
789 792 typedef struct prusage32 {
790 793 id32_t pr_lwpid; /* lwp id. 0: process or defunct */
791 794 int32_t pr_count; /* number of contributing lwps */
792 795 timestruc32_t pr_tstamp; /* current time stamp */
793 796 timestruc32_t pr_create; /* process/lwp creation time stamp */
794 797 timestruc32_t pr_term; /* process/lwp termination time stamp */
795 798 timestruc32_t pr_rtime; /* total lwp real (elapsed) time */
796 799 timestruc32_t pr_utime; /* user level cpu time */
797 800 timestruc32_t pr_stime; /* system call cpu time */
798 801 timestruc32_t pr_ttime; /* other system trap cpu time */
799 802 timestruc32_t pr_tftime; /* text page fault sleep time */
800 803 timestruc32_t pr_dftime; /* data page fault sleep time */
801 804 timestruc32_t pr_kftime; /* kernel page fault sleep time */
802 805 timestruc32_t pr_ltime; /* user lock wait sleep time */
803 806 timestruc32_t pr_slptime; /* all other sleep time */
804 807 timestruc32_t pr_wtime; /* wait-cpu (latency) time */
805 808 timestruc32_t pr_stoptime; /* stopped time */
806 809 timestruc32_t filltime[6]; /* filler for future expansion */
807 810 uint32_t pr_minf; /* minor page faults */
808 811 uint32_t pr_majf; /* major page faults */
809 812 uint32_t pr_nswap; /* swaps */
810 813 uint32_t pr_inblk; /* input blocks */
811 814 uint32_t pr_oublk; /* output blocks */
812 815 uint32_t pr_msnd; /* messages sent */
813 816 uint32_t pr_mrcv; /* messages received */
814 817 uint32_t pr_sigs; /* signals received */
815 818 uint32_t pr_vctx; /* voluntary context switches */
816 819 uint32_t pr_ictx; /* involuntary context switches */
817 820 uint32_t pr_sysc; /* system calls */
818 821 uint32_t pr_ioch; /* chars read and written */
819 822 uint32_t filler[10]; /* filler for future expansion */
820 823 } prusage32_t;
821 824
822 825 /*
823 826 * _ILP32 Page data file. /proc/<pid>/pagedata
824 827 */
825 828
826 829 /* _ILP32 page data file header */
827 830 typedef struct prpageheader32 {
828 831 timestruc32_t pr_tstamp; /* real time stamp */
829 832 int32_t pr_nmap; /* number of address space mappings */
830 833 int32_t pr_npage; /* total number of pages */
831 834 } prpageheader32_t;
832 835
833 836 /* _ILP32 page data mapping header */
834 837 typedef struct prasmap32 {
835 838 caddr32_t pr_vaddr; /* virtual address of mapping */
836 839 size32_t pr_npage; /* number of pages in mapping */
837 840 char pr_mapname[64]; /* name in /proc/<pid>/object */
838 841 offset_t pr_offset; /* offset into mapped object, if any */
839 842 int pr_mflags; /* protection and attribute flags */
840 843 int pr_pagesize; /* pagesize (bytes) for this mapping */
841 844 int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
842 845 int pr_filler[1]; /* filler for future expansion */
843 846 } prasmap32_t;
844 847
845 848 /*
846 849 * _ILP32 Header for /proc/<pid>/lstatus /proc/<pid>/lpsinfo /proc/<pid>/lusage
847 850 */
848 851 typedef struct prheader32 {
849 852 int32_t pr_nent; /* number of entries */
850 853 int32_t pr_entsize; /* size of each entry, in bytes */
851 854 } prheader32_t;
852 855
853 856 #endif /* _SYSCALL32 */
854 857
855 858 #endif /* !_KERNEL && _STRUCTURED_PROC == 0 */
856 859
857 860 #ifdef __cplusplus
858 861 }
859 862 #endif
860 863
861 864 #endif /* _SYS_PROCFS_H */
↓ open down ↓ |
211 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX