]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
apparmor: fix memory leak in verify_header
authorMassimiliano Pellizzer <massimiliano.pellizzer@canonical.com>
Tue, 20 Jan 2026 14:24:04 +0000 (15:24 +0100)
committerJohn Johansen <john.johansen@canonical.com>
Mon, 9 Mar 2026 23:05:42 +0000 (16:05 -0700)
The function sets `*ns = NULL` on every call, leaking the namespace
string allocated in previous iterations when multiple profiles are
unpacked. This also breaks namespace consistency checking since *ns
is always NULL when the comparison is made.

Remove the incorrect assignment.
The caller (aa_unpack) initializes *ns to NULL once before the loop,
which is sufficient.

Fixes: dd51c8485763 ("apparmor: provide base for multiple profiles to be replaced at once")
Reported-by: Qualys Security Advisory <qsa@qualys.com>
Tested-by: Salvatore Bonaccorso <carnil@debian.org>
Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Reviewed-by: Cengiz Can <cengiz.can@canonical.com>
Signed-off-by: Massimiliano Pellizzer <massimiliano.pellizzer@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/policy_unpack.c

index ba5d40dbeb24529ecee5778c75d004d11aedf12f..5d90ea55de828f39fd9f1641806544bbc781f769 100644 (file)
@@ -1419,7 +1419,6 @@ static int verify_header(struct aa_ext *e, int required, const char **ns)
 {
        int error = -EPROTONOSUPPORT;
        const char *name = NULL;
-       *ns = NULL;
 
        /* get the interface version */
        if (!aa_unpack_u32(e, &e->version, "version")) {