Skip to contentSkip to conversation

crypto: fix asymmetric private session variable size

PATCH Applied Ciara Power 4 participants 5 messages Feb 18, 2022 – Feb 22, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: fix asymmetric private session variable size

When creating the asymmetric session mempool, the maximum private session size of all devices is used when creating the mempool object size.
The return value for ``rte_cryptodev_asym_get_private_session_size`` is unsigned int, whereas the variable was uint8_t, leading to a possible overflow issue.

To fix this, the variable for private session size is now changed to unsigned int to match the function return type.

Fixes 1f1e4b7cbaad ("cryptodev: use single mempool for asymmetric session")
---
 lib/cryptodev/rte_cryptodev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/cryptodev/rte_cryptodev.c +2 -1
index 727d271fb9..d262ae6ffa 100644
@@ -1810,7 +1810,8 @@ rte_cryptodev_asym_session_pool_create(const char *name, uint32_t nb_elts,
 	struct rte_mempool *mp;
 	struct rte_cryptodev_asym_session_pool_private_data *pool_priv;
 	uint32_t obj_sz, obj_sz_aligned;
-	uint8_t dev_id, priv_sz, max_priv_sz = 0;
+	uint8_t dev_id;
+	unsigned int priv_sz, max_priv_sz = 0;
 
 	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
 		if (rte_cryptodev_is_valid_dev(dev_id)) {
Signature · 1 line
2.25.1
#1 lore raw

Hi Ciara,

Quoted 33 lines

-----Original Message-----
From: Power, Ciara <[email protected]>
Sent: Friday, February 18, 2022 12:58 PM
To: [email protected]
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Kusztal, ArkadiuszX <[email protected]>; Power, Ciara <[email protected]>
Subject: [PATCH] crypto: fix asymmetric private session variable size

When creating the asymmetric session mempool, the maximum private session size of all devices is used when creating the mempool object size.
The return value for ``rte_cryptodev_asym_get_private_session_size`` is unsigned int, whereas the variable was uint8_t, leading to a possible overflow issue.

To fix this, the variable for private session size is now changed to unsigned int to match the function return type.

Fixes 1f1e4b7cbaad ("cryptodev: use single mempool for asymmetric

session")

---
 lib/cryptodev/rte_cryptodev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/cryptodev/rte_cryptodev.c +0 -0
index 727d271fb9..d262ae6ffa 100644

lib/cryptodev/rte_cryptodev.c rte_cryptodev_asym_session_pool_create(const · line 1815

Quoted 7 lines
lib/cryptodev/rte_cryptodev.c +2 -1
@@ -1810,7 +1810,8 @@ rte_cryptodev_asym_session_pool_create(const
 char *name, uint32_t nb_elts,
 	struct rte_mempool *mp;
 	struct rte_cryptodev_asym_session_pool_private_data *pool_priv;
 	uint32_t obj_sz, obj_sz_aligned;
-	uint8_t dev_id, priv_sz, max_priv_sz = 0;
+	uint8_t dev_id;
+	unsigned int priv_sz, max_priv_sz = 0;

I guess it is better to use uint32_t instead of unsigned int? I know they are most likely the same thing but probably better to use consistent type.

Quoted 5 lines
lib/cryptodev/rte_cryptodev.c +0 -1
 	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
 		if (rte_cryptodev_is_valid_dev(dev_id)) {
--

2.25.1

Regards,
Fan

Acked-by on v1 1/1
#2 lore raw
In reply to Ciara Power
Quoted 42 lines

-----Original Message-----
From: Power, Ciara <[email protected]>
Sent: Friday, February 18, 2022 12:58 PM
To: [email protected]
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Kusztal, ArkadiuszX <[email protected]>; Power, Ciara <[email protected]>
Subject: [PATCH] crypto: fix asymmetric private session variable size

When creating the asymmetric session mempool, the maximum private session size of all devices is used when creating the mempool object size.
The return value for ``rte_cryptodev_asym_get_private_session_size`` is unsigned int, whereas the variable was uint8_t, leading to a possible overflow issue.

To fix this, the variable for private session size is now changed to unsigned int to match the function return type.

Fixes 1f1e4b7cbaad ("cryptodev: use single mempool for asymmetric

session")

---
 lib/cryptodev/rte_cryptodev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/cryptodev/rte_cryptodev.c +2 -1
index 727d271fb9..d262ae6ffa 100644
@@ -1810,7 +1810,8 @@ rte_cryptodev_asym_session_pool_create(const
 char *name, uint32_t nb_elts,
 	struct rte_mempool *mp;
 	struct rte_cryptodev_asym_session_pool_private_data *pool_priv;
 	uint32_t obj_sz, obj_sz_aligned;
-	uint8_t dev_id, priv_sz, max_priv_sz = 0;
+	uint8_t dev_id;
+	unsigned int priv_sz, max_priv_sz = 0;
 
 	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
Quoted 3 lines

if (rte_cryptodev_is_valid_dev(dev_id)) {
--
2.25.1

Looks like the variable type of unsigned int is match the return type. So

#3 lore raw
Quoted 50 lines

-----Original Message-----
From: Zhang, Roy Fan <[email protected]>
Sent: Friday, February 18, 2022 3:08 PM
To: Power, Ciara <[email protected]>; [email protected]
Cc: [email protected]; Kusztal, ArkadiuszX <[email protected]>
Subject: RE: [PATCH] crypto: fix asymmetric private session variable size

Quoted 41 lines

-----Original Message-----
From: Power, Ciara <[email protected]>
Sent: Friday, February 18, 2022 12:58 PM
To: [email protected]
Cc: Zhang, Roy Fan <[email protected]>; [email protected]; Kusztal, ArkadiuszX <[email protected]>; Power, Ciara <[email protected]>
Subject: [PATCH] crypto: fix asymmetric private session variable size

When creating the asymmetric session mempool, the maximum private session size of all devices is used when creating the mempool object size.
The return value for ``rte_cryptodev_asym_get_private_session_size`` is unsigned int, whereas the variable was uint8_t, leading to a possible overflow issue.

To fix this, the variable for private session size is now changed to unsigned int to match the function return type.

Fixes 1f1e4b7cbaad ("cryptodev: use single mempool for asymmetric

session")

---
 lib/cryptodev/rte_cryptodev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/lib/cryptodev/rte_cryptodev.c index 727d271fb9..d262ae6ffa 100644

lib/cryptodev/rte_cryptodev.c +2 -1
@@ -1810,7 +1810,8 @@ rte_cryptodev_asym_session_pool_create(const
 char *name, uint32_t nb_elts,
 	struct rte_mempool *mp;
 	struct rte_cryptodev_asym_session_pool_private_data *pool_priv;
 	uint32_t obj_sz, obj_sz_aligned;
-	uint8_t dev_id, priv_sz, max_priv_sz = 0;
+	uint8_t dev_id;
+	unsigned int priv_sz, max_priv_sz = 0;
 
Quoted 6 lines
Quoted 4 lines
lib/cryptodev/rte_cryptodev.c +0 -0
 	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)

if (rte_cryptodev_is_valid_dev(dev_id)) {
--
2.25.1

Looks like the variable type of unsigned int is match the return type. So

Applied
#4 lore raw
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

When creating the asymmetric session mempool, the maximum private session size of all devices is used when creating the mempool object size.
The return value for ``rte_cryptodev_asym_get_private_session_size`` is unsigned int, whereas the variable was uint8_t, leading to a possible overflow issue.

To fix this, the variable for private session size is now changed to unsigned int to match the function return type.

Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
Fixes 1f1e4b7cbaad ("cryptodev: use single mempool for asymmetric

session")

---

Applied to dpdk-next-crypto

Thanks.