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/cmd/ptools/pargs/pargs.c
          +++ new/usr/src/cmd/ptools/pargs/pargs.c
↓ open down ↓ 764 lines elided ↑ open up ↑
 765  765  
 766  766          for (i = 0; i < sizeof (auxfl)/sizeof (struct auxfl); i++) {
 767  767                  if ((val & auxfl[i].af_flag) != 0) {
 768  768                          if (*str != '\0')
 769  769                                  (void) strlcat(str, ",", n);
 770  770                          (void) strlcat(str, auxfl[i].af_name, n);
 771  771                  }
 772  772          }
 773  773  }
 774  774  
      775 +static struct auxsecfl {
      776 +        uint_t af_flag;
      777 +        const char *af_name;
      778 +} auxsecfl[] = {
      779 +        { PROC_SEC_ASLR,        "aslr" },
      780 +};
      781 +
      782 +/*ARGSUSED*/
      783 +static void
      784 +at_secflags(long val, char *instr, size_t n, char *str)
      785 +{
      786 +        int i;
      787 +
      788 +        *str = '\0';
      789 +
      790 +        for (i = 0; i < sizeof (auxsecfl)/sizeof (struct auxsecfl); i++) {
      791 +                if ((val & auxsecfl[i].af_flag) != 0) {
      792 +                        if (*str != '\0')
      793 +                                (void) strlcat(str, ",", n);
      794 +                        (void) strlcat(str, auxsecfl[i].af_name, n);
      795 +                }
      796 +        }
      797 +}
      798 +
 775  799  #define MAX_AT_NAME_LEN 15
 776  800  
 777  801  struct aux_id {
 778  802          int aux_type;
 779  803          const char *aux_name;
 780  804          void (*aux_decode)(long, char *, size_t, char *);
 781  805  };
 782  806  
 783  807  static struct aux_id aux_arr[] = {
 784  808          { AT_NULL,              "AT_NULL",              at_null },
↓ open down ↓ 20 lines elided ↑ open up ↑
 805  829          { AT_SUN_HWCAP2,        "AT_SUN_HWCAP2",        at_hwcap2 },
 806  830          { AT_SUN_IFLUSH,        "AT_SUN_IFLUSH",        at_null },
 807  831          { AT_SUN_CPU,           "AT_SUN_CPU",           at_null },
 808  832          { AT_SUN_MMU,           "AT_SUN_MMU",           at_null },
 809  833          { AT_SUN_LDDATA,        "AT_SUN_LDDATA",        at_null },
 810  834          { AT_SUN_AUXFLAGS,      "AT_SUN_AUXFLAGS",      at_flags },
 811  835          { AT_SUN_EMULATOR,      "AT_SUN_EMULATOR",      at_str  },
 812  836          { AT_SUN_BRANDNAME,     "AT_SUN_BRANDNAME",     at_str  },
 813  837          { AT_SUN_BRAND_AUX1,    "AT_SUN_BRAND_AUX1",    at_null },
 814  838          { AT_SUN_BRAND_AUX2,    "AT_SUN_BRAND_AUX2",    at_null },
 815      -        { AT_SUN_BRAND_AUX3,    "AT_SUN_BRAND_AUX3",    at_null }
      839 +        { AT_SUN_BRAND_AUX3,    "AT_SUN_BRAND_AUX3",    at_null },
      840 +        { AT_SUN_SECFLAGS,      "AT_SUN_SECFLAGS",      at_secflags },
 816  841  };
 817  842  
 818  843  #define N_AT_ENTS (sizeof (aux_arr) / sizeof (struct aux_id))
 819  844  
 820  845  /*
 821  846   * Return the aux_id entry for the given aux type; returns NULL if not found.
 822  847   */
 823  848  static struct aux_id *
 824  849  aux_find(int type)
 825  850  {
↓ open down ↓ 736 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX