Message ID | 41a7e41bb5a14f1e6e68a81c16c90e3ad4542ab1.1679381782.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1631203wrt; Tue, 21 Mar 2023 00:14:41 -0700 (PDT) X-Google-Smtp-Source: AK7set/w3DYlUgWmL+N/md0AJFFkY5UCpTD2Ptix88jTLrXhmjBq9Qg7f+kkVTPqnbB3+mXwY1+Z X-Received: by 2002:a17:903:2309:b0:1a1:a8eb:d34d with SMTP id d9-20020a170903230900b001a1a8ebd34dmr1563212plh.46.1679382881707; Tue, 21 Mar 2023 00:14:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679382881; cv=none; d=google.com; s=arc-20160816; b=e4Mz8LGsw9BckfSlFhSASroUMW5Oc/gnAa56j48NfzVpQRrNrjfg96XXlHkh0EOO5T +uMBn4vyHQ3q0MLrLXbz7bClpTQ4n7honzWiVukBn0P8rzPFxNmxKOqBZ/Gbbi3O9Pk/ AtcoMDaaR0K18ve3DuWPD7xlimBfDyORYmagZOQLNBsajllY+u+y5ijSM8LEWPrnMJBw KmLFJlRqzI/TQSj3KYUtAWJgLvW7/SB7Utb/f31jtl3cSvBZELG127hYeMRQbFDvjnLb F8ad26LrqJIJDODfuy26Xkk8hi3Xg68Mh2k/P95RMUe8Q6MfxeYZGqcs256E12S2yvkP Z1/w== 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 :message-id:date:subject:cc:to:from; bh=7XZ81h8HNpwJdgDQGs4nUpWNS1YxPh2qrhyHPfAgTGY=; b=h8Dq2ElYwJhTyQPlWyZZze+ecM2S6hl8OpBh82O9Rl5qKXn3GB0AJkaBnd28Z0oInN kg6wnPy+2yPEM9NoMVZIEVhccUwhWZJIUcx2zJYO80vSiKzb5eHBG9ZFRd+RxZ5TrXKS W3w1HBslC8EZlAJ2ZnqbeOUvdiePvH769Hxwj4MwQ3wCIJpFq1tiaRIHHmsTozLVjkF0 DNrD+4g2z3kRlOLlx2S7kOIIVx6rTh99ShJZPQ6NrJSUvP2NsnKaMldh5ItK+JMzy/8m S0YQ362Eav+gVuYnXt7MKnU7cvKoOUOK7AT3Pd5SDiw9jrR23OM4hlj5uc5g7Y2rftBJ lBHg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a170902d2cc00b0019cbce6331asi13205129plc.490.2023.03.21.00.14.29; Tue, 21 Mar 2023 00:14:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230491AbjCUG7z (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Tue, 21 Mar 2023 02:59:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbjCUG7n (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 21 Mar 2023 02:59:43 -0400 Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D69456A7F for <linux-kernel@vger.kernel.org>; Mon, 20 Mar 2023 23:59:38 -0700 (PDT) Received: from ubuntu-CJ.centvel.lan ([78.31.41.93]) by smtp.orange.fr with ESMTPA id eVy0pApSCqbhzeVy1p9iHb; Tue, 21 Mar 2023 07:59:36 +0100 X-ME-Helo: ubuntu-CJ.centvel.lan X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 21 Mar 2023 07:59:36 +0100 X-ME-IP: 78.31.41.93 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: horia.geanta@nxp.com, pankaj.gupta@nxp.com, gaurav.jain@nxp.com, herbert@gondor.apana.org.au, davem@davemloft.net, kim.phillips@freescale.com Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr> Subject: [PATCH v2] crypto: caam: Clear some memory in instantiate_rng() Date: Tue, 21 Mar 2023 07:59:30 +0100 Message-Id: <41a7e41bb5a14f1e6e68a81c16c90e3ad4542ab1.1679381782.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760960584177010046?= X-GMAIL-MSGID: =?utf-8?q?1760960584177010046?= |
Series |
[v2] crypto: caam: Clear some memory in instantiate_rng()
|
|
Commit Message
Christophe JAILLET
March 21, 2023, 6:59 a.m. UTC
According to the comment at the end of the 'for' loop just a few lines
below, it looks needed to clear 'desc'.
So it should also be cleared for the first iteration.
Move the memset() to the beginning of the loop to be safe.
Fixes: 281922a1d4f5 ("crypto: caam - add support for SEC v5.x RNG4")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
v1 --> v2:
- move the memset() instead of doing s/kmalloc/kzalloc/
- adding a Fixes tag
v1:
https://lore.kernel.org/all/16d6bf3bd7a6e96a8262fcd4680e3ccbb5a50478.1679355849.git.christophe.jaillet@wanadoo.fr/
For for loop has been introduceD in commit 1005bccd7a4a ("crypto: caam -
enable instantiation of all RNG4 state handles"). But if 'desc' really
needs to be cleared, the issue was there before (thus the Fixes tag in
the commit log)
---
drivers/crypto/caam/ctrl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com> > -----Original Message----- > From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > Sent: Tuesday, March 21, 2023 12:30 PM > To: Horia Geanta <horia.geanta@nxp.com>; Pankaj Gupta > <pankaj.gupta@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>; > herbert@gondor.apana.org.au; davem@davemloft.net; > kim.phillips@freescale.com > Cc: linux-crypto@vger.kernel.org; linux-kernel@vger.kernel.org; kernel- > janitors@vger.kernel.org; Christophe JAILLET <christophe.jaillet@wanadoo.fr> > Subject: [EXT] [PATCH v2] crypto: caam: Clear some memory in > instantiate_rng() > > Caution: EXT Email > > According to the comment at the end of the 'for' loop just a few lines below, > it looks needed to clear 'desc'. > > So it should also be cleared for the first iteration. > > Move the memset() to the beginning of the loop to be safe. > > Fixes: 281922a1d4f5 ("crypto: caam - add support for SEC v5.x RNG4") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > v1 --> v2: > - move the memset() instead of doing s/kmalloc/kzalloc/ > - adding a Fixes tag > > v1: > > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.k > ernel.org%2Fall%2F16d6bf3bd7a6e96a8262fcd4680e3ccbb5a50478.16793558 > 49.git.christophe.jaillet%40wanadoo.fr%2F&data=05%7C01%7Cgaurav.jain% > 40nxp.com%7Ca1c8a2f58318494a475008db29d9d586%7C686ea1d3bc2b4c6f > a92cd99c5c301635%7C0%7C0%7C638149787790408570%7CUnknown%7CTW > FpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJX > VCI6Mn0%3D%7C3000%7C%7C%7C&sdata=UruZict6nLO%2FncETIzKtbI7wBET > K7%2BfcAEzQyxcS5rU%3D&reserved=0 > > For for loop has been introduceD in commit 1005bccd7a4a ("crypto: caam - > enable instantiation of all RNG4 state handles"). But if 'desc' really needs to > be cleared, the issue was there before (thus the Fixes tag in the commit log) > --- > drivers/crypto/caam/ctrl.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index > 6278afb951c3..71b14269a997 100644 > --- a/drivers/crypto/caam/ctrl.c > +++ b/drivers/crypto/caam/ctrl.c > @@ -284,6 +284,10 @@ static int instantiate_rng(struct device *ctrldev, int > state_handle_mask, > const u32 rdsta_if = RDSTA_IF0 << sh_idx; > const u32 rdsta_pr = RDSTA_PR0 << sh_idx; > const u32 rdsta_mask = rdsta_if | rdsta_pr; > + > + /* Clear the contents before using the descriptor */ > + memset(desc, 0x00, CAAM_CMD_SZ * 7); > + > /* > * If the corresponding bit is set, this state handle > * was initialized by somebody else, so it's left alone. > @@ -327,8 +331,6 @@ static int instantiate_rng(struct device *ctrldev, int > state_handle_mask, > } > > dev_info(ctrldev, "Instantiated RNG4 SH%d\n", sh_idx); > - /* Clear the contents before recreating the descriptor */ > - memset(desc, 0x00, CAAM_CMD_SZ * 7); > } > > kfree(desc); > -- > 2.32.0
On Tue, Mar 21, 2023 at 07:59:30AM +0100, Christophe JAILLET wrote: > According to the comment at the end of the 'for' loop just a few lines > below, it looks needed to clear 'desc'. > > So it should also be cleared for the first iteration. > > Move the memset() to the beginning of the loop to be safe. > > Fixes: 281922a1d4f5 ("crypto: caam - add support for SEC v5.x RNG4") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > v1 --> v2: > - move the memset() instead of doing s/kmalloc/kzalloc/ > - adding a Fixes tag > > v1: > https://lore.kernel.org/all/16d6bf3bd7a6e96a8262fcd4680e3ccbb5a50478.1679355849.git.christophe.jaillet@wanadoo.fr/ > > For for loop has been introduceD in commit 1005bccd7a4a ("crypto: caam - > enable instantiation of all RNG4 state handles"). But if 'desc' really > needs to be cleared, the issue was there before (thus the Fixes tag in > the commit log) > --- > drivers/crypto/caam/ctrl.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) Patch applied. Thanks.
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 6278afb951c3..71b14269a997 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -284,6 +284,10 @@ static int instantiate_rng(struct device *ctrldev, int state_handle_mask, const u32 rdsta_if = RDSTA_IF0 << sh_idx; const u32 rdsta_pr = RDSTA_PR0 << sh_idx; const u32 rdsta_mask = rdsta_if | rdsta_pr; + + /* Clear the contents before using the descriptor */ + memset(desc, 0x00, CAAM_CMD_SZ * 7); + /* * If the corresponding bit is set, this state handle * was initialized by somebody else, so it's left alone. @@ -327,8 +331,6 @@ static int instantiate_rng(struct device *ctrldev, int state_handle_mask, } dev_info(ctrldev, "Instantiated RNG4 SH%d\n", sh_idx); - /* Clear the contents before recreating the descriptor */ - memset(desc, 0x00, CAAM_CMD_SZ * 7); } kfree(desc);