Skip to contentSkip to conversation

crypto/qat: fix reallocate OpenSSL version check

PATCH Superseded Brian Dooley 3 participants 5 messages Oct 31, 2022 – Nov 3, 2022 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto/qat: fix reallocate OpenSSL version check

Move the ossl_legacy_provider_unload() into the right place for secure protocol for QAT. Remove unnecessary unload from session destroy.

Fixes 52d59b92b06d ("crypto/qat: enable OpenSSL legacy provider in session")
---
 drivers/crypto/qat/qat_sym_session.c | 32 ++++++++++++++--------------
 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/crypto/qat/qat_sym_session.c +16 -16
index 71fa595031..6872531d67 100644
@@ -520,19 +520,19 @@ qat_sym_session_configure(struct rte_cryptodev *dev,
 	int ret;
 
 #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
-		OSSL_PROVIDER * legacy;
-		OSSL_PROVIDER *deflt;
+	OSSL_PROVIDER * legacy;
+	OSSL_PROVIDER *deflt;
 
-		/* Load Multiple providers into the default (NULL) library context */
-		legacy = OSSL_PROVIDER_load(NULL, "legacy");
-		if (legacy == NULL)
-			return -EINVAL;
+	/* Load Multiple providers into the default (NULL) library context */
+	legacy = OSSL_PROVIDER_load(NULL, "legacy");
+	if (legacy == NULL)
+		return -EINVAL;
 
-		deflt = OSSL_PROVIDER_load(NULL, "default");
-		if (deflt == NULL) {
-			OSSL_PROVIDER_unload(legacy);
-			return -EINVAL;
-		}
+	deflt = OSSL_PROVIDER_load(NULL, "default");
+	if (deflt == NULL) {
+		OSSL_PROVIDER_unload(legacy);
+		return -EINVAL;
+	}
 #endif
 	ret = qat_sym_session_set_parameters(dev, xform,
 			CRYPTODEV_GET_SYM_SESS_PRIV(sess),
@@ -545,8 +545,8 @@ qat_sym_session_configure(struct rte_cryptodev *dev,
 	}
 
 # if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
-		OSSL_PROVIDER_unload(legacy);
-		OSSL_PROVIDER_unload(deflt);
+	OSSL_PROVIDER_unload(legacy);
+	OSSL_PROVIDER_unload(deflt);
 # endif
 	return 0;
 }
@@ -2668,6 +2668,9 @@ qat_security_session_create(void *dev,
 		return ret;
 	}
 
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+	ossl_legacy_provider_unload();
+#endif
 	return 0;
 }
 
@@ -2684,9 +2687,6 @@ qat_security_session_destroy(void *dev __rte_unused,
 		memset(s, 0, qat_sym_session_get_private_size(dev));
 	}
 
-# if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
-	ossl_legacy_provider_unload();
-# endif
 	return 0;
 }
 
Signature · 1 line
2.25.1
#1 lore raw

Please see my comments below, In addition, in qat_sym_session.c l.2642

return qat_sym_gen_dev_ops[qat_dev_gen].set_session((void *)cdev, session);

the session pointer should cast to (void *) or we can pass session_private directly.

Regards

Kai

Quoted 45 lines

-----Original Message-----
From: Dooley, Brian <[email protected]>
Sent: Monday, October 31, 2022 5:49 PM
To: Ji, Kai <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Coyle, David <[email protected]>; O'Sullivan, Kevin <[email protected]>; Dooley, Brian <[email protected]>
Subject: [PATCH v1] crypto/qat: fix reallocate OpenSSL version check

Move the ossl_legacy_provider_unload() into the right place for secure protocol for QAT. Remove unnecessary unload from session destroy.

Fixes 52d59b92b06d ("crypto/qat: enable OpenSSL legacy provider in session")
---
 drivers/crypto/qat/qat_sym_session.c | 32 ++++++++++++++--------------
 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/crypto/qat/qat_sym_session.c +2 -3
