]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
apparmor: aa_label_alloc use aa_label_free on alloc failure
authorZygmunt Krynicki <me@zygoon.pl>
Sat, 2 May 2026 11:21:33 +0000 (13:21 +0200)
committerJohn Johansen <john.johansen@canonical.com>
Sun, 14 Jun 2026 03:14:06 +0000 (20:14 -0700)
aa_label_alloc() allocates a secid before allocating or taking the label
proxy. If the later proxy step fails, the error path only freed the label
memory, leaking any resources initialized by aa_label_init().

Use aa_label_free() on the failure path so partially initialized labels
release their secid and other label resources before the backing memory is
freed.

Fixes: f1bd904175e81 ("apparmor: add the base fns() for domain labels")
Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/label.c

index a8850d118c9ccde413ec371dd0d86977e443924b..c60244ed96db091075c2a18a235861b2532cd7a8 100644 (file)
@@ -458,7 +458,7 @@ struct aa_label *aa_label_alloc(int size, struct aa_proxy *proxy, gfp_t gfp)
        return new;
 
 fail:
-       kfree(new);
+       aa_label_free(new);
 
        return NULL;
 }