diff options
author | John Johansen <john.johansen@canonical.com> | 2015-12-16 18:09:10 -0800 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2017-01-27 11:16:12 +0100 |
commit | 7a203ea257e9e3b701344a4bc42fceddff32f915 (patch) | |
tree | 5e2d2eb65891b69a5cd38ff601e698fb25708f59 | |
parent | c49d78b41c7c1cf1b5fed3be2fa0c0eefd884c82 (diff) | |
download | linux-stable-7a203ea257e9e3b701344a4bc42fceddff32f915.tar.gz linux-stable-7a203ea257e9e3b701344a4bc42fceddff32f915.tar.bz2 linux-stable-7a203ea257e9e3b701344a4bc42fceddff32f915.zip |
apparmor: fix refcount race when finding a child profile
commit de7c4cc947f9f56f61520ee7edaf380434a98c8d upstream.
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>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
-rw-r--r-- | security/apparmor/policy.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c index ca402d028db8..780712553651 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 */ |