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


  47 #endif
  48 
  49 #if !defined(_KERNEL) && _STRUCTURED_PROC == 0
  50 
  51 #include <sys/old_procfs.h>
  52 
  53 #else   /* !defined(_KERNEL) && _STRUCTURED_PROC == 0 */
  54 
  55 #include <sys/feature_tests.h>
  56 #include <sys/types.h>
  57 #include <sys/time_impl.h>
  58 #include <sys/signal.h>
  59 #include <sys/siginfo.h>
  60 #include <sys/fault.h>
  61 #include <sys/syscall.h>
  62 #include <sys/pset.h>
  63 #include <sys/procfs_isa.h>
  64 #include <sys/priv.h>
  65 #include <sys/stat.h>
  66 #include <sys/param.h>

  67 
  68 /*
  69  * System call interfaces for /proc.
  70  */
  71 
  72 /*
  73  * Control codes (long values) for messages written to ctl and lwpctl files.
  74  */
  75 #define PCNULL   0L     /* null request, advance to next message */
  76 #define PCSTOP   1L     /* direct process or lwp to stop and wait for stop */
  77 #define PCDSTOP  2L     /* direct process or lwp to stop */
  78 #define PCWSTOP  3L     /* wait for process or lwp to stop, no timeout */
  79 #define PCTWSTOP 4L     /* wait for stop, with long millisecond timeout arg */
  80 #define PCRUN    5L     /* make process/lwp runnable, w/ long flags argument */
  81 #define PCCSIG   6L     /* clear current signal from lwp */
  82 #define PCCFAULT 7L     /* clear current fault from lwp */
  83 #define PCSSIG   8L     /* set current signal from siginfo_t argument */
  84 #define PCKILL   9L     /* post a signal to process/lwp, long argument */
  85 #define PCUNKILL 10L    /* delete a pending signal from process/lwp, long arg */
  86 #define PCSHOLD  11L    /* set lwp signal mask from sigset_t argument */


 163         id_t    pr_agentid;     /* lwp id of the /proc agent lwp, if any */
 164         sigset_t pr_sigpend;    /* set of process pending signals */
 165         uintptr_t pr_brkbase;   /* address of the process heap */
 166         size_t  pr_brksize;     /* size of the process heap, in bytes */
 167         uintptr_t pr_stkbase;   /* address of the process stack */
 168         size_t  pr_stksize;     /* size of the process stack, in bytes */
 169         timestruc_t pr_utime;   /* process user cpu time */
 170         timestruc_t pr_stime;   /* process system cpu time */
 171         timestruc_t pr_cutime;  /* sum of children's user times */
 172         timestruc_t pr_cstime;  /* sum of children's system times */
 173         sigset_t pr_sigtrace;   /* set of traced signals */
 174         fltset_t pr_flttrace;   /* set of traced faults */
 175         sysset_t pr_sysentry;   /* set of system calls traced on entry */
 176         sysset_t pr_sysexit;    /* set of system calls traced on exit */
 177         char    pr_dmodel;      /* data model of the process (see below) */
 178         char    pr_pad[3];
 179         taskid_t pr_taskid;     /* task id */
 180         projid_t pr_projid;     /* project id */
 181         int     pr_nzomb;       /* number of zombie lwps in the process */
 182         zoneid_t pr_zoneid;     /* zone id */
 183         int     pr_filler[15];  /* reserved for future use */

 184         lwpstatus_t pr_lwp;     /* status of the representative lwp */
 185 } pstatus_t;
 186 
 187 /*
 188  * pr_flags (same values appear in both pstatus_t and lwpstatus_t pr_flags).
 189  *
 190  * These flags do *not* apply to psinfo_t.pr_flag or lwpsinfo_t.pr_flag
 191  * (which are both deprecated).
 192  */
 193 /* The following flags apply to the specific or representative lwp */
 194 #define PR_STOPPED 0x00000001   /* lwp is stopped */
 195 #define PR_ISTOP   0x00000002   /* lwp is stopped on an event of interest */
 196 #define PR_DSTOP   0x00000004   /* lwp has a stop directive in effect */
 197 #define PR_STEP    0x00000008   /* lwp has a single-step directive in effect */
 198 #define PR_ASLEEP  0x00000010   /* lwp is sleeping in a system call */
 199 #define PR_PCINVAL 0x00000020   /* contents of pr_instr undefined */
 200 #define PR_ASLWP   0x00000040   /* obsolete flag; never set */
 201 #define PR_AGENT   0x00000080   /* this lwp is the /proc agent lwp */
 202 #define PR_DETACH  0x00000100   /* this is a detached lwp */
 203 #define PR_DAEMON  0x00000200   /* this is a daemon lwp */


 620         id32_t  pr_agentid;     /* lwp id of the /proc agent lwp, if any */
 621         sigset_t pr_sigpend;    /* set of process pending signals */
 622         caddr32_t pr_brkbase;   /* address of the process heap */
 623         size32_t pr_brksize;    /* size of the process heap, in bytes */
 624         caddr32_t pr_stkbase;   /* address of the process stack */
 625         size32_t pr_stksize;    /* size of the process stack, in bytes */
 626         timestruc32_t pr_utime; /* process user cpu time */
 627         timestruc32_t pr_stime; /* process system cpu time */
 628         timestruc32_t pr_cutime;        /* sum of children's user times */
 629         timestruc32_t pr_cstime;        /* sum of children's system times */
 630         sigset_t pr_sigtrace;   /* set of traced signals */
 631         fltset_t pr_flttrace;   /* set of traced faults */
 632         sysset_t pr_sysentry;   /* set of system calls traced on entry */
 633         sysset_t pr_sysexit;    /* set of system calls traced on exit */
 634         char    pr_dmodel;      /* data model of the process */
 635         char    pr_pad[3];
 636         id32_t  pr_taskid;      /* task id */
 637         id32_t  pr_projid;      /* project id */
 638         int     pr_nzomb;       /* number of zombie lwps in the process */
 639         id32_t  pr_zoneid;      /* zone id */
 640         int     pr_filler[15];  /* reserved for future use */

 641         lwpstatus32_t pr_lwp;   /* status of the representative lwp */
 642 } pstatus32_t;
 643 
 644 /*
 645  * _ILP32 lwp ps(1) information file.  /proc/<pid>/lwp/<lwpid>/lwpsinfo
 646  */
 647 typedef struct lwpsinfo32 {
 648         int     pr_flag;        /* lwp flags */
 649         id32_t  pr_lwpid;       /* lwp id */
 650         caddr32_t pr_addr;      /* internal address of lwp */
 651         caddr32_t pr_wchan;     /* wait addr for sleeping lwp */
 652         char    pr_stype;       /* synchronization event type */
 653         char    pr_state;       /* numeric lwp state */
 654         char    pr_sname;       /* printable character for pr_state */
 655         char    pr_nice;        /* nice for cpu usage */
 656         short   pr_syscall;     /* system call number (if in syscall) */
 657         char    pr_oldpri;      /* pre-SVR4, low value is high priority */
 658         char    pr_cpu;         /* pre-SVR4, cpu usage for scheduling */
 659         int     pr_pri;         /* priority, high value is high priority */
 660                         /* The following percent number is a 16-bit binary */




  47 #endif
  48 
  49 #if !defined(_KERNEL) && _STRUCTURED_PROC == 0
  50 
  51 #include <sys/old_procfs.h>
  52 
  53 #else   /* !defined(_KERNEL) && _STRUCTURED_PROC == 0 */
  54 
  55 #include <sys/feature_tests.h>
  56 #include <sys/types.h>
  57 #include <sys/time_impl.h>
  58 #include <sys/signal.h>
  59 #include <sys/siginfo.h>
  60 #include <sys/fault.h>
  61 #include <sys/syscall.h>
  62 #include <sys/pset.h>
  63 #include <sys/procfs_isa.h>
  64 #include <sys/priv.h>
  65 #include <sys/stat.h>
  66 #include <sys/param.h>
  67 #include <sys/secflags.h>
  68 
  69 /*
  70  * System call interfaces for /proc.
  71  */
  72 
  73 /*
  74  * Control codes (long values) for messages written to ctl and lwpctl files.
  75  */
  76 #define PCNULL   0L     /* null request, advance to next message */
  77 #define PCSTOP   1L     /* direct process or lwp to stop and wait for stop */
  78 #define PCDSTOP  2L     /* direct process or lwp to stop */
  79 #define PCWSTOP  3L     /* wait for process or lwp to stop, no timeout */
  80 #define PCTWSTOP 4L     /* wait for stop, with long millisecond timeout arg */
  81 #define PCRUN    5L     /* make process/lwp runnable, w/ long flags argument */
  82 #define PCCSIG   6L     /* clear current signal from lwp */
  83 #define PCCFAULT 7L     /* clear current fault from lwp */
  84 #define PCSSIG   8L     /* set current signal from siginfo_t argument */
  85 #define PCKILL   9L     /* post a signal to process/lwp, long argument */
  86 #define PCUNKILL 10L    /* delete a pending signal from process/lwp, long arg */
  87 #define PCSHOLD  11L    /* set lwp signal mask from sigset_t argument */


 164         id_t    pr_agentid;     /* lwp id of the /proc agent lwp, if any */
 165         sigset_t pr_sigpend;    /* set of process pending signals */
 166         uintptr_t pr_brkbase;   /* address of the process heap */
 167         size_t  pr_brksize;     /* size of the process heap, in bytes */
 168         uintptr_t pr_stkbase;   /* address of the process stack */
 169         size_t  pr_stksize;     /* size of the process stack, in bytes */
 170         timestruc_t pr_utime;   /* process user cpu time */
 171         timestruc_t pr_stime;   /* process system cpu time */
 172         timestruc_t pr_cutime;  /* sum of children's user times */
 173         timestruc_t pr_cstime;  /* sum of children's system times */
 174         sigset_t pr_sigtrace;   /* set of traced signals */
 175         fltset_t pr_flttrace;   /* set of traced faults */
 176         sysset_t pr_sysentry;   /* set of system calls traced on entry */
 177         sysset_t pr_sysexit;    /* set of system calls traced on exit */
 178         char    pr_dmodel;      /* data model of the process (see below) */
 179         char    pr_pad[3];
 180         taskid_t pr_taskid;     /* task id */
 181         projid_t pr_projid;     /* project id */
 182         int     pr_nzomb;       /* number of zombie lwps in the process */
 183         zoneid_t pr_zoneid;     /* zone id */
 184         psecflags_t pr_secflags; /* security flags */
 185         int     pr_filler[13];  /* reserved for future use */
 186         lwpstatus_t pr_lwp;     /* status of the representative lwp */
 187 } pstatus_t;
 188 
 189 /*
 190  * pr_flags (same values appear in both pstatus_t and lwpstatus_t pr_flags).
 191  *
 192  * These flags do *not* apply to psinfo_t.pr_flag or lwpsinfo_t.pr_flag
 193  * (which are both deprecated).
 194  */
 195 /* The following flags apply to the specific or representative lwp */
 196 #define PR_STOPPED 0x00000001   /* lwp is stopped */
 197 #define PR_ISTOP   0x00000002   /* lwp is stopped on an event of interest */
 198 #define PR_DSTOP   0x00000004   /* lwp has a stop directive in effect */
 199 #define PR_STEP    0x00000008   /* lwp has a single-step directive in effect */
 200 #define PR_ASLEEP  0x00000010   /* lwp is sleeping in a system call */
 201 #define PR_PCINVAL 0x00000020   /* contents of pr_instr undefined */
 202 #define PR_ASLWP   0x00000040   /* obsolete flag; never set */
 203 #define PR_AGENT   0x00000080   /* this lwp is the /proc agent lwp */
 204 #define PR_DETACH  0x00000100   /* this is a detached lwp */
 205 #define PR_DAEMON  0x00000200   /* this is a daemon lwp */


 622         id32_t  pr_agentid;     /* lwp id of the /proc agent lwp, if any */
 623         sigset_t pr_sigpend;    /* set of process pending signals */
 624         caddr32_t pr_brkbase;   /* address of the process heap */
 625         size32_t pr_brksize;    /* size of the process heap, in bytes */
 626         caddr32_t pr_stkbase;   /* address of the process stack */
 627         size32_t pr_stksize;    /* size of the process stack, in bytes */
 628         timestruc32_t pr_utime; /* process user cpu time */
 629         timestruc32_t pr_stime; /* process system cpu time */
 630         timestruc32_t pr_cutime;        /* sum of children's user times */
 631         timestruc32_t pr_cstime;        /* sum of children's system times */
 632         sigset_t pr_sigtrace;   /* set of traced signals */
 633         fltset_t pr_flttrace;   /* set of traced faults */
 634         sysset_t pr_sysentry;   /* set of system calls traced on entry */
 635         sysset_t pr_sysexit;    /* set of system calls traced on exit */
 636         char    pr_dmodel;      /* data model of the process */
 637         char    pr_pad[3];
 638         id32_t  pr_taskid;      /* task id */
 639         id32_t  pr_projid;      /* project id */
 640         int     pr_nzomb;       /* number of zombie lwps in the process */
 641         id32_t  pr_zoneid;      /* zone id */
 642         psecflags_t pr_secflags; /* security flags */
 643         int     pr_filler[13];  /* reserved for future use */
 644         lwpstatus32_t pr_lwp;   /* status of the representative lwp */
 645 } pstatus32_t;
 646 
 647 /*
 648  * _ILP32 lwp ps(1) information file.  /proc/<pid>/lwp/<lwpid>/lwpsinfo
 649  */
 650 typedef struct lwpsinfo32 {
 651         int     pr_flag;        /* lwp flags */
 652         id32_t  pr_lwpid;       /* lwp id */
 653         caddr32_t pr_addr;      /* internal address of lwp */
 654         caddr32_t pr_wchan;     /* wait addr for sleeping lwp */
 655         char    pr_stype;       /* synchronization event type */
 656         char    pr_state;       /* numeric lwp state */
 657         char    pr_sname;       /* printable character for pr_state */
 658         char    pr_nice;        /* nice for cpu usage */
 659         short   pr_syscall;     /* system call number (if in syscall) */
 660         char    pr_oldpri;      /* pre-SVR4, low value is high priority */
 661         char    pr_cpu;         /* pre-SVR4, cpu usage for scheduling */
 662         int     pr_pri;         /* priority, high value is high priority */
 663                         /* The following percent number is a 16-bit binary */