From patchwork Fri Mar 26 01:20:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yekai (A)" X-Patchwork-Id: 12165429 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 180B2C433E1 for ; Fri, 26 Mar 2021 01:24:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA02E61A3A for ; Fri, 26 Mar 2021 01:24:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230063AbhCZBXd (ORCPT ); Thu, 25 Mar 2021 21:23:33 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:14879 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbhCZBX0 (ORCPT ); Thu, 25 Mar 2021 21:23:26 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F641b2WFXz9tC1; Fri, 26 Mar 2021 09:21:23 +0800 (CST) Received: from huawei.com (10.67.165.24) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Fri, 26 Mar 2021 09:23:15 +0800 From: Kai Ye To: CC: , , , Subject: [PATCH 1/3] crypto: atmel - use memzero_explicit() for clearing data Date: Fri, 26 Mar 2021 09:20:46 +0800 Message-ID: <1616721648-56258-2-git-send-email-yekai13@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1616721648-56258-1-git-send-email-yekai13@huawei.com> References: <1616721648-56258-1-git-send-email-yekai13@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org use memzero_explicit instead of memset to clear sensitive data, such as key. Signed-off-by: Kai Ye --- drivers/crypto/atmel-sha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c index 352d80c..4a08b2a 100644 --- a/drivers/crypto/atmel-sha.c +++ b/drivers/crypto/atmel-sha.c @@ -1622,7 +1622,7 @@ static inline void atmel_sha_hmac_key_init(struct atmel_sha_hmac_key *hkey) static inline void atmel_sha_hmac_key_release(struct atmel_sha_hmac_key *hkey) { kfree(hkey->keydup); - memset(hkey, 0, sizeof(*hkey)); + memzero_explicit(hkey, sizeof(*hkey)); } static inline int atmel_sha_hmac_key_set(struct atmel_sha_hmac_key *hkey, From patchwork Fri Mar 26 01:20:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yekai (A)" X-Patchwork-Id: 12165425 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 CB22FC433C1 for ; Fri, 26 Mar 2021 01:24:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89223619B6 for ; Fri, 26 Mar 2021 01:24:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230018AbhCZBXb (ORCPT ); Thu, 25 Mar 2021 21:23:31 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14547 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbhCZBX0 (ORCPT ); Thu, 25 Mar 2021 21:23:26 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F640z2lCYzPm6m; Fri, 26 Mar 2021 09:20:51 +0800 (CST) Received: from huawei.com (10.67.165.24) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Fri, 26 Mar 2021 09:23:16 +0800 From: Kai Ye To: CC: , , , Subject: [PATCH 2/3] crypto: qce - use memzero_explicit() for clearing data Date: Fri, 26 Mar 2021 09:20:47 +0800 Message-ID: <1616721648-56258-3-git-send-email-yekai13@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1616721648-56258-1-git-send-email-yekai13@huawei.com> References: <1616721648-56258-1-git-send-email-yekai13@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org use memzero_explicit instead of memset to clear sensitive data. Signed-off-by: Kai Ye --- drivers/crypto/qce/sha.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 61c418c..cb9b3da 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -415,6 +415,7 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, ret = crypto_wait_req(crypto_ahash_digest(req), &wait); + memzero_explicit(buf, keylen + QCE_MAX_ALIGN_SIZE); kfree(buf); err_free_req: ahash_request_free(req); From patchwork Fri Mar 26 01:20:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yekai (A)" X-Patchwork-Id: 12165427 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 00C10C433E0 for ; Fri, 26 Mar 2021 01:24:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF8F761A38 for ; Fri, 26 Mar 2021 01:24:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbhCZBXc (ORCPT ); Thu, 25 Mar 2021 21:23:32 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:14880 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbhCZBX0 (ORCPT ); Thu, 25 Mar 2021 21:23:26 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F641b24WFz9tC0; Fri, 26 Mar 2021 09:21:23 +0800 (CST) Received: from huawei.com (10.67.165.24) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Fri, 26 Mar 2021 09:23:16 +0800 From: Kai Ye To: CC: , , , Subject: [PATCH 3/3] crypto: stm32 - use memzero_explicit() for clearing data Date: Fri, 26 Mar 2021 09:20:48 +0800 Message-ID: <1616721648-56258-4-git-send-email-yekai13@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1616721648-56258-1-git-send-email-yekai13@huawei.com> References: <1616721648-56258-1-git-send-email-yekai13@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org use memzero_explicit instead of memset to clear sensitive data Signed-off-by: Kai Ye --- drivers/crypto/stm32/stm32-cryp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c index 2a479317..c4297e80 100644 --- a/drivers/crypto/stm32/stm32-cryp.c +++ b/drivers/crypto/stm32/stm32-cryp.c @@ -675,7 +675,7 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp, int err) crypto_finalize_skcipher_request(cryp->engine, cryp->req, err); - memset(cryp->ctx->key, 0, cryp->ctx->keylen); + memzero_explicit(cryp->ctx->key, cryp->ctx->keylen); } static int stm32_cryp_cpu_start(struct stm32_cryp *cryp)