Print this page
7029 want per-process exploit mitigation features (secflags)
7030 want basic address space layout randomization (aslr)
7031 noexec_user_stack should be a secflag
7032 want a means to forbid mappings around NULL.


  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #ifndef _SYS_PRIV_IMPL_H
  28 #define _SYS_PRIV_IMPL_H
  29 
  30 #pragma ident   "%Z%%M% %I%     %E% SMI"
  31 
  32 #include <sys/priv_const.h>
  33 #include <sys/priv.h>
  34 
  35 #ifdef  __cplusplus
  36 extern "C" {
  37 #endif
  38 
  39 #if defined(_KERNEL) || defined(_KMEMUSER)
  40 /*
  41  * priv_set_t is a structure holding a set of privileges
  42  */
  43 
  44 struct priv_set {
  45         priv_chunk_t pbits[PRIV_SETSIZE];
  46 };
  47 
  48 typedef struct cred_priv_s {
  49         priv_set_t      crprivs[PRIV_NSET];     /* Priv sets */
  50         uint_t          crpriv_flags;           /* Privilege flags */
  51 } cred_priv_t;


  79 
  80 #define PRIV_VALIDSET(s)        ((s) >= 0 && (s) < PRIV_NSET)
  81 #define PRIV_VALIDOP(op)        ((op) >= PRIV_ON && (op) <= PRIV_SET)
  82 
  83 #define PRIV_FULLSET            &priv_fullset       /* Require full set */
  84 
  85 /*
  86  * Privilege macros bits manipulation macros; DEBUG kernels will
  87  * ASSERT() that privileges are not out of range.
  88  */
  89 #ifndef NBBY
  90 #define NBBY            8
  91 #endif
  92 
  93 #define __NBWRD         (NBBY * sizeof (priv_chunk_t))
  94 
  95 #define privmask(n)     (1U << ((__NBWRD - 1) - ((n) % __NBWRD)))
  96 #define privword(n)     ((n)/__NBWRD)
  97 
  98 /*
  99  * PRIV_ASSERT(a, b) sets privilege "b" in privilege set "a".
 100  * PRIV_CLEAR(a,b) clears privilege "b" in privilege set "a".
 101  * PRIV_ISASSERT tests if privilege 'b' is asserted in privilege set 'a'.
 102  */
 103 
 104 #define __PRIV_ASSERT(a, b)     ((a)->pbits[privword(b)] |= privmask(b))
 105 #define __PRIV_CLEAR(a, b)      ((a)->pbits[privword(b)] &= ~privmask(b))
 106 #define __PRIV_ISASSERT(a, b)   ((a)->pbits[privword(b)] & privmask(b))
 107 
 108 #ifdef DEBUG
 109 #define PRIV_CLEAR(a, b)        priv_delset((a), (b))
 110 #define PRIV_ASSERT(a, b)       priv_addset((a), (b))
 111 #define PRIV_ISASSERT(a, b)     priv_ismember((a), (b))
 112 #else
 113 #define PRIV_CLEAR(a, b)        __PRIV_CLEAR((a), (b))
 114 #define PRIV_ASSERT(a, b)       __PRIV_ASSERT((a), (b))
 115 #define PRIV_ISASSERT(a, b)     __PRIV_ISASSERT((a), (b))
 116 #endif
 117 
 118 #endif /* _KERNEL */
 119 
 120 #ifdef  __cplusplus
 121 }
 122 #endif
 123 
 124 #endif  /* _SYS_PRIV_IMPL_H */


  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #ifndef _SYS_PRIV_IMPL_H
  28 #define _SYS_PRIV_IMPL_H
  29 


  30 #include <sys/priv_const.h>
  31 #include <sys/priv.h>
  32 
  33 #ifdef  __cplusplus
  34 extern "C" {
  35 #endif
  36 
  37 #if defined(_KERNEL) || defined(_KMEMUSER)
  38 /*
  39  * priv_set_t is a structure holding a set of privileges
  40  */
  41 
  42 struct priv_set {
  43         priv_chunk_t pbits[PRIV_SETSIZE];
  44 };
  45 
  46 typedef struct cred_priv_s {
  47         priv_set_t      crprivs[PRIV_NSET];     /* Priv sets */
  48         uint_t          crpriv_flags;           /* Privilege flags */
  49 } cred_priv_t;


  77 
  78 #define PRIV_VALIDSET(s)        ((s) >= 0 && (s) < PRIV_NSET)
  79 #define PRIV_VALIDOP(op)        ((op) >= PRIV_ON && (op) <= PRIV_SET)
  80 
  81 #define PRIV_FULLSET            &priv_fullset       /* Require full set */
  82 
  83 /*
  84  * Privilege macros bits manipulation macros; DEBUG kernels will
  85  * ASSERT() that privileges are not out of range.
  86  */
  87 #ifndef NBBY
  88 #define NBBY            8
  89 #endif
  90 
  91 #define __NBWRD         (NBBY * sizeof (priv_chunk_t))
  92 
  93 #define privmask(n)     (1U << ((__NBWRD - 1) - ((n) % __NBWRD)))
  94 #define privword(n)     ((n)/__NBWRD)
  95 
  96 /*
  97  * PRIV_ADDSET(a, b) sets privilege "b" in privilege set "a".
  98  * PRIV_DELSET(a, b) clears privilege "b" in privilege set "a".
  99  * PRIV_ISMEMBER(a, b) tests if privilege 'b' is asserted in privilege set 'a'.
 100  */
 101 
 102 #define __PRIV_ADDSET(a, b)     ((a)->pbits[privword(b)] |= privmask(b))
 103 #define __PRIV_DELSET(a, b)     ((a)->pbits[privword(b)] &= ~privmask(b))
 104 #define __PRIV_ISMEMBER(a, b)   ((a)->pbits[privword(b)] & privmask(b))
 105 
 106 #ifdef DEBUG
 107 #define PRIV_DELSET(a, b)       priv_delset((a), (b))
 108 #define PRIV_ADDSET(a, b)       priv_addset((a), (b))
 109 #define PRIV_ISMEMBER(a, b)     priv_ismember((a), (b))
 110 #else
 111 #define PRIV_DELSET(a, b)       __PRIV_DELSET((a), (b))
 112 #define PRIV_ADDSET(a, b)       __PRIV_ADDSET((a), (b))
 113 #define PRIV_ISMEMBER(a, b)     __PRIV_ISMEMBER((a), (b))
 114 #endif
 115 
 116 #endif /* _KERNEL */
 117 
 118 #ifdef  __cplusplus
 119 }
 120 #endif
 121 
 122 #endif  /* _SYS_PRIV_IMPL_H */