crypto/qat: fix secure session check

Message ID 20220701085707.246099-1-rebecca.troy@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series crypto/qat: fix secure session check |

Checks

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

Commit Message

Rebecca Troy July 1, 2022, 8:57 a.m. UTC
  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")
Cc: kai.ji@intel.com
Cc: stable@dpdk.org

Signed-off-by: Rebecca Troy <rebecca.troy@intel.com>
---
 drivers/crypto/qat/qat_sym.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
  

Comments

Akhil Goyal July 1, 2022, 6:31 p.m. UTC | #1
> 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")
> Cc: kai.ji@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Rebecca Troy <rebecca.troy@intel.com>
> ---
>  drivers/crypto/qat/qat_sym.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
> index 3477cd89ad..e5ae670b3a 100644
> --- a/drivers/crypto/qat/qat_sym.c
> +++ b/drivers/crypto/qat/qat_sym.c
> @@ -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;
>  			}
Fix formatting of above if check.

> +		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
  

Patch

diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
index 3477cd89ad..e5ae670b3a 100644
--- a/drivers/crypto/qat/qat_sym.c
+++ b/drivers/crypto/qat/qat_sym.c
@@ -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"