Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp659597pxb; Tue, 5 Apr 2022 17:40:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL7kym2vMYIaa5No5hZqIgSwxN5RRy7OnddPGNbscuwOI5lyovvU1maM2kSXZwbXSChCuk X-Received: by 2002:a05:6402:42d4:b0:416:5cac:a9a0 with SMTP id i20-20020a05640242d400b004165caca9a0mr6346578edc.86.1649205643319; Tue, 05 Apr 2022 17:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649205643; cv=none; d=google.com; s=arc-20160816; b=vQTUeyvTKC5A1HgA/axgzhfmFN2ai2mavAd2Mr7D0v8O15Uj5r0iDJiPfy8d/tFmOn 0A4D0sLyE9kcC8yB9YF83Z6FzJIckOkqOc8v5JMbtT/8sPIc2ma7aOFN0Gz3fmbvjkiR HE4ypmKvOgjiLbuDlXdokzF1m0c3ydyOfylT09N27hMr6D5xD0j+WJ0h+wXwRTw21dKQ 87NP4CqatiQofqkGKV2Bf/zn40atTzQ6WlhVvliT/KuE4kskxTiKxlx9KKKWALrFb9nn 4DeJI5Eerd2TFTN8Bm0mFSlD0lLY7HPC8vZsUl1yIkRhyWLPmW/0HxKSKmI6OURI31je mUYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/eI3+Y07T4twlcGMz/6K0EjClMSjoGcGRXYaKfiPdTU=; b=cU4EuxAF6Se4k1XqJaFb7fFJTw2rJoHb40DO8o6r5IgJwXrRN6ZyWgGa4rcBUQn0B5 2/l2EX5Mydbfy25ysu7kNoL0TQJcT+ETKMXbd91EGdnxm5zHdBuYGB82Ei5bKY/Mf0bo zDPVUjeeDqSM4a9hA9qnbeAdU1uROvHJOWf5eKaVc1u7MygtFxWQ/fZjaQUR3RczmuYP FgTn1LiQnurBMwZ3N1gxAzy26BVQi5/wgl8wlD4ChAFgIEPfXpMuMIigkOjKLeP0TkyD 1ASp4KivAnI/EisukufH27b0CIwocf1e5TKdp4WlbmZK0aUqD+4zeARi9pmWfV5cFtsK fCSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dpGk3jeW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a170906044300b006e00eb3a624si10292769eja.41.2022.04.05.17.40.18; Tue, 05 Apr 2022 17:40:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dpGk3jeW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378883AbiDELjk (ORCPT + 99 others); Tue, 5 Apr 2022 07:39:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244718AbiDEIwf (ORCPT ); Tue, 5 Apr 2022 04:52:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F11F515718; Tue, 5 Apr 2022 01:42:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AF41EB81C14; Tue, 5 Apr 2022 08:42:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9FE3C385A1; Tue, 5 Apr 2022 08:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148149; bh=YFr4/nojKaAOU/ZZjc5sHloKXZS8yH7kQ2huS/c3kYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dpGk3jeWY+cewBcUP4BRF3NZRPQlbE9XssvjxwanlUA04N/OS45P+B/MqNF7or1re RjnD6iaLTSI5LzBktp9ekXcz+Kf3pTYwNZEbqa6Bja/d/EVl7mM2d/kUr/5ApoVfc1 nKKxGTnimpdNyZvaIsAgOOvRHWXAUckNF1qL3ano= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jianglei Nie , Herbert Xu , Sasha Levin Subject: [PATCH 5.16 0251/1017] crypto: ccree - Fix use after free in cc_cipher_exit() Date: Tue, 5 Apr 2022 09:19:24 +0200 Message-Id: <20220405070401.712674946@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jianglei Nie [ Upstream commit 3d950c34074ed74d2713c3856ba01264523289e6 ] kfree_sensitive(ctx_p->user.key) will free the ctx_p->user.key. But ctx_p->user.key is still used in the next line, which will lead to a use after free. We can call kfree_sensitive() after dev_dbg() to avoid the uaf. Fixes: 63ee04c8b491 ("crypto: ccree - add skcipher support") Signed-off-by: Jianglei Nie Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/ccree/cc_cipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index 78833491f534..309da6334a0a 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -257,8 +257,8 @@ static void cc_cipher_exit(struct crypto_tfm *tfm) &ctx_p->user.key_dma_addr); /* Free key buffer in context */ - kfree_sensitive(ctx_p->user.key); dev_dbg(dev, "Free key buffer in context. key=@%p\n", ctx_p->user.key); + kfree_sensitive(ctx_p->user.key); } struct tdes_keys { -- 2.34.1