Message ID | 16d6bf3bd7a6e96a8262fcd4680e3ccbb5a50478.1679355849.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 j10csp1501388wrt; Mon, 20 Mar 2023 17:04:02 -0700 (PDT) X-Google-Smtp-Source: AK7set/XieNv9BRaxV5R+Hn7GQZTltvIgZ2pKaMseg+A5lctXJsykg62GRpY26qM9Wola2F9DRX3 X-Received: by 2002:a05:6a20:4a0f:b0:d3:5c72:8fb4 with SMTP id fr15-20020a056a204a0f00b000d35c728fb4mr178137pzb.60.1679357042241; Mon, 20 Mar 2023 17:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679357042; cv=none; d=google.com; s=arc-20160816; b=hXgLIpJTi8td5R/yOi4rVlfMDOdBy81D0AAUVQAOLnHVdRb0KxjE9LTaGBYpVqapgx DZ0EAfdSp0qfGkP6n0Xm8oWII1tn/fQQlieoL+dglagN6Ywn/Y6szcytnSWEROzZwSI1 MHIeplh09+OUAgbFA6SIjNtAy3YxJPUv63udXwGj5/PmoUmNX4QuzxHKyIHVunQoLDue QeGET9bbeKA+0SRy7M+wii0j6y/AjIwgrYFVlAS2xoGQrBUbOM4KZNtepHqKJV3xwBCT RpwX91TRrpesQZ0i6LcSOyJ6HIR/qAbt+yaiTmp2wx3seCkvtnkkXK4Y/g6GOcgXV25g gRWw== 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=xtAW4lI/K85GsnVJzlCpLndn9+bY8AumbI9dS/wFDLE=; b=zv65jCE1HrambKJlnf1bnPxzoLMA86Goz2dWSGmfQqCQGsJAQHzDiRtthHRfW8URs+ 0AuO3slZxr5wW0LYqqa/Di3En0X+0hpxFLcKGnNAxk74omc4ylTo+xGXFlybCE5PJBPH sIsfo733Pr/ydoaLWcHiSA4/Mh4fevScnQ1MvzFx3mhth/hJ/8X7p6RISPxzfCaIKgcw vc4QH1BbBcpBqsyTs8/R8G1udccwChttmOxOVfZjfyZjiO89ttm4qkcuGctVK+mqtXmg zrPLIg+msxHSw4xb98LGosuS+Uap5pOnoBkz+hNQIKSSwldrr3dY+NgJlw6h813fZDGR fZ4A== 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 r7-20020a63e507000000b0050f736a8d3dsi4689419pgh.64.2023.03.20.17.03.47; Mon, 20 Mar 2023 17:04:02 -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 S229879AbjCTX6b (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Mon, 20 Mar 2023 19:58:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjCTX6a (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 20 Mar 2023 19:58:30 -0400 Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 21AD630D4 for <linux-kernel@vger.kernel.org>; Mon, 20 Mar 2023 16:58:28 -0700 (PDT) Received: from localhost.localdomain ([78.31.41.93]) by smtp.orange.fr with ESMTPA id ePCEpUM95Kb31ePCGpjTnR; Tue, 21 Mar 2023 00:45:54 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 21 Mar 2023 00:45:54 +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 Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr> Subject: [PATCH] crypto: caam: Clear some memory in instantiate_rng() Date: Tue, 21 Mar 2023 00:45:43 +0100 Message-Id: <16d6bf3bd7a6e96a8262fcd4680e3ccbb5a50478.1679355849.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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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?1760933490156361139?= X-GMAIL-MSGID: =?utf-8?q?1760933490156361139?= |
Series |
crypto: caam: Clear some memory in instantiate_rng()
|
|
Commit Message
Christophe JAILLET
March 20, 2023, 11:45 p.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.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is speculative, but can't hurt.
Maybe the memset() at the end of the 'for' loop could be removed instead.
---
drivers/crypto/caam/ctrl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, Mar 21, 2023 at 12:45:43AM +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. > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > This patch is speculative, but can't hurt. > > Maybe the memset() at the end of the 'for' loop could be removed instead. I think the memset can be removed. Horia?
Hi Herbert > -----Original Message----- > From: Herbert Xu <herbert@gondor.apana.org.au> > Sent: Tuesday, March 21, 2023 8:57 AM > To: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > Cc: Horia Geanta <horia.geanta@nxp.com>; Pankaj Gupta > <pankaj.gupta@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>; > davem@davemloft.net; linux-crypto@vger.kernel.org; linux- > kernel@vger.kernel.org; kernel-janitors@vger.kernel.org > Subject: [EXT] Re: [PATCH] crypto: caam: Clear some memory in > instantiate_rng() > > Caution: EXT Email > > On Tue, Mar 21, 2023 at 12:45:43AM +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. > > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > --- > > This patch is speculative, but can't hurt. > > > > Maybe the memset() at the end of the 'for' loop could be removed instead. > > I think the memset can be removed. Horia? memset() is needed to clear the desc for each state handle before recreating descriptor. So it is required. Regards Gaurav Jain > -- > Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgondor > .apana.org.au%2F~herbert%2F&data=05%7C01%7Cgaurav.jain%40nxp.com% > 7C93eb192d0c734fc5105e08db29bc1da2%7C686ea1d3bc2b4c6fa92cd99c5c3 > 01635%7C0%7C0%7C638149660155476281%7CUnknown%7CTWFpbGZsb3d8 > eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3 > D%7C3000%7C%7C%7C&sdata=S%2Bh6BA5ka9HoWb%2BHq8Vwb3TwnEu8b > RZ5scpGvOxg8iw%3D&reserved=0 > PGP Key: > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgondor > .apana.org.au%2F~herbert%2Fpubkey.txt&data=05%7C01%7Cgaurav.jain%4 > 0nxp.com%7C93eb192d0c734fc5105e08db29bc1da2%7C686ea1d3bc2b4c6fa > 92cd99c5c301635%7C0%7C0%7C638149660155476281%7CUnknown%7CTWF > pbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV > CI6Mn0%3D%7C3000%7C%7C%7C&sdata=7YT4gr8kviqJYFABOcg6UgZL3BceG > 3oY4HUSUuUwAdg%3D&reserved=0
On Tue, Mar 21, 2023 at 05:03:24AM +0000, Gaurav Jain wrote: > > memset() is needed to clear the desc for each state handle before recreating descriptor. > So it is required. OK so we should move it to the top of the loop then. Thanks,
Hi > -----Original Message----- > From: Herbert Xu <herbert@gondor.apana.org.au> > Sent: Tuesday, March 21, 2023 10:37 AM > To: Gaurav Jain <gaurav.jain@nxp.com> > Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>; Horia Geanta > <horia.geanta@nxp.com>; Pankaj Gupta <pankaj.gupta@nxp.com>; > davem@davemloft.net; linux-crypto@vger.kernel.org; linux- > kernel@vger.kernel.org; kernel-janitors@vger.kernel.org > Subject: Re: [EXT] Re: [PATCH] crypto: caam: Clear some memory in > instantiate_rng() > > Caution: EXT Email > > On Tue, Mar 21, 2023 at 05:03:24AM +0000, Gaurav Jain wrote: > > > > memset() is needed to clear the desc for each state handle before > recreating descriptor. > > So it is required. > > OK so we should move it to the top of the loop then. kzalloc() will zeroize the contents of desc for the first time. In this case memset() is ok at the end for instantiating other rng handles. Thanks Gaurav > > Thanks, > -- > Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgondor > .apana.org.au%2F~herbert%2F&data=05%7C01%7Cgaurav.jain%40nxp.com% > 7C46125a50355a466bbd6208db29ca159a%7C686ea1d3bc2b4c6fa92cd99c5c3 > 01635%7C0%7C0%7C638149720177317067%7CUnknown%7CTWFpbGZsb3d8 > eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3 > D%7C3000%7C%7C%7C&sdata=DmvSAsFT0dY%2FL%2FP5lcw90hR0FYAKRdnI > kZxiaMN1MVk%3D&reserved=0 > PGP Key: > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgondor > .apana.org.au%2F~herbert%2Fpubkey.txt&data=05%7C01%7Cgaurav.jain%4 > 0nxp.com%7C46125a50355a466bbd6208db29ca159a%7C686ea1d3bc2b4c6fa > 92cd99c5c301635%7C0%7C0%7C638149720177317067%7CUnknown%7CTWF > pbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV > CI6Mn0%3D%7C3000%7C%7C%7C&sdata=8NA1ediu3cnWLFbisXecjq5Z%2BuK > uztPYtlcRDCPSMno%3D&reserved=0
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 32253a064d0f..e4e971dc0f96 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -276,7 +276,7 @@ static int instantiate_rng(struct device *ctrldev, int state_handle_mask, int ret = 0, sh_idx; ctrl = (struct caam_ctrl __iomem *)ctrlpriv->ctrl; - desc = kmalloc(CAAM_CMD_SZ * 7, GFP_KERNEL | GFP_DMA); + desc = kzalloc(CAAM_CMD_SZ * 7, GFP_KERNEL | GFP_DMA); if (!desc) return -ENOMEM;