Skip to contentSkip to conversation

crypto/qat: fix secure session check

PATCH In review Rebecca Troy 3 participants 4 messages Jul 1, 2022 – Jul 5, 2022 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto/qat: fix secure session check

Currently when running the dpdk-perf-test with docsis security sessions, a segmentation fault occurs. This is due to the check being made that the session is not equal to op->sym->sec_session. This check passes the first time but on the second iteration fails and doesn't create the build_request.

This commit fixes that error by getting the ctx first from the private session data and then comparing ctx, rather than op->sym->sec_session, with the sess.

Fixes fb3b9f492205 ("crypto/qat: rework burst data path")
---
 drivers/crypto/qat/qat_sym.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/crypto/qat/qat_sym.c +5 -5
index 3477cd89ad..e5ae670b3a 100644
@@ -105,16 +105,16 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 
 #ifdef RTE_LIB_SECURITY
 	else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
-		if ((void *)sess != (void *)op->sym->sec_session) {
-			struct rte_cryptodev *cdev;
-			struct qat_cryptodev_private *internals;
-
-			ctx = get_sec_session_private_data(
+		ctx = get_sec_session_private_data(
 					op->sym->sec_session);
 			if (unlikely(!ctx)) {
 				QAT_DP_LOG(ERR, "No session for this device");
 				return -EINVAL;
 			}
+		if (sess != (uintptr_t)ctx) {
+			struct rte_cryptodev *cdev;
+			struct qat_cryptodev_private *internals;
+
 			if (unlikely(ctx->bpi_ctx == NULL)) {
 				QAT_DP_LOG(ERR, "QAT PMD only supports security"
 						" operation requests for"
Signature · 1 line
2.25.1
#1 lore raw
Quoted 31 lines

Currently when running the dpdk-perf-test with docsis security sessions, a segmentation fault occurs. This is due to the check being made that the session is not equal to op->sym->sec_session. This check passes the first time but on the second iteration fails and doesn't create the build_request.

This commit fixes that error by getting the ctx first from the private session data and then comparing ctx, rather than op->sym->sec_session, with the sess.

Fixes fb3b9f492205 ("crypto/qat: rework burst data path")
---
 drivers/crypto/qat/qat_sym.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/crypto/qat/qat_sym.c +0 -2
index 3477cd89ad..e5ae670b3a 100644
@@ -105,16 +105,16 @@ qat_sym_build_request(void *in_op, uint8_t
 *out_msg,
 
 #ifdef RTE_LIB_SECURITY
 	else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
-		if ((void *)sess != (void *)op->sym->sec_session) {
-			struct rte_cryptodev *cdev;

drivers/crypto/qat/qat_sym.c qat_sym_build_request(void *in_op, uint8_t · line 115

Quoted 10 lines
drivers/crypto/qat/qat_sym.c +1 -3
-			struct qat_cryptodev_private *internals;
-
-			ctx = get_sec_session_private_data(
+		ctx = get_sec_session_private_data(
 					op->sym->sec_session);
 			if (unlikely(!ctx)) {
 				QAT_DP_LOG(ERR, "No session for this
 device");
 				return -EINVAL;
 			}

Fix formatting of above if check.

Quoted 10 lines
drivers/crypto/qat/qat_sym.c +4 -0
+		if (sess != (uintptr_t)ctx) {
+			struct rte_cryptodev *cdev;
+			struct qat_cryptodev_private *internals;
+
 			if (unlikely(ctx->bpi_ctx == NULL)) {

QAT_DP_LOG(ERR, "QAT PMD only supports
security"
" operation requests for"
--
2.25.1

#2 lore raw

PATCH v2 1/1 crypto/qat: fix secure session check

In reply to Rebecca Troy

From: Rebecca Troy <[email protected]>

Currently when running the dpdk-perf-test with docsis security sessions, a segmentation fault occurs. This is due to the check being made that the session is not equal to op->sym->sec_session. This check passes the first time but on the second iteration fails and doesn't create the build_request.

This commit fixes that error by getting the ctx first from the private session data and then comparing ctx, rather than op->sym->sec_session, with the sess.

Fixes fb3b9f492205 ("crypto/qat: rework burst data path")
---
 drivers/crypto/qat/qat_sym.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/crypto/qat/qat_sym.c +6 -7
index 3477cd89ad..db6316fbe9 100644
@@ -105,16 +105,15 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 
 #ifdef RTE_LIB_SECURITY
 	else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
-		if ((void *)sess != (void *)op->sym->sec_session) {
+		ctx = get_sec_session_private_data(op->sym->sec_session);
+		if (unlikely(!ctx)) {
+			QAT_DP_LOG(ERR, "No session for this device");
+			return -EINVAL;
+		}
+		if (sess != (uintptr_t)ctx) {
 			struct rte_cryptodev *cdev;
 			struct qat_cryptodev_private *internals;
 
-			ctx = get_sec_session_private_data(
-					op->sym->sec_session);
-			if (unlikely(!ctx)) {
-				QAT_DP_LOG(ERR, "No session for this device");
-				return -EINVAL;
-			}
 			if (unlikely(ctx->bpi_ctx == NULL)) {
 				QAT_DP_LOG(ERR, "QAT PMD only supports security"
 						" operation requests for"
Signature · 1 line
2.17.1
Applied
#3 lore raw
Quoted 14 lines

----------------------------------------------------------------------
From: Rebecca Troy <[email protected]>

Currently when running the dpdk-perf-test with docsis security sessions, a segmentation fault occurs. This is due to the check being made that the session is not equal to op->sym->sec_session. This check passes the first time but on the second iteration fails and doesn't create the build_request.

This commit fixes that error by getting the ctx first from the private session data and then comparing ctx, rather than op->sym->sec_session, with the sess.

Quoted 5 lines
Fixes fb3b9f492205 ("crypto/qat: rework burst data path")

Applied to dpdk-next-crypto
Thanks.