[apparmor] [PATCH 37/43] apparmor: baby step - now add labels to the labelset trees

John Johansen john.johansen at canonical.com
Fri Feb 8 21:01:13 UTC 2013


Just add the labels to the tree to make sure insertions and deletions
into the rb tree are working.

Signed-off-by: John Johansen <john.johansen at canonical.com>
---
 security/apparmor/policy.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
index 89b1335..7585ddd 100644
--- a/security/apparmor/policy.c
+++ b/security/apparmor/policy.c
@@ -1248,6 +1248,8 @@ ssize_t aa_replace_profiles(void *udata, size_t size, bool noreplace)
 		if (old) {
 			share_name(old, new);
 			__replace_profile(old, new);
+			aa_label_replace(&ns->labels, &old->label, &new->label);
+			__aa_labelset_invalidate_all(ns, old);
 			if (rename) {
 				/* TODO:
 				__replace_profile(rename, new);
@@ -1258,6 +1260,7 @@ ssize_t aa_replace_profiles(void *udata, size_t size, bool noreplace)
 			/* TODO: move children to new */
 			__aa_fs_profile_rmdir(rename);
 		} else {
+			struct aa_label *l;
 			/*
 			 * set replacedby backref to new only when, it
 			 * has a file in the interface fs. The backref will
@@ -1265,6 +1268,8 @@ ssize_t aa_replace_profiles(void *udata, size_t size, bool noreplace)
 			 */
 			new->replacedby->profile = aa_get_profile(new);
 			__list_add_profile(&policy->profiles, new);
+			l = aa_label_insert(&ns->labels, &new->label);
+			aa_put_label(l);
 		}
 		aa_put_profile(rename);
 		aa_put_profile(old);
@@ -1354,6 +1359,8 @@ ssize_t aa_remove_profiles(char *fqname, size_t size)
 		}
 		name = profile->base.hname;
 		__remove_profile(profile);
+		aa_label_remove(&ns->labels, &profile->label);
+		__aa_labelset_invalidate_all(ns, profile);
 		mutex_unlock(&ns->lock);
 	}
 
-- 
1.7.10.4




More information about the AppArmor mailing list