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/sgs/libconv/common/corenote.c
          +++ new/usr/src/cmd/sgs/libconv/common/corenote.c
↓ open down ↓ 96 lines elided ↑ open up ↑
  97   97                  MSG_AUXV_AT_SUN_UID,            MSG_AUXV_AT_SUN_RUID,
  98   98                  MSG_AUXV_AT_SUN_GID,            MSG_AUXV_AT_SUN_RGID,
  99   99                  MSG_AUXV_AT_SUN_LDELF,          MSG_AUXV_AT_SUN_LDSHDR,
 100  100                  MSG_AUXV_AT_SUN_LDNAME,         MSG_AUXV_AT_SUN_LPAGESZ,
 101  101                  MSG_AUXV_AT_SUN_PLATFORM,       MSG_AUXV_AT_SUN_HWCAP,
 102  102                  MSG_AUXV_AT_SUN_IFLUSH,         MSG_AUXV_AT_SUN_CPU
 103  103          };
 104  104          static const conv_ds_msg_t ds_types_2000_2011 = {
 105  105              CONV_DS_MSG_INIT(2000, types_2000_2011) };
 106  106  
 107      -        static const Msg        types_2014_2023[] = {
      107 +        static const Msg        types_2014_2024[] = {
 108  108                  MSG_AUXV_AT_SUN_EXECNAME,       MSG_AUXV_AT_SUN_MMU,
 109  109                  MSG_AUXV_AT_SUN_LDDATA,         MSG_AUXV_AT_SUN_AUXFLAGS,
 110  110                  MSG_AUXV_AT_SUN_EMULATOR,       MSG_AUXV_AT_SUN_BRANDNAME,
 111  111                  MSG_AUXV_AT_SUN_BRAND_AUX1,     MSG_AUXV_AT_SUN_BRAND_AUX2,
 112      -                MSG_AUXV_AT_SUN_BRAND_AUX3,     MSG_AUXV_AT_SUN_HWCAP2
      112 +                MSG_AUXV_AT_SUN_BRAND_AUX3,     MSG_AUXV_AT_SUN_HWCAP2,
      113 +                MSG_AUXV_AT_SUN_SECFLAGS
 113  114          };
 114      -        static const conv_ds_msg_t ds_types_2014_2023 = {
 115      -            CONV_DS_MSG_INIT(2014, types_2014_2023) };
      115 +        static const conv_ds_msg_t ds_types_2014_2024 = {
      116 +            CONV_DS_MSG_INIT(2014, types_2014_2024) };
 116  117  
 117  118          static const conv_ds_t  *ds[] = {
 118  119                  CONV_DS_ADDR(ds_types_0_22), CONV_DS_ADDR(ds_types_2000_2011),
 119      -                CONV_DS_ADDR(ds_types_2014_2023), NULL };
      120 +                CONV_DS_ADDR(ds_types_2014_2024), NULL };
 120  121  
 121  122          return (conv_map_ds(ELFOSABI_NONE, EM_NONE, type, ds, fmt_flags,
 122  123              inv_buf));
 123  124  }
 124  125  
 125  126  
 126  127  const char *
 127  128  conv_cnote_signal(Word sig, Conv_fmt_flags_t fmt_flags,
 128  129      Conv_inv_buf_t *inv_buf)
 129  130  {
↓ open down ↓ 2445 lines elided ↑ open up ↑
2575 2576          } else {
2576 2577                  arg.rflags = mode;
2577 2578          }
2578 2579  
2579 2580          if (mode == 0)
2580 2581                  return (MSG_ORIG(MSG_GBL_ZERO));
2581 2582  
2582 2583          (void) conv_expn_field(&arg, vda, fmt_flags);
2583 2584          return (buf);
2584 2585  }
     2586 +
     2587 +
     2588 +#define PROCSECFLGSZ    CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
     2589 +        MSG_PROC_SEC_ASLR_SIZE          + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
     2590 +        CONV_INV_BUFSIZE                + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
     2591 +
     2592 +/*
     2593 + * Ensure that Conv_cnote_pr_secflags_buf_t is large enough:
     2594 + *
     2595 + * PROCSECFLGSZ is the real minimum size of the buffer required by
     2596 + * conv_cnote_psecflags(). However, Conv_cnote_pr_secflags_buf_t uses
     2597 + * CONV_CNOTE_PSECFLAGS_FLAG_BUFSIZE to set the buffer size. We do things this
     2598 + * way because the definition of PROCSECFLGSZ uses information that is not
     2599 + * available in the environment of other programs that include the conv.h
     2600 + * header file.
     2601 + */
     2602 +#if (CONV_PSECFLAGS_BUFSIZE != PROCSECFLGSZ) && !defined(__lint)
     2603 +#define REPORT_BUFSIZE PROCSECFLGSZ
     2604 +#include "report_bufsize.h"
     2605 +#error "CONV_PSECFLAGS_BUFSIZE does not match PROCSECFLGSZ"
     2606 +#endif
     2607 +
     2608 +const char *
     2609 +conv_psecflags(int flags, Conv_fmt_flags_t fmt_flags,
     2610 +    Conv_secflags_buf_t *secflags_buf)
     2611 +{
     2612 +        static const Val_desc vda[] = {
     2613 +                { 0x0001,               MSG_PROC_SEC_ASLR },
     2614 +                { 0,                    0 }
     2615 +        };
     2616 +        static CONV_EXPN_FIELD_ARG conv_arg = {
     2617 +            NULL, sizeof (secflags_buf->buf) };
     2618 +
     2619 +        if (flags == 0)
     2620 +                return (MSG_ORIG(MSG_GBL_ZERO));
     2621 +
     2622 +        conv_arg.buf = secflags_buf->buf;
     2623 +        conv_arg.oflags = conv_arg.rflags = flags;
     2624 +        (void) conv_expn_field(&conv_arg, vda, fmt_flags);
     2625 +
     2626 +        return ((const char *)secflags_buf->buf);
     2627 +}
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX