1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_TSOL_LABEL_H 27 #define _SYS_TSOL_LABEL_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #include <sys/types.h> 32 #ifdef _KERNEL 33 #include <sys/cred.h> 34 #include <sys/vnode.h> 35 #include <sys/tsol/label_macro.h> 36 #endif /* _KERNEL */ 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* Binary Label Structure Definitions */ 43 44 typedef struct _mac_label_impl m_label_t; 45 46 typedef m_label_t blevel_t, /* compatibility */ 47 bslabel_t, /* Sensitivity Label */ 48 bclear_t; /* Clearance */ 49 50 typedef struct _tsol_binary_level_lrange { /* Level Range */ 51 m_label_t *lower_bound; 52 m_label_t *upper_bound; 53 } m_range_t; 54 55 typedef m_range_t blrange_t; 56 57 #define NMLP_MAX 0x10 58 #define NSLS_MAX 0x4 59 60 typedef m_label_t blset_t[NSLS_MAX]; 61 62 typedef struct tsol_mlp_s { 63 uchar_t mlp_ipp; 64 uint16_t mlp_port; 65 uint16_t mlp_port_upper; 66 } tsol_mlp_t; 67 68 /* Procedure Interface Definitions available to user and kernel */ 69 70 extern int bltype(const void *, uint8_t); 71 extern int blequal(const m_label_t *, const m_label_t *); 72 extern int bldominates(const m_label_t *, const m_label_t *); 73 extern int blstrictdom(const m_label_t *, const m_label_t *); 74 extern int blinrange(const m_label_t *, const m_range_t *); 75 extern void blmaximum(m_label_t *, const m_label_t *); 76 extern void blminimum(m_label_t *, const m_label_t *); 77 extern void bsllow(m_label_t *); 78 extern void bslhigh(m_label_t *); 79 extern void bclearlow(m_label_t *); 80 extern void bclearhigh(m_label_t *); 81 extern void bslundef(m_label_t *); 82 extern void bclearundef(m_label_t *); 83 extern void setbltype(void *, uint8_t); 84 extern boolean_t bisinvalid(const void *); 85 86 #ifdef _KERNEL 87 typedef struct tsol_mlp_entry_s { 88 struct tsol_mlp_entry_s *mlpe_next, *mlpe_prev; 89 zoneid_t mlpe_zoneid; 90 tsol_mlp_t mlpe_mlp; 91 } tsol_mlp_entry_t; 92 93 typedef struct tsol_mlp_list_s { 94 krwlock_t mlpl_rwlock; 95 tsol_mlp_entry_t *mlpl_first, *mlpl_last; 96 } tsol_mlp_list_t; 97 98 typedef struct ts_label_s { 99 uint_t tsl_ref; /* Reference count */ 100 uint32_t tsl_doi; /* Domain of Interpretation */ 101 uint32_t tsl_flags; /* TSLF_* below */ 102 m_label_t tsl_label; /* Actual label */ 103 } ts_label_t; 104 105 #define DEFAULT_DOI 1 106 107 #define TSLF_UNLABELED 0x00000001 /* source was unlabeled */ 108 109 #define CR_SL(cr) (label2bslabel(crgetlabel(cr))) 110 111 extern ts_label_t *l_admin_low; 112 extern ts_label_t *l_admin_high; 113 extern uint32_t default_doi; 114 extern int sys_labeling; 115 116 extern void label_init(void); 117 extern ts_label_t *labelalloc(const m_label_t *, uint32_t, int); 118 extern void label_hold(ts_label_t *); 119 extern void label_rele(ts_label_t *); 120 extern m_label_t *label2bslabel(ts_label_t *); 121 extern uint32_t label2doi(ts_label_t *); 122 extern boolean_t label_equal(const ts_label_t *, const ts_label_t *); 123 extern cred_t *newcred_from_bslabel(m_label_t *, uint32_t, int); 124 extern cred_t *copycred_from_bslabel(cred_t *, m_label_t *, 125 uint32_t, int); 126 extern ts_label_t *getflabel(vnode_t *); 127 extern int getlabel(const char *, m_label_t *); 128 extern int fgetlabel(int, m_label_t *); 129 extern int _blinrange(const m_label_t *, const brange_t *); 130 extern int blinlset(const m_label_t *, const blset_t); 131 extern ts_label_t *nfs4_getflabel(vnode_t *); 132 133 /* 134 * The use of '!!' here prevents users from referencing this function-like 135 * macro as though it were an l-value, and in normal use is optimized away 136 * by the compiler. 137 */ 138 #define is_system_labeled() (!!(sys_labeling > 0)) 139 140 #endif /* _KERNEL */ 141 142 #ifdef __cplusplus 143 } 144 #endif 145 146 #endif /* !_SYS_TSOL_LABEL_H */ 147