1717#include <linux/spinlock.h>
1818#include <linux/lsm_hooks.h>
1919#include <linux/in.h>
20+ #if IS_ENABLED (CONFIG_IPV6 )
21+ #include <linux/in6.h>
22+ #endif /* CONFIG_IPV6 */
2023#include <net/netlabel.h>
2124#include <linux/list.h>
2225#include <linux/rculist.h>
2326#include <linux/lsm_audit.h>
2427
28+ /*
29+ * Use IPv6 port labeling if IPv6 is enabled and secmarks
30+ * are not being used.
31+ */
32+ #if IS_ENABLED (CONFIG_IPV6 ) && !defined(CONFIG_SECURITY_SMACK_NETFILTER )
33+ #define SMACK_IPV6_PORT_LABELING 1
34+ #endif
35+
36+ #if IS_ENABLED (CONFIG_IPV6 ) && defined(CONFIG_SECURITY_SMACK_NETFILTER )
37+ #define SMACK_IPV6_SECMARK_LABELING 1
38+ #endif
39+
2540/*
2641 * Smack labels were limited to 23 characters for a long time.
2742 */
@@ -118,15 +133,30 @@ struct smack_rule {
118133};
119134
120135/*
121- * An entry in the table identifying hosts.
136+ * An entry in the table identifying IPv4 hosts.
122137 */
123- struct smk_netlbladdr {
138+ struct smk_net4addr {
124139 struct list_head list ;
125- struct sockaddr_in smk_host ; /* network address */
140+ struct in_addr smk_host ; /* network address */
126141 struct in_addr smk_mask ; /* network mask */
142+ int smk_masks ; /* mask size */
143+ struct smack_known * smk_label ; /* label */
144+ };
145+
146+ #if IS_ENABLED (CONFIG_IPV6 )
147+ /*
148+ * An entry in the table identifying IPv6 hosts.
149+ */
150+ struct smk_net6addr {
151+ struct list_head list ;
152+ struct in6_addr smk_host ; /* network address */
153+ struct in6_addr smk_mask ; /* network mask */
154+ int smk_masks ; /* mask size */
127155 struct smack_known * smk_label ; /* label */
128156};
157+ #endif /* CONFIG_IPV6 */
129158
159+ #ifdef SMACK_IPV6_PORT_LABELING
130160/*
131161 * An entry in the table identifying ports.
132162 */
@@ -137,12 +167,31 @@ struct smk_port_label {
137167 struct smack_known * smk_in ; /* inbound label */
138168 struct smack_known * smk_out ; /* outgoing label */
139169};
170+ #endif /* SMACK_IPV6_PORT_LABELING */
140171
141172struct smack_onlycap {
142173 struct list_head list ;
143174 struct smack_known * smk_label ;
144175};
145176
177+ /* Super block security struct flags for mount options */
178+ #define FSDEFAULT_MNT 0x01
179+ #define FSFLOOR_MNT 0x02
180+ #define FSHAT_MNT 0x04
181+ #define FSROOT_MNT 0x08
182+ #define FSTRANS_MNT 0x10
183+
184+ #define NUM_SMK_MNT_OPTS 5
185+
186+ enum {
187+ Opt_error = -1 ,
188+ Opt_fsdefault = 1 ,
189+ Opt_fsfloor = 2 ,
190+ Opt_fshat = 3 ,
191+ Opt_fsroot = 4 ,
192+ Opt_fstransmute = 5 ,
193+ };
194+
146195/*
147196 * Mount options
148197 */
@@ -152,6 +201,7 @@ struct smack_onlycap {
152201#define SMK_FSROOT "smackfsroot="
153202#define SMK_FSTRANS "smackfstransmute="
154203
204+ #define SMACK_DELETE_OPTION "-DELETE"
155205#define SMACK_CIPSO_OPTION "-CIPSO"
156206
157207/*
@@ -234,10 +284,6 @@ struct smk_audit_info {
234284 struct smack_audit_data sad ;
235285#endif
236286};
237- /*
238- * These functions are in smack_lsm.c
239- */
240- struct inode_smack * new_inode_smack (struct smack_known * );
241287
242288/*
243289 * These functions are in smack_access.c
@@ -267,7 +313,6 @@ extern struct smack_known *smack_syslog_label;
267313#ifdef CONFIG_SECURITY_SMACK_BRINGUP
268314extern struct smack_known * smack_unconfined ;
269315#endif
270- extern struct smack_known smack_cipso_option ;
271316extern int smack_ptrace_rule ;
272317
273318extern struct smack_known smack_known_floor ;
@@ -279,7 +324,10 @@ extern struct smack_known smack_known_web;
279324
280325extern struct mutex smack_known_lock ;
281326extern struct list_head smack_known_list ;
282- extern struct list_head smk_netlbladdr_list ;
327+ extern struct list_head smk_net4addr_list ;
328+ #if IS_ENABLED (CONFIG_IPV6 )
329+ extern struct list_head smk_net6addr_list ;
330+ #endif /* CONFIG_IPV6 */
283331
284332extern struct mutex smack_onlycap_lock ;
285333extern struct list_head smack_onlycap_list ;
0 commit comments