RE: [EXT] Re: [PATCH] crypto: caam: Clear some memory in instantiate_rng()

From: Gaurav Jain
Date: Tue Mar 21 2023 - 02:55:37 EST


Hi

> -----Original Message-----
> From: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> Sent: Tuesday, March 21, 2023 10:37 AM
> To: Gaurav Jain <gaurav.jain@xxxxxxx>
> Cc: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>; Horia Geanta
> <horia.geanta@xxxxxxx>; Pankaj Gupta <pankaj.gupta@xxxxxxx>;
> davem@xxxxxxxxxxxxx; linux-crypto@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx; kernel-janitors@xxxxxxxxxxxxxxx
> 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@xxxxxxxxxxxxxxxxxxx> 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