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


 876         sp->pr_brksize = p->p_brksize;
 877         sp->pr_stkbase = (uintptr_t)prgetstackbase(p);
 878         sp->pr_stksize = p->p_stksize;
 879         sp->pr_pid = p->p_pid;
 880         if (curproc->p_zone->zone_id != GLOBAL_ZONEID &&
 881             (p->p_flag & SZONETOP)) {
 882                 ASSERT(p->p_zone->zone_id != GLOBAL_ZONEID);
 883                 /*
 884                  * Inside local zones, fake zsched's pid as parent pids for
 885                  * processes which reference processes outside of the zone.
 886                  */
 887                 sp->pr_ppid = curproc->p_zone->zone_zsched->p_pid;
 888         } else {
 889                 sp->pr_ppid = p->p_ppid;
 890         }
 891         sp->pr_pgid  = p->p_pgrp;
 892         sp->pr_sid   = p->p_sessp->s_sid;
 893         sp->pr_taskid = p->p_task->tk_tkid;
 894         sp->pr_projid = p->p_task->tk_proj->kpj_id;
 895         sp->pr_zoneid = p->p_zone->zone_id;

 896         hrt2ts(mstate_aggr_state(p, LMS_USER), &sp->pr_utime);
 897         hrt2ts(mstate_aggr_state(p, LMS_SYSTEM), &sp->pr_stime);
 898         TICK_TO_TIMESTRUC(p->p_cutime, &sp->pr_cutime);
 899         TICK_TO_TIMESTRUC(p->p_cstime, &sp->pr_cstime);
 900         prassignset(&sp->pr_sigtrace, &p->p_sigmask);
 901         prassignset(&sp->pr_flttrace, &p->p_fltmask);
 902         prassignset(&sp->pr_sysentry, &PTOU(p)->u_entrymask);
 903         prassignset(&sp->pr_sysexit, &PTOU(p)->u_exitmask);
 904         switch (p->p_model) {
 905         case DATAMODEL_ILP32:
 906                 sp->pr_dmodel = PR_MODEL_ILP32;
 907                 break;
 908         case DATAMODEL_LP64:
 909                 sp->pr_dmodel = PR_MODEL_LP64;
 910                 break;
 911         }
 912         if (p->p_agenttp)
 913                 sp->pr_agentid = p->p_agenttp->t_tid;
 914 
 915         /* get the chosen lwp's status */


1099         sp->pr_brksize = (uint32_t)p->p_brksize;
1100         sp->pr_stkbase = (uint32_t)(uintptr_t)prgetstackbase(p);
1101         sp->pr_stksize = (uint32_t)p->p_stksize;
1102         sp->pr_pid   = p->p_pid;
1103         if (curproc->p_zone->zone_id != GLOBAL_ZONEID &&
1104             (p->p_flag & SZONETOP)) {
1105                 ASSERT(p->p_zone->zone_id != GLOBAL_ZONEID);
1106                 /*
1107                  * Inside local zones, fake zsched's pid as parent pids for
1108                  * processes which reference processes outside of the zone.
1109                  */
1110                 sp->pr_ppid = curproc->p_zone->zone_zsched->p_pid;
1111         } else {
1112                 sp->pr_ppid = p->p_ppid;
1113         }
1114         sp->pr_pgid  = p->p_pgrp;
1115         sp->pr_sid   = p->p_sessp->s_sid;
1116         sp->pr_taskid = p->p_task->tk_tkid;
1117         sp->pr_projid = p->p_task->tk_proj->kpj_id;
1118         sp->pr_zoneid = p->p_zone->zone_id;

