Signed-off-by: Ryan Lee <[email protected]>
---
security/apparmor/policy.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
index f6f1b72d7c3d..d24c9291035b 100644
--- a/security/apparmor/policy.c
+++ b/security/apparmor/policy.c
@@ -1138,17 +1138,20 @@ static void share_name(struct aa_profile *old, struct
aa_profile *new)
static struct aa_profile *update_to_newest_parent(struct aa_profile *new)
{
struct aa_profile *parent, *newest;
+ bool needput;
parent = rcu_dereference_protected(new->parent,
mutex_is_locked(&new->ns->lock));
- newest = aa_get_newest_profile(parent);
+ newest = aa_get_newest_profile_condref(parent, &needput);
/* parent replaced in this atomic set? */
if (newest != parent) {
+ /* newest will be put when new->parent gets cleaned up */
+ AA_BUG(!needput);
aa_put_profile(parent);
rcu_assign_pointer(new->parent, newest);
} else
- aa_put_profile(newest);
+ aa_put_profile_condref(newest, needput);
return newest;
}
--
2.43.0