* [dpdk-dev] [PATCH 1/3] test/crypto: fix asym session mempool creation
@ 2020-06-08 13:15 Adam Dybkowski
2020-06-08 13:15 ` [dpdk-dev] [PATCH 2/3] cryptodev: verify session mempool element size Adam Dybkowski
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Adam Dybkowski @ 2020-06-08 13:15 UTC (permalink / raw)
To: dev, fiona.trahe, akhil.goyal; +Cc: Adam Dybkowski, stable
This patch fixes the element size of the mempool used
for allocating asym crypto sessions and their private data.
Fixes: 2c6dab9cd93d ("test/crypto: add RSA and Mod tests")
Cc: stable@dpdk.org
Signed-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
app/test/test_cryptodev_asym.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index b8e050048..dc62ed7bf 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -935,8 +935,9 @@ testsuite_setup(void)
}
/* setup asym session pool */
- unsigned int session_size =
- rte_cryptodev_asym_get_private_session_size(dev_id);
+ unsigned int session_size = RTE_MAX(
+ rte_cryptodev_asym_get_private_session_size(dev_id),
+ rte_cryptodev_asym_get_header_session_size());
/*
* Create mempool with TEST_NUM_SESSIONS * 2,
* to include the session headers
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH 2/3] cryptodev: verify session mempool element size
2020-06-08 13:15 [dpdk-dev] [PATCH 1/3] test/crypto: fix asym session mempool creation Adam Dybkowski
@ 2020-06-08 13:15 ` Adam Dybkowski
2020-06-24 14:56 ` Trahe, Fiona
2020-06-08 13:15 ` [dpdk-dev] [PATCH 3/3] crypto/qat: verify session IOVA Adam Dybkowski
2020-06-24 14:49 ` [dpdk-dev] [PATCH 1/3] test/crypto: fix asym session mempool creation Trahe, Fiona
2 siblings, 1 reply; 8+ messages in thread
From: Adam Dybkowski @ 2020-06-08 13:15 UTC (permalink / raw)
To: dev, fiona.trahe, akhil.goyal; +Cc: Adam Dybkowski
This patch adds the verification of the element size of the
mempool provided for the session creation. Returns the error
if the element size is too small to hold the session object.
Signed-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
lib/librte_cryptodev/rte_cryptodev.c | 45 +++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 8 deletions(-)
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index e37b83afd..9ea4ece65 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1422,7 +1422,7 @@ rte_cryptodev_sym_session_init(uint8_t dev_id,
dev = rte_cryptodev_pmd_get_dev(dev_id);
- if (sess == NULL || xforms == NULL || dev == NULL)
+ if (sess == NULL || xforms == NULL || dev == NULL || mp == NULL)
return -EINVAL;
if (mp->elt_size < sess_priv_sz)
@@ -1540,24 +1540,39 @@ rte_cryptodev_sym_session_data_size(struct rte_cryptodev_sym_session *sess)
sess->user_data_sz;
}
+static uint8_t
+rte_cryptodev_sym_is_valid_session_pool(struct rte_mempool *mp)
+{
+ struct rte_cryptodev_sym_session_pool_private_data *pool_priv;
+
+ if (!mp)
+ return 0;
+
+ pool_priv = rte_mempool_get_priv(mp);
+
+ if (!pool_priv || mp->private_data_size < sizeof(*pool_priv) ||
+ pool_priv->nb_drivers != nb_drivers ||
+ mp->elt_size <
+ rte_cryptodev_sym_get_header_session_size()
+ + pool_priv->user_data_sz)
+ return 0;
+
+ return 1;
+}
+
struct rte_cryptodev_sym_session *
rte_cryptodev_sym_session_create(struct rte_mempool *mp)
{
struct rte_cryptodev_sym_session *sess;
struct rte_cryptodev_sym_session_pool_private_data *pool_priv;
- if (!mp) {
+ if (!rte_cryptodev_sym_is_valid_session_pool(mp)) {
CDEV_LOG_ERR("Invalid mempool\n");
return NULL;
}
pool_priv = rte_mempool_get_priv(mp);
- if (!pool_priv || mp->private_data_size < sizeof(*pool_priv)) {
- CDEV_LOG_ERR("Invalid mempool\n");
- return NULL;
- }
-
/* Allocate a session structure from the session pool */
if (rte_mempool_get(mp, (void **)&sess)) {
CDEV_LOG_ERR("couldn't get object from session mempool");
@@ -1582,6 +1597,20 @@ struct rte_cryptodev_asym_session *
rte_cryptodev_asym_session_create(struct rte_mempool *mp)
{
struct rte_cryptodev_asym_session *sess;
+ unsigned int session_size =
+ rte_cryptodev_asym_get_header_session_size();
+
+ if (!mp) {
+ CDEV_LOG_ERR("invalid mempool\n");
+ return NULL;
+ }
+
+ /* Verify if provided mempool can hold elements big enough. */
+ if (mp->elt_size < session_size) {
+ CDEV_LOG_ERR(
+ "mempool elements too small to hold session objects");
+ return NULL;
+ }
/* Allocate a session structure from the session pool */
if (rte_mempool_get(mp, (void **)&sess)) {
@@ -1592,7 +1621,7 @@ rte_cryptodev_asym_session_create(struct rte_mempool *mp)
/* Clear device session pointer.
* Include the flag indicating presence of private data
*/
- memset(sess, 0, (sizeof(void *) * nb_drivers) + sizeof(uint8_t));
+ memset(sess, 0, session_size);
rte_cryptodev_trace_asym_session_create(mp, sess);
return sess;
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH 3/3] crypto/qat: verify session IOVA
2020-06-08 13:15 [dpdk-dev] [PATCH 1/3] test/crypto: fix asym session mempool creation Adam Dybkowski
2020-06-08 13:15 ` [dpdk-dev] [PATCH 2/3] cryptodev: verify session mempool element size Adam Dybkowski
@ 2020-06-08 13:15 ` Adam Dybkowski
2020-06-24 15:08 ` Trahe, Fiona
2020-06-24 14:49 ` [dpdk-dev] [PATCH 1/3] test/crypto: fix asym session mempool creation Trahe, Fiona
2 siblings, 1 reply; 8+ messages in thread
From: Adam Dybkowski @ 2020-06-08 13:15 UTC (permalink / raw)
To: dev, fiona.trahe, akhil.goyal; +Cc: Adam Dybkowski
This patch adds the verification of the crypto session IOVA
that should be known (not zero) to proceed with the
session initialisation. In case of unknown IOVA
the error code -EINVAL is returned.
Signed-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
drivers/crypto/qat/qat_sym_session.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c
index 58bdbd343..11b459ee8 100644
--- a/drivers/crypto/qat/qat_sym_session.c
+++ b/drivers/crypto/qat/qat_sym_session.c
@@ -537,8 +537,16 @@ qat_sym_session_set_parameters(struct rte_cryptodev *dev,
int ret;
int qat_cmd_id;
+ /* Verify the session physical address is known */
+ rte_iova_t session_paddr = rte_mempool_virt2iova(session);
+ if (session_paddr == 0 || session_paddr == RTE_BAD_IOVA) {
+ QAT_LOG(ERR,
+ "Session physical address unknown. Bad memory pool.");
+ return -EINVAL;
+ }
+
/* Set context descriptor physical address */
- session->cd_paddr = rte_mempool_virt2iova(session) +
+ session->cd_paddr = session_paddr +
offsetof(struct qat_sym_session, cd);
session->min_qat_dev_gen = QAT_GEN1;
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] test/crypto: fix asym session mempool creation
2020-06-08 13:15 [dpdk-dev] [PATCH 1/3] test/crypto: fix asym session mempool creation Adam Dybkowski
2020-06-08 13:15 ` [dpdk-dev] [PATCH 2/3] cryptodev: verify session mempool element size Adam Dybkowski
2020-06-08 13:15 ` [dpdk-dev] [PATCH 3/3] crypto/qat: verify session IOVA Adam Dybkowski
@ 2020-06-24 14:49 ` Trahe, Fiona
2020-07-01 19:53 ` Akhil Goyal
2 siblings, 1 reply; 8+ messages in thread
From: Trahe, Fiona @ 2020-06-24 14:49 UTC (permalink / raw)
To: Dybkowski, AdamX, dev, akhil.goyal; +Cc: stable
> -----Original Message-----
> From: Dybkowski, AdamX <adamx.dybkowski@intel.com>
> Sent: Monday, June 8, 2020 2:15 PM
> To: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com
> Cc: Dybkowski, AdamX <adamx.dybkowski@intel.com>; stable@dpdk.org
> Subject: [PATCH 1/3] test/crypto: fix asym session mempool creation
>
> This patch fixes the element size of the mempool used
> for allocating asym crypto sessions and their private data.
>
> Fixes: 2c6dab9cd93d ("test/crypto: add RSA and Mod tests")
> Cc: stable@dpdk.org
>
> Signed-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] cryptodev: verify session mempool element size
2020-06-08 13:15 ` [dpdk-dev] [PATCH 2/3] cryptodev: verify session mempool element size Adam Dybkowski
@ 2020-06-24 14:56 ` Trahe, Fiona
2020-07-01 19:54 ` Akhil Goyal
0 siblings, 1 reply; 8+ messages in thread
From: Trahe, Fiona @ 2020-06-24 14:56 UTC (permalink / raw)
To: Dybkowski, AdamX, dev, akhil.goyal
> -----Original Message-----
> From: Dybkowski, AdamX <adamx.dybkowski@intel.com>
> Sent: Monday, June 8, 2020 2:15 PM
> To: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com
> Cc: Dybkowski, AdamX <adamx.dybkowski@intel.com>
> Subject: [PATCH 2/3] cryptodev: verify session mempool element size
>
> This patch adds the verification of the element size of the
> mempool provided for the session creation. Returns the error
> if the element size is too small to hold the session object.
>
> Signed-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH 3/3] crypto/qat: verify session IOVA
2020-06-08 13:15 ` [dpdk-dev] [PATCH 3/3] crypto/qat: verify session IOVA Adam Dybkowski
@ 2020-06-24 15:08 ` Trahe, Fiona
0 siblings, 0 replies; 8+ messages in thread
From: Trahe, Fiona @ 2020-06-24 15:08 UTC (permalink / raw)
To: Dybkowski, AdamX, dev, akhil.goyal
> -----Original Message-----
> From: Dybkowski, AdamX <adamx.dybkowski@intel.com>
> Sent: Monday, June 8, 2020 2:15 PM
> To: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com
> Cc: Dybkowski, AdamX <adamx.dybkowski@intel.com>
> Subject: [PATCH 3/3] crypto/qat: verify session IOVA
>
> This patch adds the verification of the crypto session IOVA
> that should be known (not zero) to proceed with the
> session initialisation. In case of unknown IOVA
> the error code -EINVAL is returned.
>
> Signed-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] test/crypto: fix asym session mempool creation
2020-06-24 14:49 ` [dpdk-dev] [PATCH 1/3] test/crypto: fix asym session mempool creation Trahe, Fiona
@ 2020-07-01 19:53 ` Akhil Goyal
0 siblings, 0 replies; 8+ messages in thread
From: Akhil Goyal @ 2020-07-01 19:53 UTC (permalink / raw)
To: Trahe, Fiona, Dybkowski, AdamX, dev; +Cc: stable
> > This patch fixes the element size of the mempool used
> > for allocating asym crypto sessions and their private data.
> >
> > Fixes: 2c6dab9cd93d ("test/crypto: add RSA and Mod tests")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>
> Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] cryptodev: verify session mempool element size
2020-06-24 14:56 ` Trahe, Fiona
@ 2020-07-01 19:54 ` Akhil Goyal
0 siblings, 0 replies; 8+ messages in thread
From: Akhil Goyal @ 2020-07-01 19:54 UTC (permalink / raw)
To: Trahe, Fiona, Dybkowski, AdamX, dev
> > Subject: [PATCH 2/3] cryptodev: verify session mempool element size
> >
> > This patch adds the verification of the element size of the
> > mempool provided for the session creation. Returns the error
> > if the element size is too small to hold the session object.
> >
> > Signed-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>
> Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
Series applied to dpdk-next-crypto
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-07-01 19:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08 13:15 [dpdk-dev] [PATCH 1/3] test/crypto: fix asym session mempool creation Adam Dybkowski
2020-06-08 13:15 ` [dpdk-dev] [PATCH 2/3] cryptodev: verify session mempool element size Adam Dybkowski
2020-06-24 14:56 ` Trahe, Fiona
2020-07-01 19:54 ` Akhil Goyal
2020-06-08 13:15 ` [dpdk-dev] [PATCH 3/3] crypto/qat: verify session IOVA Adam Dybkowski
2020-06-24 15:08 ` Trahe, Fiona
2020-06-24 14:49 ` [dpdk-dev] [PATCH 1/3] test/crypto: fix asym session mempool creation Trahe, Fiona
2020-07-01 19:53 ` Akhil Goyal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).