]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
apparmor: fix memory leak when deduping profile load
authorJohn Johansen <john.johansen@canonical.com>
Sat, 14 Apr 2018 05:33:10 +0000 (22:33 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Thu, 7 Jun 2018 08:51:01 +0000 (01:51 -0700)
AppArmor is leaking the newly loaded profile and its proxy when
the profile is an exact match to the currently loaded version.

In this case the dedup check results in the profile being skipped and
put without dealing with the proxy ref thus not breaking a circular
refcount and causing a leak.

BugLink: http://bugs.launchpad.net/bugs/1750594
Fixes: 5d5182cae401 ("apparmor: move to per loaddata files, instead of replicating in profiles")
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/policy.c

index b367fef33d037f78a1fd95e47b2f900d557749aa..1590e2de4e841c131ac472fa5e9c312d448b0866 100644 (file)
@@ -1008,6 +1008,9 @@ ssize_t aa_replace_profiles(struct aa_ns *policy_ns, struct aa_label *label,
                        audit_policy(label, op, ns_name, ent->new->base.hname,
                                     "same as current profile, skipping",
                                     error);
+                       /* break refcount cycle with proxy. */
+                       aa_put_proxy(ent->new->label.proxy);
+                       ent->new->label.proxy = NULL;
                        goto skip;
                }