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


  87                 MSG_AUXV_AT_EGID,               MSG_AUXV_AT_PLATFORM,
  88                 MSG_AUXV_AT_HWCAP,              MSG_AUXV_AT_CLKTCK,
  89                 MSG_AUXV_AT_FPUCW,              MSG_AUXV_AT_DCACHEBSIZE,
  90                 MSG_AUXV_AT_ICACHEBSIZE,        MSG_AUXV_AT_UCACHEBSIZE,
  91                 MSG_AUXV_AT_IGNOREPPC
  92         };
  93         static const conv_ds_msg_t ds_types_0_22 = {
  94             CONV_DS_MSG_INIT(0, types_0_22) };
  95 
  96         static const Msg        types_2000_2011[] = {
  97                 MSG_AUXV_AT_SUN_UID,            MSG_AUXV_AT_SUN_RUID,
  98                 MSG_AUXV_AT_SUN_GID,            MSG_AUXV_AT_SUN_RGID,
  99                 MSG_AUXV_AT_SUN_LDELF,          MSG_AUXV_AT_SUN_LDSHDR,
 100                 MSG_AUXV_AT_SUN_LDNAME,         MSG_AUXV_AT_SUN_LPAGESZ,
 101                 MSG_AUXV_AT_SUN_PLATFORM,       MSG_AUXV_AT_SUN_HWCAP,
 102                 MSG_AUXV_AT_SUN_IFLUSH,         MSG_AUXV_AT_SUN_CPU
 103         };
 104         static const conv_ds_msg_t ds_types_2000_2011 = {
 105             CONV_DS_MSG_INIT(2000, types_2000_2011) };
 106 
 107         static const Msg        types_2014_2023[] = {
 108                 MSG_AUXV_AT_SUN_EXECNAME,       MSG_AUXV_AT_SUN_MMU,
 109                 MSG_AUXV_AT_SUN_LDDATA,         MSG_AUXV_AT_SUN_AUXFLAGS,
 110                 MSG_AUXV_AT_SUN_EMULATOR,       MSG_AUXV_AT_SUN_BRANDNAME,
 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

 113         };
 114         static const conv_ds_msg_t ds_types_2014_2023 = {
 115             CONV_DS_MSG_INIT(2014, types_2014_2023) };
 116 
 117         static const conv_ds_t  *ds[] = {
 118                 CONV_DS_ADDR(ds_types_0_22), CONV_DS_ADDR(ds_types_2000_2011),
 119                 CONV_DS_ADDR(ds_types_2014_2023), NULL };
 120 
 121         return (conv_map_ds(ELFOSABI_NONE, EM_NONE, type, ds, fmt_flags,
 122             inv_buf));
 123 }
 124 
 125 
 126 const char *
 127 conv_cnote_signal(Word sig, Conv_fmt_flags_t fmt_flags,
 128     Conv_inv_buf_t *inv_buf)
 129 {
 130         static const Msg        sigarr[] = {
 131                 MSG_SIGHUP,             MSG_SIGINT,
 132                 MSG_SIGQUIT,            MSG_SIGILL,
 133                 MSG_SIGTRAP,            MSG_SIGABRT,
 134                 MSG_SIGEMT,             MSG_SIGFPE,
 135                 MSG_SIGKILL,            MSG_SIGBUS,
 136                 MSG_SIGSEGV,            MSG_SIGSYS,
 137                 MSG_SIGPIPE,            MSG_SIGALRM,
 138                 MSG_SIGTERM,            MSG_SIGUSR1,
 139                 MSG_SIGUSR2,            MSG_SIGCHLD,


2565                 break;
2566         default:
2567                 s = NULL;
2568                 break;
2569         }
2570 
2571         if (s) {
2572                 arg.oflags |= 0x1000;
2573                 arg.rflags |= 0x1000;
2574                 vda[0].v_msg = s;
2575         } else {
2576                 arg.rflags = mode;
2577         }
2578 
2579         if (mode == 0)
2580                 return (MSG_ORIG(MSG_GBL_ZERO));
2581 
2582         (void) conv_expn_field(&arg, vda, fmt_flags);
2583         return (buf);
2584 }












































  87                 MSG_AUXV_AT_EGID,               MSG_AUXV_AT_PLATFORM,
  88                 MSG_AUXV_AT_HWCAP,              MSG_AUXV_AT_CLKTCK,
  89                 MSG_AUXV_AT_FPUCW,              MSG_AUXV_AT_DCACHEBSIZE,
  90                 MSG_AUXV_AT_ICACHEBSIZE,        MSG_AUXV_AT_UCACHEBSIZE,
  91                 MSG_AUXV_AT_IGNOREPPC
  92         };
  93         static const conv_ds_msg_t ds_types_0_22 = {
  94             CONV_DS_MSG_INIT(0, types_0_22) };
  95 
  96         static const Msg        types_2000_2011[] = {
  97                 MSG_AUXV_AT_SUN_UID,            MSG_AUXV_AT_SUN_RUID,
  98                 MSG_AUXV_AT_SUN_GID,            MSG_AUXV_AT_SUN_RGID,
  99                 MSG_AUXV_AT_SUN_LDELF,          MSG_AUXV_AT_SUN_LDSHDR,
 100                 MSG_AUXV_AT_SUN_LDNAME,         MSG_AUXV_AT_SUN_LPAGESZ,
 101                 MSG_AUXV_AT_SUN_PLATFORM,       MSG_AUXV_AT_SUN_HWCAP,
 102                 MSG_AUXV_AT_SUN_IFLUSH,         MSG_AUXV_AT_SUN_CPU
 103         };
 104         static const conv_ds_msg_t ds_types_2000_2011 = {
 105             CONV_DS_MSG_INIT(2000, types_2000_2011) };
 106 
 107         static const Msg        types_2014_2024[] = {
 108                 MSG_AUXV_AT_SUN_EXECNAME,       MSG_AUXV_AT_SUN_MMU,
 109                 MSG_AUXV_AT_SUN_LDDATA,         MSG_AUXV_AT_SUN_AUXFLAGS,
 110                 MSG_AUXV_AT_SUN_EMULATOR,       MSG_AUXV_AT_SUN_BRANDNAME,
 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,
 113                 MSG_AUXV_AT_SUN_SECFLAGS
 114         };
 115         static const conv_ds_msg_t ds_types_2014_2024 = {
 116             CONV_DS_MSG_INIT(2014, types_2014_2024) };
 117 
 118         static const conv_ds_t  *ds[] = {
 119                 CONV_DS_ADDR(ds_types_0_22), CONV_DS_ADDR(ds_types_2000_2011),
 120                 CONV_DS_ADDR(ds_types_2014_2024), NULL };
 121 
 122         return (conv_map_ds(ELFOSABI_NONE, EM_NONE, type, ds, fmt_flags,
 123             inv_buf));
 124 }
 125 
 126 
 127 const char *
 128 conv_cnote_signal(Word sig, Conv_fmt_flags_t fmt_flags,
 129     Conv_inv_buf_t *inv_buf)
 130 {
 131         static const Msg        sigarr[] = {
 132                 MSG_SIGHUP,             MSG_SIGINT,
 133                 MSG_SIGQUIT,            MSG_SIGILL,
 134                 MSG_SIGTRAP,            MSG_SIGABRT,
 135                 MSG_SIGEMT,             MSG_SIGFPE,
 136                 MSG_SIGKILL,            MSG_SIGBUS,
 137                 MSG_SIGSEGV,            MSG_SIGSYS,
 138                 MSG_SIGPIPE,            MSG_SIGALRM,
 139                 MSG_SIGTERM,            MSG_SIGUSR1,
 140                 MSG_SIGUSR2,            MSG_SIGCHLD,


2566                 break;
2567         default:
2568                 s = NULL;
2569                 break;
2570         }
2571 
2572         if (s) {
2573                 arg.oflags |= 0x1000;
2574                 arg.rflags |= 0x1000;
2575                 vda[0].v_msg = s;
2576         } else {
2577                 arg.rflags = mode;
2578         }
2579 
2580         if (mode == 0)
2581                 return (MSG_ORIG(MSG_GBL_ZERO));
2582 
2583         (void) conv_expn_field(&arg, vda, fmt_flags);
2584         return (buf);
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 }