Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4379391pxb; Tue, 2 Mar 2021 13:44:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1p+iZr+eKOm4skIGT2mPau//BGoVfYtxYxiD+k7uP4Mfh/tYTljS3f/469+o5fhRfGoXJ X-Received: by 2002:a17:906:684b:: with SMTP id a11mr14027540ejs.329.1614721481106; Tue, 02 Mar 2021 13:44:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614721481; cv=none; d=google.com; s=arc-20160816; b=ISL1w618yd5UyTVKVqlCE9X6XEMxHhOTgbsisBaHlX93cHA9i3awZiBLQNGRAAasZk ig7M04DUVzjdYGMcUASnBPIAM2It9hPWium5qockl85IbjPWoMbHH45RqLlHbcEDTn/s lizJl3u0rFLXEjaAe5o8AOscfK+7FrPflt9e+n8sJ5y0blIFsrOCfsQwxn9/fYakFLCn xlAvI/fJT4Ca+IkbUAD4Ml36K4QBYR6eexblScw5HKpCd/Qzs4+3QRy+XFsrqqZqed49 pH0D/9RTo5nSEHaFrJAsHdDjLDiIJC4Wyp67vm+D9XgAJAQrU1/vQHe2AAyqrbbgiVnn 8LRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=gUKm2NN6KlwacrihJvuBy26o9MqKN0GlZ/sb2lFMckY=; b=LjHWxS5RnB/NqpN/hgi8kK0lHGFdVit7Raa0EFQvnHTw5ceQtBNU5MnaLaTtx1LgqT 3LVdnenyWpzcN45Ml9rBUFu/AYohdbomR8dmif9K4twZI1McpSzbkIf0ozPPR1uhLuPV S4MoUMfWep7npOD1Q0/U9WWQjcAwytEzdZXKpOGRAyZRFv0uxzsn+9GLE0868IG4PFQ9 t6uHSEGga+a61hy6CKz5g3OZMiHqnMpGv95X4U5d/6BYeNwEx0MxsjF19BcV6pkvP6QT 6wthjeIhintF5N3mNqCN0J0qUl72LVd5v73/jE1j6VUsTRd5UsmIAZ5aeei5sPaW8SmS RkJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si11394213eja.156.2021.03.02.13.44.18; Tue, 02 Mar 2021 13:44:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379004AbhCBJhA (ORCPT + 99 others); Tue, 2 Mar 2021 04:37:00 -0500 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:49091 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1837909AbhCBJJu (ORCPT ); Tue, 2 Mar 2021 04:09:50 -0500 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 Cc: herbert@gondor.apana.org.au, davem@davemloft.net, mripard@kernel.org, wens@csie.org, jernej.skrabec@siol.net, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Yang Li 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; } -- 1.8.3.1