From patchwork Tue Mar 2 09:09:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Li X-Patchwork-Id: 12111269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 746D1C433E0 for ; Tue, 2 Mar 2021 09:10:44 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F30FC61494 for ; Tue, 2 Mar 2021 09:10:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F30FC61494 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=xpVYQrl+5CqZXZFIq9joht039LjJmQrGq0QweEAPJUk=; b=oi04OQrHgsGvwgsEgTOTcd3gLV rorMdwmNW8VhdW0RlgWy6mZTDqumoo5rvrxXu3bHncpnhf2EiK2/sPVmYwIb0Hh3GpDbaouB/hgop jp6xvOo7KlejoqgFwcjgr09FX5p/nTpPrif2uGhS0dVQcWPjxYk9YKls2SCiCjMbz/ifzShi86Mws zNBiV3X4y4ErKznWYeCrg4LhKTbW4uvU+9DHE2k7Qas7H3pxkX3OPvT5eJQ3nJWgziRmZwSx+xq8u illFRV0g6dcktXQLJoJFD7QH+QL3L6YvnGOoL79LLxivKlYqE7Dm4VSFwke0axMSRgI6nANl+zf0f X2n1A1AQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lH11r-0008Qy-Oz; Tue, 02 Mar 2021 09:09:19 +0000 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lH11o-0008PJ-M9 for linux-arm-kernel@lists.infradead.org; Tue, 02 Mar 2021 09:09:18 +0000 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R201e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e04426; MF=yang.lee@linux.alibaba.com; NM=1; PH=DS; RN=10; SR=0; TI=SMTPD_---0UQ4egCQ_1614676146; Received: from j63c13417.sqa.eu95.tbsite.net(mailfrom:yang.lee@linux.alibaba.com fp:SMTPD_---0UQ4egCQ_1614676146) by smtp.aliyun-inc.com(127.0.0.1); Tue, 02 Mar 2021 17:09:07 +0800 From: Yang Li To: clabbe.montjoie@gmail.com Subject: [PATCH v2] crypto: sun8i-ce: use kfree_sensitive() instead of Date: Tue, 2 Mar 2021 17:09:05 +0800 Message-Id: <1614676145-93512-1-git-send-email-yang.lee@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_040916_967631_18384CCF X-CRM114-Status: UNSURE ( 8.14 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jernej.skrabec@siol.net, herbert@gondor.apana.org.au, linux-kernel@vger.kernel.org, mripard@kernel.org, wens@csie.org, Yang Li , linux-crypto@vger.kernel.org, davem@davemloft.net, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use kfree_sensitive() instead of using kfree() to make the intention of the API more explicit. fixed the following coccicheck: ./drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c:30:16-17: WARNING opportunity for kfree_sensitive/kvfree_sensitive (memset at line 29) ./drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c:42:16-17: WARNING opportunity for kfree_sensitive/kvfree_sensitive (memset at line 41) ./drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c:161:8-9: WARNING opportunity for kfree_sensitive/kvfree_sensitive (memset at line 109) Reported-by: Abaci Robot Signed-off-by: Yang Li --- Changes in v2 -Change the appropriate title drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c index cfde9ee..8259d52 100644 --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c @@ -27,7 +27,7 @@ void sun8i_ce_prng_exit(struct crypto_tfm *tfm) struct sun8i_ce_rng_tfm_ctx *ctx = crypto_tfm_ctx(tfm); memzero_explicit(ctx->seed, ctx->slen); - kfree(ctx->seed); + kfree_sensitive(ctx->seed); ctx->seed = NULL; ctx->slen = 0; } @@ -39,7 +39,7 @@ int sun8i_ce_prng_seed(struct crypto_rng *tfm, const u8 *seed, if (ctx->seed && ctx->slen != slen) { memzero_explicit(ctx->seed, ctx->slen); - kfree(ctx->seed); + kfree_sensitive(ctx->seed); ctx->slen = 0; ctx->seed = NULL; } @@ -158,7 +158,7 @@ int sun8i_ce_prng_generate(struct crypto_rng *tfm, const u8 *src, } memzero_explicit(d, todo); err_iv: - kfree(d); + kfree_sensitive(d); err_mem: return err; }