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 7F073749E for ; Thu, 12 Jan 2023 14:14:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8257C433D2; Thu, 12 Jan 2023 14:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673532850; bh=MLRtfCooDebbWIHo2dsGHUY0wjpBQIhx4CKbimFIDYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Axl97txA6G+Irsfooxh6yynmoGh37Ss5CmNcAbw6KNOlcQOHbqoxvF7TLWzUXyoG1 FUlWeAX26u9PCs9CEb1CU3UR/y0Ql2AQXYnHuLPHqgrXJ7H5P9lcWNlUFDqcYckoff 6a3AgXjX59qxD6jq84peopugI+hw8uwdrEwXj/cw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiu Jianfeng , John Johansen , Sasha Levin Subject: [PATCH 5.10 296/783] apparmor: Fix memleak in alloc_ns() Date: Thu, 12 Jan 2023 14:50:12 +0100 Message-Id: <20230112135538.050196200@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112135524.143670746@linuxfoundation.org> References: <20230112135524.143670746@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Xiu Jianfeng [ Upstream commit e9e6fa49dbab6d84c676666f3fe7d360497fd65b ] After changes in commit a1bd627b46d1 ("apparmor: share profile name on replacement"), the hname member of struct aa_policy is not valid slab object, but a subset of that, it can not be freed by kfree_sensitive(), use aa_policy_destroy() to fix it. Fixes: a1bd627b46d1 ("apparmor: share profile name on replacement") Signed-off-by: Xiu Jianfeng Signed-off-by: John Johansen Signed-off-by: Sasha Levin --- security/apparmor/policy_ns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/apparmor/policy_ns.c b/security/apparmor/policy_ns.c index 70921d95fb40..53d24cf63893 100644 --- a/security/apparmor/policy_ns.c +++ b/security/apparmor/policy_ns.c @@ -121,7 +121,7 @@ static struct aa_ns *alloc_ns(const char *prefix, const char *name) return ns; fail_unconfined: - kfree_sensitive(ns->base.hname); + aa_policy_destroy(&ns->base); fail_ns: kfree_sensitive(ns); return NULL; -- 2.35.1