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


 181         SCALAR_FIELD(pstatus_t,         pr_aslwpid,     1);
 182         SCALAR_FIELD(pstatus_t,         pr_agentid,     1);
 183         SCALAR_FIELD(pstatus_t,         pr_sigpend,     0);
 184         SCALAR_FIELD(pstatus_t,         pr_brkbase,     0);
 185         SCALAR_FIELD(pstatus_t,         pr_brksize,     0);
 186         SCALAR_FIELD(pstatus_t,         pr_stkbase,     0);
 187         SCALAR_FIELD(pstatus_t,         pr_stksize,     0);
 188         SCALAR_FIELD(pstatus_t,         pr_utime,       0);
 189         SCALAR_FIELD(pstatus_t,         pr_stime,       0);
 190         SCALAR_FIELD(pstatus_t,         pr_cutime,      0);
 191         SCALAR_FIELD(pstatus_t,         pr_cstime,      0);
 192         SCALAR_FIELD(pstatus_t,         pr_sigtrace,    0);
 193         SCALAR_FIELD(pstatus_t,         pr_flttrace,    0);
 194         SCALAR_FIELD(pstatus_t,         pr_sysentry,    0);
 195         SCALAR_FIELD(pstatus_t,         pr_sysexit,     0);
 196         SCALAR_FIELD(pstatus_t,         pr_dmodel,      0);
 197         SCALAR_FIELD(pstatus_t,         pr_taskid,      1);
 198         SCALAR_FIELD(pstatus_t,         pr_projid,      1);
 199         SCALAR_FIELD(pstatus_t,         pr_nzomb,       1);
 200         SCALAR_FIELD(pstatus_t,         pr_zoneid,      1);

 201         SCALAR_FIELD(pstatus_t,         pr_lwp,         0);
 202 
 203         END;
 204 }
 205 
 206 
 207 /* prstatus_t, <sys/old_procfs.h> */
 208 static void
 209 gen_prstatus(void)
 210 {
 211         START(prstatus, prstatus_t);
 212 
 213         SCALAR_FIELD(prstatus_t,        pr_flags,       1);
 214         SCALAR_FIELD(prstatus_t,        pr_why,         1);
 215         SCALAR_FIELD(prstatus_t,        pr_what,        1);
 216         SCALAR_FIELD(prstatus_t,        pr_info,        0);
 217         SCALAR_FIELD(prstatus_t,        pr_cursig,      1);
 218         SCALAR_FIELD(prstatus_t,        pr_nlwp,        0);
 219         SCALAR_FIELD(prstatus_t,        pr_sigpend,     0);
 220         SCALAR_FIELD(prstatus_t,        pr_sighold,     0);


 570         START(prfdinfo, prfdinfo_t);
 571 
 572         SCALAR_FIELD(prfdinfo_t,        pr_fd,          0);
 573         SCALAR_FIELD(prfdinfo_t,        pr_mode,        0);
 574         SCALAR_FIELD(prfdinfo_t,        pr_uid,         0);
 575         SCALAR_FIELD(prfdinfo_t,        pr_gid,         0);
 576         SCALAR_FIELD(prfdinfo_t,        pr_major,       0);
 577         SCALAR_FIELD(prfdinfo_t,        pr_minor,       0);
 578         SCALAR_FIELD(prfdinfo_t,        pr_rmajor,      0);
 579         SCALAR_FIELD(prfdinfo_t,        pr_rminor,      0);
 580         SCALAR_FIELD(prfdinfo_t,        pr_ino,         0);
 581         SCALAR_FIELD(prfdinfo_t,        pr_offset,      0);
 582         SCALAR_FIELD(prfdinfo_t,        pr_size,        0);
 583         SCALAR_FIELD(prfdinfo_t,        pr_fileflags,   0);
 584         SCALAR_FIELD(prfdinfo_t,        pr_fdflags,     0);
 585         ARRAY_FIELD(prfdinfo_t,         pr_path,        0);
 586 
 587         END;
 588 }
 589 









 590 
 591 /*ARGSUSED*/
 592 int
 593 main(int argc, char *argv[])
 594 {
 595         const char *fmt = "\t&%s_layout,\n";
 596 
 597         /* get obj file for input */
 598         if (argc < 3) {
 599                 (void) fprintf(stderr,
 600                     "usage: %s {object_file} {MACH}\n", argv[0]);
 601                 exit(1);
 602         }
 603 
 604         objfile = argv[1];
 605         machname = argv[2];
 606 
 607         get_ctf_file(objfile);
 608 
 609         (void) printf("#include <struct_layout.h>\n");


 611         gen_auxv();
 612         gen_prgregset();
 613         gen_lwpstatus();
 614         gen_pstatus();
 615         gen_prstatus();
 616         gen_psinfo();
 617         gen_prpsinfo();
 618         gen_lwpsinfo();
 619         gen_prcred();
 620         gen_prpriv();
 621         gen_priv_impl_info();
 622         gen_fltset();
 623         gen_siginfo();
 624         gen_sigset();
 625         gen_sigaction();
 626         gen_stack();
 627         gen_sysset();
 628         gen_timestruc();
 629         gen_utsname();
 630         gen_prfdinfo();

 631 
 632 
 633         /*
 634          * Generate the full arch_layout description
 635          */
 636         (void) printf(
 637             "\n\n\n\nstatic const sl_arch_layout_t layout_%s = {\n",
 638             machname);
 639         (void) printf(fmt, "auxv");
 640         (void) printf(fmt, "fltset");
 641         (void) printf(fmt, "lwpsinfo");
 642         (void) printf(fmt, "lwpstatus");
 643         (void) printf(fmt, "prcred");
 644         (void) printf(fmt, "priv_impl_info");
 645         (void) printf(fmt, "prpriv");
 646         (void) printf(fmt, "psinfo");
 647         (void) printf(fmt, "pstatus");
 648         (void) printf(fmt, "prgregset");
 649         (void) printf(fmt, "prpsinfo");
 650         (void) printf(fmt, "prstatus");
 651         (void) printf(fmt, "sigaction");
 652         (void) printf(fmt, "siginfo");
 653         (void) printf(fmt, "sigset");
 654         (void) printf(fmt, "stack");
 655         (void) printf(fmt, "sysset");
 656         (void) printf(fmt, "timestruc");
 657         (void) printf(fmt, "utsname");
 658         (void) printf(fmt, "prfdinfo");

 659         (void) printf("};\n");
 660 
 661         /*
 662          * A public function, to make the information available
 663          */
 664         (void) printf("\n\nconst sl_arch_layout_t *\n");
 665         (void) printf("struct_layout_%s(void)\n", machname);
 666         (void) printf("{\n\treturn (&layout_%s);\n}\n", machname);
 667 
 668         return (0);
 669 }
 670 
 671 /*
 672  * Helper functions using the CTF library to get type info.
 673  */
 674 
 675 static void
 676 get_ctf_file(char *fname)
 677 {
 678         int ctferr;




 181         SCALAR_FIELD(pstatus_t,         pr_aslwpid,     1);
 182         SCALAR_FIELD(pstatus_t,         pr_agentid,     1);
 183         SCALAR_FIELD(pstatus_t,         pr_sigpend,     0);
 184         SCALAR_FIELD(pstatus_t,         pr_brkbase,     0);
 185         SCALAR_FIELD(pstatus_t,         pr_brksize,     0);
 186         SCALAR_FIELD(pstatus_t,         pr_stkbase,     0);
 187         SCALAR_FIELD(pstatus_t,         pr_stksize,     0);
 188         SCALAR_FIELD(pstatus_t,         pr_utime,       0);
 189         SCALAR_FIELD(pstatus_t,         pr_stime,       0);
 190         SCALAR_FIELD(pstatus_t,         pr_cutime,      0);
 191         SCALAR_FIELD(pstatus_t,         pr_cstime,      0);
 192         SCALAR_FIELD(pstatus_t,         pr_sigtrace,    0);
 193         SCALAR_FIELD(pstatus_t,         pr_flttrace,    0);
 194         SCALAR_FIELD(pstatus_t,         pr_sysentry,    0);
 195         SCALAR_FIELD(pstatus_t,         pr_sysexit,     0);
 196         SCALAR_FIELD(pstatus_t,         pr_dmodel,      0);
 197         SCALAR_FIELD(pstatus_t,         pr_taskid,      1);
 198         SCALAR_FIELD(pstatus_t,         pr_projid,      1);
 199         SCALAR_FIELD(pstatus_t,         pr_nzomb,       1);
 200         SCALAR_FIELD(pstatus_t,         pr_zoneid,      1);
 201         SCALAR_FIELD(pstatus_t,         pr_secflags,    0);
 202         SCALAR_FIELD(pstatus_t,         pr_lwp,         0);
 203 
 204         END;
 205 }
 206 
 207 
 208 /* prstatus_t, <sys/old_procfs.h> */
 209 static void
 210 gen_prstatus(void)
 211 {
 212         START(prstatus, prstatus_t);
 213 
 214         SCALAR_FIELD(prstatus_t,        pr_flags,       1);
 215         SCALAR_FIELD(prstatus_t,        pr_why,         1);
 216         SCALAR_FIELD(prstatus_t,        pr_what,        1);
 217         SCALAR_FIELD(prstatus_t,        pr_info,        0);
 218         SCALAR_FIELD(prstatus_t,        pr_cursig,      1);
 219         SCALAR_FIELD(prstatus_t,        pr_nlwp,        0);
 220         SCALAR_FIELD(prstatus_t,        pr_sigpend,     0);
 221         SCALAR_FIELD(prstatus_t,        pr_sighold,     0);


 571         START(prfdinfo, prfdinfo_t);
 572 
 573         SCALAR_FIELD(prfdinfo_t,        pr_fd,          0);
 574         SCALAR_FIELD(prfdinfo_t,        pr_mode,        0);
 575         SCALAR_FIELD(prfdinfo_t,        pr_uid,         0);
 576         SCALAR_FIELD(prfdinfo_t,        pr_gid,         0);
 577         SCALAR_FIELD(prfdinfo_t,        pr_major,       0);
 578         SCALAR_FIELD(prfdinfo_t,        pr_minor,       0);
 579         SCALAR_FIELD(prfdinfo_t,        pr_rmajor,      0);
 580         SCALAR_FIELD(prfdinfo_t,        pr_rminor,      0);
 581         SCALAR_FIELD(prfdinfo_t,        pr_ino,         0);
 582         SCALAR_FIELD(prfdinfo_t,        pr_offset,      0);
 583         SCALAR_FIELD(prfdinfo_t,        pr_size,        0);
 584         SCALAR_FIELD(prfdinfo_t,        pr_fileflags,   0);
 585         SCALAR_FIELD(prfdinfo_t,        pr_fdflags,     0);
 586         ARRAY_FIELD(prfdinfo_t,         pr_path,        0);
 587 
 588         END;
 589 }
 590 
 591 static void
 592 gen_psecflags(void)
 593 {
 594         START(psecflags, psecflags_t);
 595         SCALAR_FIELD(psecflags_t, psf_effective, 0);
 596         SCALAR_FIELD(psecflags_t, psf_inherit, 0);
 597         END;
 598 }
 599 
 600 
 601 /*ARGSUSED*/
 602 int
 603 main(int argc, char *argv[])
 604 {
 605         const char *fmt = "\t&%s_layout,\n";
 606 
 607         /* get obj file for input */
 608         if (argc < 3) {
 609                 (void) fprintf(stderr,
 610                     "usage: %s {object_file} {MACH}\n", argv[0]);
 611                 exit(1);
 612         }
 613 
 614         objfile = argv[1];
 615         machname = argv[2];
 616 
 617         get_ctf_file(objfile);
 618 
 619         (void) printf("#include <struct_layout.h>\n");


 621         gen_auxv();
 622         gen_prgregset();
 623         gen_lwpstatus();
 624         gen_pstatus();
 625         gen_prstatus();
 626         gen_psinfo();
 627         gen_prpsinfo();
 628         gen_lwpsinfo();
 629         gen_prcred();
 630         gen_prpriv();
 631         gen_priv_impl_info();
 632         gen_fltset();
 633         gen_siginfo();
 634         gen_sigset();
 635         gen_sigaction();
 636         gen_stack();
 637         gen_sysset();
 638         gen_timestruc();
 639         gen_utsname();
 640         gen_prfdinfo();
 641         gen_psecflags();
 642 
 643 
 644         /*
 645          * Generate the full arch_layout description
 646          */
 647         (void) printf(
 648             "\n\n\n\nstatic const sl_arch_layout_t layout_%s = {\n",
 649             machname);
 650         (void) printf(fmt, "auxv");
 651         (void) printf(fmt, "fltset");
 652         (void) printf(fmt, "lwpsinfo");
 653         (void) printf(fmt, "lwpstatus");
 654         (void) printf(fmt, "prcred");
 655         (void) printf(fmt, "priv_impl_info");
 656         (void) printf(fmt, "prpriv");
 657         (void) printf(fmt, "psinfo");
 658         (void) printf(fmt, "pstatus");
 659         (void) printf(fmt, "prgregset");
 660         (void) printf(fmt, "prpsinfo");
 661         (void) printf(fmt, "prstatus");
 662         (void) printf(fmt, "sigaction");
 663         (void) printf(fmt, "siginfo");
 664         (void) printf(fmt, "sigset");
 665         (void) printf(fmt, "stack");
 666         (void) printf(fmt, "sysset");
 667         (void) printf(fmt, "timestruc");
 668         (void) printf(fmt, "utsname");
 669         (void) printf(fmt, "prfdinfo");
 670         (void) printf(fmt, "psecflags");
 671         (void) printf("};\n");
 672 
 673         /*
 674          * A public function, to make the information available
 675          */
 676         (void) printf("\n\nconst sl_arch_layout_t *\n");
 677         (void) printf("struct_layout_%s(void)\n", machname);
 678         (void) printf("{\n\treturn (&layout_%s);\n}\n", machname);
 679 
 680         return (0);
 681 }
 682 
 683 /*
 684  * Helper functions using the CTF library to get type info.
 685  */
 686 
 687 static void
 688 get_ctf_file(char *fname)
 689 {
 690         int ctferr;