Commit a913c940 authored by John Johansen's avatar John Johansen Committed by Greg Kroah-Hartman

apparmor: fix refcount race when finding a child profile

commit de7c4cc9 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: default avatarJohn Johansen <john.johansen@canonical.com>
Acked-by: default avatarSeth Arnold <seth.arnold@canonical.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a15f1d0d
......@@ -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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment