Skip to content

Commit

Permalink
AppArmor: Fix locking from removal of profile namespace
Browse files Browse the repository at this point in the history
The locking for profile namespace removal is wrong, when removing a
profile namespace, it needs to be removed from its parent's list.
Lock the parent of namespace list instead of the namespace being removed.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
John Johansen authored and James Morris committed Sep 7, 2010
1 parent 04ccd53 commit 999b4f0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions security/apparmor/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,12 +1151,14 @@ ssize_t aa_remove_profiles(char *fqname, size_t size)
/* released below */
ns = aa_get_namespace(root);

write_lock(&ns->lock);
if (!name) {
/* remove namespace - can only happen if fqname[0] == ':' */
write_lock(&ns->parent->lock);
__remove_namespace(ns);
write_unlock(&ns->parent->lock);
} else {
/* remove profile */
write_lock(&ns->lock);
profile = aa_get_profile(__lookup_profile(&ns->base, name));
if (!profile) {
error = -ENOENT;
Expand All @@ -1165,8 +1167,8 @@ ssize_t aa_remove_profiles(char *fqname, size_t size)
}
name = profile->base.hname;
__remove_profile(profile);
write_unlock(&ns->lock);
}
write_unlock(&ns->lock);

/* don't fail removal if audit fails */
(void) audit_policy(OP_PROF_RM, GFP_KERNEL, name, info, error);
Expand Down

0 comments on commit 999b4f0

Please sign in to comment.