crypto/cnxk: fix bus error on RSA verify

Message ID 20211025040004.3171175-1-kirankumark@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series crypto/cnxk: fix bus error on RSA verify |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Kiran Kumar Kokkilagadda Oct. 25, 2021, 4 a.m. UTC
  From: Kiran Kumar K <kirankumark@marvell.com>

While creating RSA session, private key length is not being
calculated properly. This is causing bus error on RSA verify.
This patch fix the issue with length calculation.

Fixes: 5a3513caeb455 ("crypto/cnxk: add asymmetric session")

Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
---
 drivers/crypto/cnxk/cnxk_ae.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Anoob Joseph Oct. 25, 2021, 4:17 a.m. UTC | #1
> From: Kiran Kumar K <kirankumark@marvell.com>
> 
> While creating RSA session, private key length is not being calculated
> properly. This is causing bus error on RSA verify.
> This patch fix the issue with length calculation.
> 
> Fixes: 5a3513caeb455 ("crypto/cnxk: add asymmetric session")
> 
> Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
> ---
>  drivers/crypto/cnxk/cnxk_ae.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Acked-by: Anoob Joseph <anoobj@marvell.com>
  
Akhil Goyal Oct. 31, 2021, 7:37 p.m. UTC | #2
> > From: Kiran Kumar K <kirankumark@marvell.com>
> >
> > While creating RSA session, private key length is not being calculated
> > properly. This is causing bus error on RSA verify.
> > This patch fix the issue with length calculation.
> >
> > Fixes: 5a3513caeb455 ("crypto/cnxk: add asymmetric session")
> >
> > Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
> > ---
> >  drivers/crypto/cnxk/cnxk_ae.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> 
> Acked-by: Anoob Joseph <anoobj@marvell.com>
Cc:stable@dpdk.org

Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index 00dc75ef9d..6222171fe6 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -82,15 +82,15 @@  cnxk_ae_fill_rsa_params(struct cnxk_ae_sess *sess,
 	struct rte_crypto_rsa_xform *rsa = &sess->rsa_ctx;
 	size_t mod_len = xfrm_rsa->n.length;
 	size_t exp_len = xfrm_rsa->e.length;
-	size_t len = (mod_len / 2);
 	uint64_t total_size;
+	size_t len = 0;
 
 	if (qt.p.length != 0 && qt.p.data == NULL)
 		return -EINVAL;
 
 	/* Make sure key length used is not more than mod_len/2 */
 	if (qt.p.data != NULL)
-		len = RTE_MIN(len, qt.p.length);
+		len = (((mod_len / 2) < qt.p.length) ? 0 : qt.p.length);
 
 	/* Total size required for RSA key params(n,e,(q,dQ,p,dP,qInv)) */
 	total_size = mod_len + exp_len + 5 * len;