From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3BD73AF66F; Thu, 12 Mar 2026 20:29:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773347369; cv=none; b=a5MPRFMqRuE17ISi5dON30qYERRm7yEIX1Q6RkJtt0jJo3R8687xPQBPzYLSV02nm+JIZARkvrtqnGMZkRjsWeFn87Oow4L715kvokibwjzSKFsCmdvr8E35oOhRaVCtQdlsahgHfdt3xOYTcIx9GYI1IdXJeVQkd3RpSe53FfI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773347369; c=relaxed/simple; bh=ED29GbfCSctyJUw2XEa9pvOEb11nQpt9wyujCuE2+tI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ukwmpMJo4axSV0JeyXwcRzBO2WC0pSDsqQGoyeETSNdbNGIT2lzJHXB4u/G5RwTStlpVs9Omb3auNcOe8qCaRN77KShH8zY1DT871enOPwk4TdmyDqFDUxAgVQb5P/LWHOiRtWfrGJVOGvH2rqHGCvIogu9cMB+r59mSrO4Afuc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oIPTicvR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="oIPTicvR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83A6CC4CEF7; Thu, 12 Mar 2026 20:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1773347368; bh=ED29GbfCSctyJUw2XEa9pvOEb11nQpt9wyujCuE2+tI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oIPTicvR3ASMFU5WWDFlCOotxj+nra3yg8IPfZXHoBTS+mmwL9a13axgEaTKqZfE6 hT9MDwApNBp+CPFYAfhB1vxq4lL7No4QKr/WDx8NIV9yqgTww60B/auKcP5qJuSlad MOjK3RQYq1zeUC9SIhq1izDL81+fSm/CuTKL4gwc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qualys Security Advisory , Salvatore Bonaccorso , Georgia Garcia , Cengiz Can , John Johansen Subject: [PATCH 6.12 256/265] apparmor: Fix double free of ns_name in aa_replace_profiles() Date: Thu, 12 Mar 2026 21:10:43 +0100 Message-ID: <20260312201027.594218839@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260312201018.128816016@linuxfoundation.org> References: <20260312201018.128816016@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: John Johansen commit 5df0c44e8f5f619d3beb871207aded7c78414502 upstream. if ns_name is NULL after 1071 error = aa_unpack(udata, &lh, &ns_name); and if ent->ns_name contains an ns_name in 1089 } else if (ent->ns_name) { then ns_name is assigned the ent->ns_name 1095 ns_name = ent->ns_name; however ent->ns_name is freed at 1262 aa_load_ent_free(ent); and then again when freeing ns_name at 1270 kfree(ns_name); Fix this by NULLing out ent->ns_name after it is transferred to ns_name Fixes: 145a0ef21c8e9 ("apparmor: fix blob compression when ns is forced on a policy load") Reported-by: Qualys Security Advisory Tested-by: Salvatore Bonaccorso Reviewed-by: Georgia Garcia Reviewed-by: Cengiz Can Signed-off-by: John Johansen Signed-off-by: Greg Kroah-Hartman --- security/apparmor/policy.c | 1 + 1 file changed, 1 insertion(+) --- a/security/apparmor/policy.c +++ b/security/apparmor/policy.c @@ -1118,6 +1118,7 @@ ssize_t aa_replace_profiles(struct aa_ns goto fail; } ns_name = ent->ns_name; + ent->ns_name = NULL; } else count++; }