aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/netlabel.h14
-rw-r--r--security/selinux/ss/services.c2
-rw-r--r--security/smack/smack_lsm.c2
3 files changed, 12 insertions, 6 deletions
diff --git a/include/net/netlabel.h b/include/net/netlabel.h
index 0ca67d73c7ad..5e53a85b5ca1 100644
--- a/include/net/netlabel.h
+++ b/include/net/netlabel.h
@@ -162,7 +162,7 @@ struct netlbl_lsm_secattr_catmap {
162 162
163/** 163/**
164 * struct netlbl_lsm_secattr - NetLabel LSM security attributes 164 * struct netlbl_lsm_secattr - NetLabel LSM security attributes
165 * @flags: indicate which attributes are contained in this structure 165 * @flags: indicate structure attributes, see NETLBL_SECATTR_*
166 * @type: indicate the NLTYPE of the attributes 166 * @type: indicate the NLTYPE of the attributes
167 * @domain: the NetLabel LSM domain 167 * @domain: the NetLabel LSM domain
168 * @cache: NetLabel LSM specific cache 168 * @cache: NetLabel LSM specific cache
@@ -180,17 +180,22 @@ struct netlbl_lsm_secattr_catmap {
180 * NetLabel itself when returning security attributes to the LSM. 180 * NetLabel itself when returning security attributes to the LSM.
181 * 181 *
182 */ 182 */
183struct netlbl_lsm_secattr {
184 u32 flags;
185 /* bitmap values for 'flags' */
183#define NETLBL_SECATTR_NONE 0x00000000 186#define NETLBL_SECATTR_NONE 0x00000000
184#define NETLBL_SECATTR_DOMAIN 0x00000001 187#define NETLBL_SECATTR_DOMAIN 0x00000001
188#define NETLBL_SECATTR_DOMAIN_CPY (NETLBL_SECATTR_DOMAIN | \
189 NETLBL_SECATTR_FREE_DOMAIN)
185#define NETLBL_SECATTR_CACHE 0x00000002 190#define NETLBL_SECATTR_CACHE 0x00000002
186#define NETLBL_SECATTR_MLS_LVL 0x00000004 191#define NETLBL_SECATTR_MLS_LVL 0x00000004
187#define NETLBL_SECATTR_MLS_CAT 0x00000008 192#define NETLBL_SECATTR_MLS_CAT 0x00000008
188#define NETLBL_SECATTR_SECID 0x00000010 193#define NETLBL_SECATTR_SECID 0x00000010
194 /* bitmap meta-values for 'flags' */
195#define NETLBL_SECATTR_FREE_DOMAIN 0x01000000
189#define NETLBL_SECATTR_CACHEABLE (NETLBL_SECATTR_MLS_LVL | \ 196#define NETLBL_SECATTR_CACHEABLE (NETLBL_SECATTR_MLS_LVL | \
190 NETLBL_SECATTR_MLS_CAT | \ 197 NETLBL_SECATTR_MLS_CAT | \
191 NETLBL_SECATTR_SECID) 198 NETLBL_SECATTR_SECID)
192struct netlbl_lsm_secattr {
193 u32 flags;
194 u32 type; 199 u32 type;
195 char *domain; 200 char *domain;
196 struct netlbl_lsm_cache *cache; 201 struct netlbl_lsm_cache *cache;
@@ -303,7 +308,8 @@ static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)
303 */ 308 */
304static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr) 309static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
305{ 310{
306 kfree(secattr->domain); 311 if (secattr->flags & NETLBL_SECATTR_FREE_DOMAIN)
312 kfree(secattr->domain);
307 if (secattr->flags & NETLBL_SECATTR_CACHE) 313 if (secattr->flags & NETLBL_SECATTR_CACHE)
308 netlbl_secattr_cache_free(secattr->cache); 314 netlbl_secattr_cache_free(secattr->cache);
309 if (secattr->flags & NETLBL_SECATTR_MLS_CAT) 315 if (secattr->flags & NETLBL_SECATTR_MLS_CAT)
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index f37418601215..47295acd09c9 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -2649,7 +2649,7 @@ int security_netlbl_sid_to_secattr(u32 sid, struct netlbl_lsm_secattr *secattr)
2649 goto netlbl_sid_to_secattr_failure; 2649 goto netlbl_sid_to_secattr_failure;
2650 secattr->domain = kstrdup(policydb.p_type_val_to_name[ctx->type - 1], 2650 secattr->domain = kstrdup(policydb.p_type_val_to_name[ctx->type - 1],
2651 GFP_ATOMIC); 2651 GFP_ATOMIC);
2652 secattr->flags |= NETLBL_SECATTR_DOMAIN; 2652 secattr->flags |= NETLBL_SECATTR_DOMAIN_CPY;
2653 mls_export_netlbl_lvl(ctx, secattr); 2653 mls_export_netlbl_lvl(ctx, secattr);
2654 rc = mls_export_netlbl_cat(ctx, secattr); 2654 rc = mls_export_netlbl_cat(ctx, secattr);
2655 if (rc != 0) 2655 if (rc != 0)
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 732ba27923c4..e2d6f7cd9254 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1275,7 +1275,7 @@ static void smack_to_secattr(char *smack, struct netlbl_lsm_secattr *nlsp)
1275 1275
1276 switch (smack_net_nltype) { 1276 switch (smack_net_nltype) {
1277 case NETLBL_NLTYPE_CIPSOV4: 1277 case NETLBL_NLTYPE_CIPSOV4:
1278 nlsp->domain = kstrdup(smack, GFP_ATOMIC); 1278 nlsp->domain = smack;
1279 nlsp->flags = NETLBL_SECATTR_DOMAIN | NETLBL_SECATTR_MLS_LVL; 1279 nlsp->flags = NETLBL_SECATTR_DOMAIN | NETLBL_SECATTR_MLS_LVL;
1280 1280
1281 rc = smack_to_cipso(smack, &cipso); 1281 rc = smack_to_cipso(smack, &cipso);