diff options
Diffstat (limited to 'security/smack/smack.h')
-rw-r--r-- | security/smack/smack.h | 57 |
1 files changed, 21 insertions, 36 deletions
diff --git a/security/smack/smack.h b/security/smack/smack.h index 4ede719922ed..5e031a2e4c36 100644 --- a/security/smack/smack.h +++ b/security/smack/smack.h | |||
@@ -23,13 +23,19 @@ | |||
23 | #include <linux/lsm_audit.h> | 23 | #include <linux/lsm_audit.h> |
24 | 24 | ||
25 | /* | 25 | /* |
26 | * Smack labels were limited to 23 characters for a long time. | ||
27 | */ | ||
28 | #define SMK_LABELLEN 24 | ||
29 | #define SMK_LONGLABEL 256 | ||
30 | |||
31 | /* | ||
32 | * Maximum number of bytes for the levels in a CIPSO IP option. | ||
26 | * Why 23? CIPSO is constrained to 30, so a 32 byte buffer is | 33 | * Why 23? CIPSO is constrained to 30, so a 32 byte buffer is |
27 | * bigger than can be used, and 24 is the next lower multiple | 34 | * bigger than can be used, and 24 is the next lower multiple |
28 | * of 8, and there are too many issues if there isn't space set | 35 | * of 8, and there are too many issues if there isn't space set |
29 | * aside for the terminating null byte. | 36 | * aside for the terminating null byte. |
30 | */ | 37 | */ |
31 | #define SMK_MAXLEN 23 | 38 | #define SMK_CIPSOLEN 24 |
32 | #define SMK_LABELLEN (SMK_MAXLEN+1) | ||
33 | 39 | ||
34 | struct superblock_smack { | 40 | struct superblock_smack { |
35 | char *smk_root; | 41 | char *smk_root; |
@@ -66,6 +72,7 @@ struct task_smack { | |||
66 | 72 | ||
67 | #define SMK_INODE_INSTANT 0x01 /* inode is instantiated */ | 73 | #define SMK_INODE_INSTANT 0x01 /* inode is instantiated */ |
68 | #define SMK_INODE_TRANSMUTE 0x02 /* directory is transmuting */ | 74 | #define SMK_INODE_TRANSMUTE 0x02 /* directory is transmuting */ |
75 | #define SMK_INODE_CHANGED 0x04 /* smack was transmuted */ | ||
69 | 76 | ||
70 | /* | 77 | /* |
71 | * A label access rule. | 78 | * A label access rule. |
@@ -78,15 +85,6 @@ struct smack_rule { | |||
78 | }; | 85 | }; |
79 | 86 | ||
80 | /* | 87 | /* |
81 | * An entry in the table mapping smack values to | ||
82 | * CIPSO level/category-set values. | ||
83 | */ | ||
84 | struct smack_cipso { | ||
85 | int smk_level; | ||
86 | char smk_catset[SMK_LABELLEN]; | ||
87 | }; | ||
88 | |||
89 | /* | ||
90 | * An entry in the table identifying hosts. | 88 | * An entry in the table identifying hosts. |
91 | */ | 89 | */ |
92 | struct smk_netlbladdr { | 90 | struct smk_netlbladdr { |
@@ -113,22 +111,19 @@ struct smk_netlbladdr { | |||
113 | * interfaces don't. The secid should go away when all of | 111 | * interfaces don't. The secid should go away when all of |
114 | * these components have been repaired. | 112 | * these components have been repaired. |
115 | * | 113 | * |
116 | * If there is a cipso value associated with the label it | 114 | * The cipso value associated with the label gets stored here, too. |
117 | * gets stored here, too. This will most likely be rare as | ||
118 | * the cipso direct mapping in used internally. | ||
119 | * | 115 | * |
120 | * Keep the access rules for this subject label here so that | 116 | * Keep the access rules for this subject label here so that |
121 | * the entire set of rules does not need to be examined every | 117 | * the entire set of rules does not need to be examined every |
122 | * time. | 118 | * time. |
123 | */ | 119 | */ |
124 | struct smack_known { | 120 | struct smack_known { |
125 | struct list_head list; | 121 | struct list_head list; |
126 | char smk_known[SMK_LABELLEN]; | 122 | char *smk_known; |
127 | u32 smk_secid; | 123 | u32 smk_secid; |
128 | struct smack_cipso *smk_cipso; | 124 | struct netlbl_lsm_secattr smk_netlabel; /* on wire labels */ |
129 | spinlock_t smk_cipsolock; /* for changing cipso map */ | 125 | struct list_head smk_rules; /* access rules */ |
130 | struct list_head smk_rules; /* access rules */ | 126 | struct mutex smk_rules_lock; /* lock for rules */ |
131 | struct mutex smk_rules_lock; /* lock for the rules */ | ||
132 | }; | 127 | }; |
133 | 128 | ||
134 | /* | 129 | /* |
@@ -165,6 +160,7 @@ struct smack_known { | |||
165 | #define SMACK_CIPSO_DOI_DEFAULT 3 /* Historical */ | 160 | #define SMACK_CIPSO_DOI_DEFAULT 3 /* Historical */ |
166 | #define SMACK_CIPSO_DOI_INVALID -1 /* Not a DOI */ | 161 | #define SMACK_CIPSO_DOI_INVALID -1 /* Not a DOI */ |
167 | #define SMACK_CIPSO_DIRECT_DEFAULT 250 /* Arbitrary */ | 162 | #define SMACK_CIPSO_DIRECT_DEFAULT 250 /* Arbitrary */ |
163 | #define SMACK_CIPSO_MAPPED_DEFAULT 251 /* Also arbitrary */ | ||
168 | #define SMACK_CIPSO_MAXCATVAL 63 /* Bigger gets harder */ | 164 | #define SMACK_CIPSO_MAXCATVAL 63 /* Bigger gets harder */ |
169 | #define SMACK_CIPSO_MAXLEVEL 255 /* CIPSO 2.2 standard */ | 165 | #define SMACK_CIPSO_MAXLEVEL 255 /* CIPSO 2.2 standard */ |
170 | #define SMACK_CIPSO_MAXCATNUM 239 /* CIPSO 2.2 standard */ | 166 | #define SMACK_CIPSO_MAXCATNUM 239 /* CIPSO 2.2 standard */ |
@@ -215,10 +211,9 @@ struct inode_smack *new_inode_smack(char *); | |||
215 | int smk_access_entry(char *, char *, struct list_head *); | 211 | int smk_access_entry(char *, char *, struct list_head *); |
216 | int smk_access(char *, char *, int, struct smk_audit_info *); | 212 | int smk_access(char *, char *, int, struct smk_audit_info *); |
217 | int smk_curacc(char *, u32, struct smk_audit_info *); | 213 | int smk_curacc(char *, u32, struct smk_audit_info *); |
218 | int smack_to_cipso(const char *, struct smack_cipso *); | ||
219 | char *smack_from_cipso(u32, char *); | ||
220 | char *smack_from_secid(const u32); | 214 | char *smack_from_secid(const u32); |
221 | void smk_parse_smack(const char *string, int len, char *smack); | 215 | char *smk_parse_smack(const char *string, int len); |
216 | int smk_netlbl_mls(int, char *, struct netlbl_lsm_secattr *, int); | ||
222 | char *smk_import(const char *, int); | 217 | char *smk_import(const char *, int); |
223 | struct smack_known *smk_import_entry(const char *, int); | 218 | struct smack_known *smk_import_entry(const char *, int); |
224 | struct smack_known *smk_find_entry(const char *); | 219 | struct smack_known *smk_find_entry(const char *); |
@@ -228,6 +223,7 @@ u32 smack_to_secid(const char *); | |||
228 | * Shared data. | 223 | * Shared data. |
229 | */ | 224 | */ |
230 | extern int smack_cipso_direct; | 225 | extern int smack_cipso_direct; |
226 | extern int smack_cipso_mapped; | ||
231 | extern char *smack_net_ambient; | 227 | extern char *smack_net_ambient; |
232 | extern char *smack_onlycap; | 228 | extern char *smack_onlycap; |
233 | extern const char *smack_cipso_option; | 229 | extern const char *smack_cipso_option; |
@@ -239,24 +235,13 @@ extern struct smack_known smack_known_invalid; | |||
239 | extern struct smack_known smack_known_star; | 235 | extern struct smack_known smack_known_star; |
240 | extern struct smack_known smack_known_web; | 236 | extern struct smack_known smack_known_web; |
241 | 237 | ||
238 | extern struct mutex smack_known_lock; | ||
242 | extern struct list_head smack_known_list; | 239 | extern struct list_head smack_known_list; |
243 | extern struct list_head smk_netlbladdr_list; | 240 | extern struct list_head smk_netlbladdr_list; |
244 | 241 | ||
245 | extern struct security_operations smack_ops; | 242 | extern struct security_operations smack_ops; |
246 | 243 | ||
247 | /* | 244 | /* |
248 | * Stricly for CIPSO level manipulation. | ||
249 | * Set the category bit number in a smack label sized buffer. | ||
250 | */ | ||
251 | static inline void smack_catset_bit(int cat, char *catsetp) | ||
252 | { | ||
253 | if (cat > SMK_LABELLEN * 8) | ||
254 | return; | ||
255 | |||
256 | catsetp[(cat - 1) / 8] |= 0x80 >> ((cat - 1) % 8); | ||
257 | } | ||
258 | |||
259 | /* | ||
260 | * Is the directory transmuting? | 245 | * Is the directory transmuting? |
261 | */ | 246 | */ |
262 | static inline int smk_inode_transmutable(const struct inode *isp) | 247 | static inline int smk_inode_transmutable(const struct inode *isp) |