Skip to contentSkip to conversation

netlabel: use domain based selectors when address based selectors are not available

PATCH Applied Paul Moore 2 participants 2 messages Aug 2, 2013

Subsystems (4)
lore
Share & tools
lore

Paul Moore

author
#0 lore raw

PATCH 1/1 netlabel: use domain based selectors when address based selectors are not available

NetLabel has the ability to selectively assign network security labels to outbound traffic based on either the LSM's "domain" (different for each LSM), the network destination, or a combination of both. Depending on the type of traffic, local or forwarded, and the type of traffic selector, domain or address based, different hooks are used to label the traffic; the goal being minimal overhead.

Unfortunately, there is a bug such that a system using NetLabel domain based traffic selectors does not correctly label outbound local traffic that is not assigned to a socket. The issue is that in these cases the associated NetLabel hook only looks at the address based selectors and not the domain based selectors. This patch corrects this by checking both the domain and address based selectors so that the correct labeling is applied, regardless of the configuration type.

In order to acomplish this fix, this patch also simplifies some of the NetLabel domainhash structures to use a more common outbound traffic mapping type: struct netlbl_dommap_def. This simplifies some of the code in this patch and paves the way for further simplifications in the future.

---
 net/netlabel/netlabel_cipso_v4.c   |    4 +
 net/netlabel/netlabel_domainhash.c |  104 +++++++++++++++++-------------------
 net/netlabel/netlabel_domainhash.h |   46 ++++++++--------
 net/netlabel/netlabel_kapi.c       |   88 ++++++++++++------------------
 net/netlabel/netlabel_mgmt.c       |   44 +++++++--------
 net/netlabel/netlabel_unlabeled.c  |    2 -
 6 files changed, 130 insertions(+), 158 deletions(-)
net/netlabel/netlabel_cipso_v4.c +2 -2
index c15042f..a110064 100644
@@ -691,8 +691,8 @@ static int netlbl_cipsov4_remove_cb(struct netlbl_dom_map *entry, void *arg)
 {
 	struct netlbl_domhsh_walk_arg *cb_arg = arg;
 
-	if (entry->type == NETLBL_NLTYPE_CIPSOV4 &&
-	    entry->type_def.cipsov4->doi == cb_arg->doi)
+	if (entry->def.type == NETLBL_NLTYPE_CIPSOV4 &&
+	    entry->def.cipso->doi == cb_arg->doi)
 		return netlbl_domhsh_remove_entry(entry, cb_arg->audit_info);
 
 	return 0;
net/netlabel/netlabel_domainhash.c +49 -55

264 lines not on this page · raw message

net/netlabel/netlabel_domainhash.h +22 -24

75 lines not on this page · raw message

net/netlabel/netlabel_kapi.c +35 -53

184 lines not on this page · raw message

net/netlabel/netlabel_mgmt.c +21 -23

135 lines not on this page · raw message

net/netlabel/netlabel_unlabeled.c +1 -1
index af35319..8f08974 100644
@@ -1541,7 +1541,7 @@ int __init netlbl_unlabel_defconf(void)
 	entry = kzalloc(sizeof(*entry), GFP_KERNEL);
 	if (entry == NULL)
 		return -ENOMEM;
-	entry->type = NETLBL_NLTYPE_UNLABELED;
+	entry->def.type = NETLBL_NLTYPE_UNLABELED;
 	ret_val = netlbl_domhsh_add_default(entry, &audit_info);
 	if (ret_val != 0)
 		return ret_val;
maintainer Applied
#1 lore raw

From: Paul Moore <[email protected]>
Date: Fri, 02 Aug 2013 14:45:08 -0400

Quoted 15 lines

NetLabel has the ability to selectively assign network security labels to outbound traffic based on either the LSM's "domain" (different for each LSM), the network destination, or a combination of both. Depending on the type of traffic, local or forwarded, and the type of traffic selector, domain or address based, different hooks are used to label the traffic; the goal being minimal overhead.

Unfortunately, there is a bug such that a system using NetLabel domain based traffic selectors does not correctly label outbound local traffic that is not assigned to a socket. The issue is that in these cases the associated NetLabel hook only looks at the address based selectors and not the domain based selectors. This patch corrects this by checking both the domain and address based selectors so that the correct labeling is applied, regardless of the configuration type.

Quoted 7 lines

In order to acomplish this fix, this patch also simplifies some of the NetLabel domainhash structures to use a more common outbound traffic mapping type: struct netlbl_dommap_def. This simplifies some of the code in this patch and paves the way for further simplifications in the future.

Applied, thanks Paul.