From: Massimiliano Pellizzer Date: Mon, 13 Apr 2026 06:39:11 +0000 (-0700) Subject: apparmor: fix memory leak in verify_header X-Git-Tag: v6.1.169~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bcf82c0c5a8b383fd2d5d8f3fd880cdcab2ac557;p=thirdparty%2Fkernel%2Fstable.git apparmor: fix memory leak in verify_header commit e38c55d9f834e5b848bfed0f5c586aaf45acb825 upstream. 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 Tested-by: Salvatore Bonaccorso Reviewed-by: Georgia Garcia Reviewed-by: Cengiz Can Signed-off-by: Massimiliano Pellizzer Signed-off-by: John Johansen Signed-off-by: Greg Kroah-Hartman --- diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c index 1f8628a418dac..9e6f3e0d4265a 100644 --- a/security/apparmor/policy_unpack.c +++ b/security/apparmor/policy_unpack.c @@ -959,7 +959,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")) {