[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <MN2PR12MB46070886A98A29851B65133BF3929@MN2PR12MB4607.namprd12.prod.outlook.com>
Date: Mon, 3 Apr 2023 09:47:58 +0000
From: "Harsha, Harsha" <harsha.harsha@....com>
To: Herbert Xu <herbert@...dor.apana.org.au>
CC: "davem@...emloft.net" <davem@...emloft.net>,
"linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"michals@...inx.com" <michals@...inx.com>,
"saratcha@...inx.com" <saratcha@...inx.com>,
"git (AMD-Xilinx)" <git@....com>,
"Shah, Dhaval (CPG-PSAV)" <dhaval.r.shah@....com>
Subject: RE: [PATCH V2 3/4] crypto: xilinx: Add ZynqMP RSA driver
Hi Herbert,
> -----Original Message-----
> From: Herbert Xu <herbert@...dor.apana.org.au>
> Sent: Friday, March 31, 2023 2:33 PM
> To: Harsha, Harsha <harsha.harsha@....com>
> Cc: davem@...emloft.net; linux-crypto@...r.kernel.org; linux-
> kernel@...r.kernel.org; linux-arm-kernel@...ts.infradead.org;
> michals@...inx.com; saratcha@...inx.com; git (AMD-Xilinx) <git@....com>;
> Shah, Dhaval (CPG-PSAV) <dhaval.r.shah@....com>
> Subject: Re: [PATCH V2 3/4] crypto: xilinx: Add ZynqMP RSA driver
>
> On Tue, Mar 21, 2023 at 11:04:45AM +0530, Harsha Harsha wrote:
> >
> > +static inline int xilinx_copy_and_save_keypart(u8 **kpbuf, unsigned int
> *kplen,
> > + const u8 *buf, size_t sz) {
> > + int nskip;
> > +
> > + for (nskip = 0; nskip < sz; nskip++)
> > + if (buf[nskip])
> > + break;
> > +
> > + *kplen = sz - nskip;
> > + *kpbuf = kmemdup(buf + nskip, *kplen, GFP_KERNEL);
> > + if (!*kpbuf)
> > + return -ENOMEM;
> > +
> > + return 0;
> > +}
>
> ...
>
> > +static int xilinx_rsa_setkey(struct crypto_akcipher *tfm, const void *key,
> > + unsigned int keylen, bool private) {
> > + struct xilinx_rsa_tfm_ctx *tctx = akcipher_tfm_ctx(tfm);
> > + struct rsa_key raw_key;
> > + int ret;
> > +
> > + if (private)
> > + ret = rsa_parse_priv_key(&raw_key, key, keylen);
> > + else
> > + ret = rsa_parse_pub_key(&raw_key, key, keylen);
> > + if (ret)
> > + goto n_key;
> > +
> > + ret = xilinx_copy_and_save_keypart(&tctx->n_buf, &tctx->n_len,
> > + raw_key.n, raw_key.n_sz);
>
> What happens when you call setkey twice? Wouldn't this leak memory?
Thanks for the review. I will check the behavior and get back to you.
Regards,
Harsha
>
> Cheers,
> --
> Email: Herbert Xu <herbert@...dor.apana.org.au> Home Page:
> http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists