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 412AC20F88 for ; Fri, 21 Jul 2023 19:07:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B501AC433C7; Fri, 21 Jul 2023 19:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689966423; bh=nEBMnRdzm8+vrLGl9jwmXxblkHYL0QG4tMRlx2RrLr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZppYH5+Y1gWhUqLC8iBTTPcYPadvdfM62PYE1+ONR7FrYJV4n6Qb3pDJuF0yBQVZE EpIGm6K3vbCCvO9GAeBER1mF1dEKQp2RQ5uQ9IOFAObahvJm+/mgGqJDfnlcHmBN7L p4ZOtpc7rMLozmBiUWrgI6x/gJJwwXnU0AMSqxgo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Danila Chernetsov , John Johansen , Sasha Levin Subject: [PATCH 5.15 338/532] apparmor: fix missing error check for rhashtable_insert_fast Date: Fri, 21 Jul 2023 18:04:02 +0200 Message-ID: <20230721160632.756990872@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230721160614.695323302@linuxfoundation.org> References: <20230721160614.695323302@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: Danila Chernetsov [ Upstream commit 000518bc5aef25d3f703592a0296d578c98b1517 ] rhashtable_insert_fast() could return err value when memory allocation is failed. but unpack_profile() do not check values and this always returns success value. This patch just adds error check code. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: e025be0f26d5 ("apparmor: support querying extended trusted helper extra data") Signed-off-by: Danila Chernetsov Signed-off-by: John Johansen Signed-off-by: Sasha Levin --- security/apparmor/policy_unpack.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c index d5b3a062d1d18..5f758b289ace3 100644 --- a/security/apparmor/policy_unpack.c +++ b/security/apparmor/policy_unpack.c @@ -909,8 +909,13 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) goto fail; } - rhashtable_insert_fast(profile->data, &data->head, - profile->data->p); + if (rhashtable_insert_fast(profile->data, &data->head, + profile->data->p)) { + kfree_sensitive(data->key); + kfree_sensitive(data); + info = "failed to insert data to table"; + goto fail; + } } if (!unpack_nameX(e, AA_STRUCTEND, NULL)) { -- 2.39.2