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 typedef struct tsol_mlp_s { 58 uchar_t mlp_ipp; 59 uint16_t mlp_port; 60 uint16_t mlp_port_upper; 61 } tsol_mlp_t; 62 63 /* Procedure Interface Definitions available to user and kernel */ 64 65 extern int bltype(const void *, uint8_t); 66 extern int blequal(const m_label_t *, const m_label_t *); 67 extern int bldominates(const m_label_t *, const m_label_t *); 68 extern int blstrictdom(const m_label_t *, const m_label_t *); 69 extern int blinrange(const m_label_t *, const m_range_t *); 70 extern void blmaximum(m_label_t *, const m_label_t *); 71 extern void blminimum(m_label_t *, const m_label_t *); 72 extern void bsllow(m_label_t *); 73 extern void bslhigh(m_label_t *); 74 extern void bclearlow(m_label_t *); 75 extern void bclearhigh(m_label_t *); 76 extern void bslundef(m_label_t *); 77 extern void bclearundef(m_label_t *); 78 extern void setbltype(void *, uint8_t); 79 extern boolean_t bisinvalid(const void *); 80 81 #ifdef _KERNEL 82 typedef struct tsol_mlp_entry_s { 83 struct tsol_mlp_entry_s *mlpe_next, *mlpe_prev; 84 zoneid_t mlpe_zoneid; 85 tsol_mlp_t mlpe_mlp; 86 } tsol_mlp_entry_t; 87 88 typedef struct tsol_mlp_list_s { 89 krwlock_t mlpl_rwlock; 90 tsol_mlp_entry_t *mlpl_first, *mlpl_last; 91 } tsol_mlp_list_t; 92 93 typedef struct ts_label_s { 94 uint_t tsl_ref; /* Reference count */ 95 uint32_t tsl_doi; /* Domain of Interpretation */ 96 uint32_t tsl_flags; /* TSLF_* below */ 97 m_label_t tsl_label; /* Actual label */ 98 } ts_label_t; 99 100 #define DEFAULT_DOI 1 101 102 #define TSLF_UNLABELED 0x00000001 /* source was unlabeled */ 103 104 #define CR_SL(cr) (label2bslabel(crgetlabel(cr))) 105 106 extern ts_label_t *l_admin_low; 107 extern ts_label_t *l_admin_high; 108 extern uint32_t default_doi; 109 extern int sys_labeling; 110 111 extern void label_init(void); 112 extern ts_label_t *labelalloc(const m_label_t *, uint32_t, int); 113 extern void label_hold(ts_label_t *); 114 extern void label_rele(ts_label_t *); 115 extern m_label_t *label2bslabel(ts_label_t *); 116 extern uint32_t label2doi(ts_label_t *); 117 extern boolean_t label_equal(const ts_label_t *, const ts_label_t *); 118 extern cred_t *newcred_from_bslabel(m_label_t *, uint32_t, int); 119 extern cred_t *copycred_from_bslabel(cred_t *, m_label_t *, 120 uint32_t, int); 121 extern ts_label_t *getflabel(vnode_t *); 122 extern int getlabel(const char *, m_label_t *); 123 extern int fgetlabel(int, m_label_t *); 124 extern int _blinrange(const m_label_t *, const brange_t *); 125 extern int blinlset(const m_label_t *, const blset_t); 126 extern ts_label_t *nfs4_getflabel(vnode_t *); 127 128 /* 129 * The use of '!!' here prevents users from referencing this function-like 130 * macro as though it were an l-value, and in normal use is optimized away 131 * by the compiler. 132 */ 133 #define is_system_labeled() (!!(sys_labeling > 0)) 134 135 #endif /* _KERNEL */ 136 137 #ifdef __cplusplus 138 } 139 #endif 140 141 #endif /* !_SYS_TSOL_LABEL_H */ 142