index 71fa595031..6872531d67 100644
@@ -520,19 +520,19 @@ qat_sym_session_configure(struct rte_cryptodev
 *dev,
 	int ret;
 
 #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
-		OSSL_PROVIDER * legacy;
-		OSSL_PROVIDER *deflt;
+	OSSL_PROVIDER * legacy;
+	OSSL_PROVIDER *deflt;
 
-		/* Load Multiple providers into the default (NULL) library

context */

drivers/crypto/qat/qat_sym_session.c +4 -3
-		legacy = OSSL_PROVIDER_load(NULL, "legacy");
-		if (legacy == NULL)
-			return -EINVAL;
+	/* Load Multiple providers into the default (NULL) library context */
+	legacy = OSSL_PROVIDER_load(NULL, "legacy");
+	if (legacy == NULL)
+		return -EINVAL;
 

drivers/crypto/qat/qat_sym_session.c qat_sym_session_configure(struct rte_cryptodev *dev, · line 535

Quoted 10 lines
drivers/crypto/qat/qat_sym_session.c +5 -5
-		deflt = OSSL_PROVIDER_load(NULL, "default");
-		if (deflt == NULL) {
-			OSSL_PROVIDER_unload(legacy);
-			return -EINVAL;
-		}
+	deflt = OSSL_PROVIDER_load(NULL, "default");
+	if (deflt == NULL) {
+		OSSL_PROVIDER_unload(legacy);
+		return -EINVAL;
+	}

[KJ] please use ossl_legacy_provider_load() helper instead load legacy and default libs manually here.

drivers/crypto/qat/qat_sym_session.c qat_sym_session_configure(struct rte_cryptodev *dev, · line 549

Quoted 11 lines

#endif

drivers/crypto/qat/qat_sym_session.c +2 -2
 	ret = qat_sym_session_set_parameters(dev, xform,
 			CRYPTODEV_GET_SYM_SESS_PRIV(sess),
@@ -545,8 +545,8 @@ qat_sym_session_configure(struct rte_cryptodev *dev,
 	}
 
 # if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
-		OSSL_PROVIDER_unload(legacy);
-		OSSL_PROVIDER_unload(deflt);
+	OSSL_PROVIDER_unload(legacy);
+	OSSL_PROVIDER_unload(deflt);

[KJ] you can use ossl_legacy_provider_unload() here

Quoted 26 lines
drivers/crypto/qat/qat_sym_session.c +3 -4
 # endif
 	return 0;
 }
@@ -2668,6 +2668,9 @@ qat_security_session_create(void *dev,
 		return ret;
 	}
 
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+	ossl_legacy_provider_unload();
+#endif
 	return 0;
 }
 
@@ -2684,9 +2687,6 @@ qat_security_session_destroy(void *dev
 __rte_unused,
 		memset(s, 0, qat_sym_session_get_private_size(dev));
 	}
 
-# if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
-	ossl_legacy_provider_unload();
-# endif
 	return 0;
 }
 
--

2.25.1

#2 lore raw

PATCH v2 1/1 crypto/qat: fix reallocate OpenSSL version check

In reply to Brian Dooley

Move the ossl_legacy_provider_unload() into the right place for secure protocol for QAT. Remove unnecessary unload from session destroy.

Fixes 52d59b92b06d ("crypto/qat: enable OpenSSL legacy provider in session")

---
v2:
- Use ossl legacy provider helper functions
- Cast session pointer to void

---
 drivers/crypto/qat/qat_sym_session.c | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/crypto/qat/qat_sym_session.c +7 -19
index 71fa595031..0ebc66f89e 100644
@@ -520,19 +520,7 @@ qat_sym_session_configure(struct rte_cryptodev *dev,
 	int ret;
 
 #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
-		OSSL_PROVIDER * legacy;
-		OSSL_PROVIDER *deflt;
-
-		/* Load Multiple providers into the default (NULL) library context */
-		legacy = OSSL_PROVIDER_load(NULL, "legacy");
-		if (legacy == NULL)
-			return -EINVAL;
-
-		deflt = OSSL_PROVIDER_load(NULL, "default");
-		if (deflt == NULL) {
-			OSSL_PROVIDER_unload(legacy);
-			return -EINVAL;
-		}
+	ossl_legacy_provider_load();
 #endif
 	ret = qat_sym_session_set_parameters(dev, xform,
 			CRYPTODEV_GET_SYM_SESS_PRIV(sess),
@@ -545,8 +533,7 @@ qat_sym_session_configure(struct rte_cryptodev *dev,
 	}
 
 # if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
-		OSSL_PROVIDER_unload(legacy);
-		OSSL_PROVIDER_unload(deflt);
+	ossl_legacy_provider_unload();
 # endif
 	return 0;
 }
@@ -2639,7 +2626,8 @@ qat_sec_session_set_docsis_parameters(struct rte_cryptodev *dev,
 		return ret;
 	qat_sym_session_finalize(session);
 
-	return qat_sym_gen_dev_ops[qat_dev_gen].set_session((void *)cdev, session);
+	return qat_sym_gen_dev_ops[qat_dev_gen].set_session((void *)cdev,
+			(void *)session);
 }
 
 int
@@ -2668,6 +2656,9 @@ qat_security_session_create(void *dev,
 		return ret;
 	}
 
+#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
+	ossl_legacy_provider_unload();
+#endif
 	return 0;
 }
 
@@ -2684,9 +2675,6 @@ qat_security_session_destroy(void *dev __rte_unused,
 		memset(s, 0, qat_sym_session_get_private_size(dev));
 	}
 
-# if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
-	ossl_legacy_provider_unload();
-# endif
 	return 0;
 }
 
Signature · 1 line
2.25.1
Acked-by on v2 1/1
#3 lore raw
Quoted 21 lines

-----Original Message-----
From: Dooley, Brian <[email protected]>
Sent: Wednesday, November 2, 2022 9:54 AM
To: Ji, Kai <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Coyle, David <[email protected]>; O'Sullivan, Kevin <[email protected]>; Dooley, Brian <[email protected]>
Subject: [PATCH v2] crypto/qat: fix reallocate OpenSSL version check

Move the ossl_legacy_provider_unload() into the right place for secure protocol for QAT. Remove unnecessary unload from session destroy.

Fixes 52d59b92b06d ("crypto/qat: enable OpenSSL legacy provider in session")

---
v2:
- Use ossl legacy provider helper functions
- Cast session pointer to void
---

Applied
#4 lore raw
Quoted 13 lines
Quoted 3 lines

Subject: [PATCH v2] crypto/qat: fix reallocate OpenSSL version check

Move the ossl_legacy_provider_unload() into the right place for secure

protocol

Quoted 7 lines

for QAT. Remove unnecessary unload from session destroy.

Fixes 52d59b92b06d ("crypto/qat: enable OpenSSL legacy provider in session")

---

Applied to dpdk-next-crypto

Thanks.