]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
UBUNTU: SAUCE: apparmor: fix memory leak when duplicate profile load
authorJohn Johansen <john.johansen@canonical.com>
Sat, 14 Apr 2018 05:52:58 +0000 (22:52 -0700)
committerSeth Forshee <seth.forshee@canonical.com>
Mon, 16 Apr 2018 19:09:23 +0000 (14:09 -0500)
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 match check results in the profile being skipped
and put with out dealing with the proxy and forwarding thus creating
a circular refcount and a leak.

BugLink: http://bugs.launchpad.net/bugs/1750594
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Forshee <seth.forshee@canonical.com>
Acked-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
security/apparmor/policy.c

index b0b58848c2487e69cca16f9bfd3ee21d466a12af..a92c167c92492e139913f101225b12cdd77129dc 100644 (file)
@@ -1003,6 +1003,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;
                }