summaryrefslogtreecommitdiff
path: root/security/apparmor/policy.c
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2015-12-17 02:09:10 (GMT)
committerJohn Johansen <john.johansen@canonical.com>2016-07-12 15:43:10 (GMT)
commitde7c4cc947f9f56f61520ee7edaf380434a98c8d (patch)
tree8da638b921498bba5fca1fc2b4192166f45700ef /security/apparmor/policy.c
parent0b938a2e2cf0b0a2c8bac9769111545aff0fee97 (diff)
downloadlinux-de7c4cc947f9f56f61520ee7edaf380434a98c8d.tar.xz
apparmor: fix refcount race when finding a child profile
When finding a child profile via an rcu critical section, the profile may be put and scheduled for deletion after the child is found but before its refcount is incremented. Protect against this by repeating the lookup if the profiles refcount is 0 and is one its way to deletion. Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Seth Arnold <seth.arnold@canonical.com>
Diffstat (limited to 'security/apparmor/policy.c')
-rw-r--r--security/apparmor/policy.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
index ca402d0..7807125 100644
--- a/security/apparmor/policy.c
+++ b/security/apparmor/policy.c
@@ -766,7 +766,9 @@ struct aa_profile *aa_find_child(struct aa_profile *parent, const char *name)
struct aa_profile *profile;
rcu_read_lock();
- profile = aa_get_profile(__find_child(&parent->base.profiles, name));
+ do {
+ profile = __find_child(&parent->base.profiles, name);
+ } while (profile && !aa_get_profile_not0(profile));
rcu_read_unlock();
/* refcount released by caller */