1119         hrt2ts32(mstate_aggr_state(p, LMS_USER), &sp->pr_utime);
1120         hrt2ts32(mstate_aggr_state(p, LMS_SYSTEM), &sp->pr_stime);
1121         TICK_TO_TIMESTRUC32(p->p_cutime, &sp->pr_cutime);
1122         TICK_TO_TIMESTRUC32(p->p_cstime, &sp->pr_cstime);
1123         prassignset(&sp->pr_sigtrace, &p->p_sigmask);
1124         prassignset(&sp->pr_flttrace, &p->p_fltmask);
1125         prassignset(&sp->pr_sysentry, &PTOU(p)->u_entrymask);
1126         prassignset(&sp->pr_sysexit, &PTOU(p)->u_exitmask);
1127         switch (p->p_model) {
1128         case DATAMODEL_ILP32:
1129                 sp->pr_dmodel = PR_MODEL_ILP32;
1130                 break;
1131         case DATAMODEL_LP64:
1132                 sp->pr_dmodel = PR_MODEL_LP64;
1133                 break;
1134         }
1135         if (p->p_agenttp)
1136                 sp->pr_agentid = p->p_agenttp->t_tid;
1137 
1138         /* get the chosen lwp's status */




 876         sp->pr_brksize = p->p_brksize;
 877         sp->pr_stkbase = (uintptr_t)prgetstackbase(p);
 878         sp->pr_stksize = p->p_stksize;
 879         sp->pr_pid = p->p_pid;
 880         if (curproc->p_zone->zone_id != GLOBAL_ZONEID &&
 881             (p->p_flag & SZONETOP)) {
 882                 ASSERT(p->p_zone->zone_id != GLOBAL_ZONEID);
 883                 /*
 884                  * Inside local zones, fake zsched's pid as parent pids for
 885                  * processes which reference processes outside of the zone.
 886                  */
 887                 sp->pr_ppid = curproc->p_zone->zone_zsched->p_pid;
 888         } else {
 889                 sp->pr_ppid = p->p_ppid;
 890         }
 891         sp->pr_pgid  = p->p_pgrp;
 892         sp->pr_sid   = p->p_sessp->s_sid;
 893         sp->pr_taskid = p->p_task->tk_tkid;
 894         sp->pr_projid = p->p_task->tk_proj->kpj_id;
 895         sp->pr_zoneid = p->p_zone->zone_id;
 896         bcopy(&p->p_secflags, &sp->pr_secflags, sizeof (psecflags_t));
 897         hrt2ts(mstate_aggr_state(p, LMS_USER), &sp->pr_utime);
 898         hrt2ts(mstate_aggr_state(p, LMS_SYSTEM), &sp->pr_stime);
 899         TICK_TO_TIMESTRUC(p->p_cutime, &sp->pr_cutime);
 900         TICK_TO_TIMESTRUC(p->p_cstime, &sp->pr_cstime);
 901         prassignset(&sp->pr_sigtrace, &p->p_sigmask);
 902         prassignset(&sp->pr_flttrace, &p->p_fltmask);
 903         prassignset(&sp->pr_sysentry, &PTOU(p)->u_entrymask);
 904         prassignset(&sp->pr_sysexit, &PTOU(p)->u_exitmask);
 905         switch (p->p_model) {
 906         case DATAMODEL_ILP32:
 907                 sp->pr_dmodel = PR_MODEL_ILP32;
 908                 break;
 909         case DATAMODEL_LP64:
 910                 sp->pr_dmodel = PR_MODEL_LP64;
 911                 break;
 912         }
 913         if (p->p_agenttp)
 914                 sp->pr_agentid = p->p_agenttp->t_tid;
 915 
 916         /* get the chosen lwp's status */


1100         sp->pr_brksize = (uint32_t)p->p_brksize;
1101         sp->pr_stkbase = (uint32_t)(uintptr_t)prgetstackbase(p);
1102         sp->pr_stksize = (uint32_t)p->p_stksize;
1103         sp->pr_pid   = p->p_pid;
1104         if (curproc->p_zone->zone_id != GLOBAL_ZONEID &&
1105             (p->p_flag & SZONETOP)) {
1106                 ASSERT(p->p_zone->zone_id != GLOBAL_ZONEID);
1107                 /*
1108                  * Inside local zones, fake zsched's pid as parent pids for
1109                  * processes which reference processes outside of the zone.
1110                  */
1111                 sp->pr_ppid = curproc->p_zone->zone_zsched->p_pid;
1112         } else {
1113                 sp->pr_ppid = p->p_ppid;
1114         }
1115         sp->pr_pgid  = p->p_pgrp;
1116         sp->pr_sid   = p->p_sessp->s_sid;
1117         sp->pr_taskid = p->p_task->tk_tkid;
1118         sp->pr_projid = p->p_task->tk_proj->kpj_id;
1119         sp->pr_zoneid = p->p_zone->zone_id;
1120         bcopy(&p->p_secflags, &sp->pr_secflags, sizeof (psecflags_t));
1121         hrt2ts32(mstate_aggr_state(p, LMS_USER), &sp->pr_utime);
1122         hrt2ts32(mstate_aggr_state(p, LMS_SYSTEM), &sp->pr_stime);
1123         TICK_TO_TIMESTRUC32(p->p_cutime, &sp->pr_cutime);
1124         TICK_TO_TIMESTRUC32(p->p_cstime, &sp->pr_cstime);
1125         prassignset(&sp->pr_sigtrace, &p->p_sigmask);
1126         prassignset(&sp->pr_flttrace, &p->p_fltmask);
1127         prassignset(&sp->pr_sysentry, &PTOU(p)->u_entrymask);
1128         prassignset(&sp->pr_sysexit, &PTOU(p)->u_exitmask);
1129         switch (p->p_model) {
1130         case DATAMODEL_ILP32:
1131                 sp->pr_dmodel = PR_MODEL_ILP32;
1132                 break;
1133         case DATAMODEL_LP64:
1134                 sp->pr_dmodel = PR_MODEL_LP64;
1135                 break;
1136         }
1137         if (p->p_agenttp)
1138                 sp->pr_agentid = p->p_agenttp->t_tid;
1139 
1140         /* get the chosen lwp's status */