[dpdk-stable] patch 'crypto/qat: fix uncleared cookies after operation' has been queued to stable release 20.11.4

Xueming Li xuemingl at nvidia.com
Wed Nov 10 07:31:54 CET 2021


Hi,

FYI, your patch has been queued to stable release 20.11.4

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/12/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/7982968fd4ffb1a32ca4e90a8f7c8fc10226a930

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 7982968fd4ffb1a32ca4e90a8f7c8fc10226a930 Mon Sep 17 00:00:00 2001
From: Arek Kusztal <arkadiuszx.kusztal at intel.com>
Date: Thu, 21 Oct 2021 11:06:01 +0100
Subject: [PATCH] crypto/qat: fix uncleared cookies after operation
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 867ba300f915291629c33b2eadf6a98564c622a0 ]

This commit fixes uncleared cookies issue when using
RSA algorithm.

Fixes: e2c5f4ea994c ("crypto/qat: support RSA in asym")

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal at intel.com>
Acked-by: Fan Zhang <roy.fan.zhang at intel.com>
---
 drivers/crypto/qat/qat_asym.c | 41 +++++++++++++++++++++++++----------
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index 983c639d68..f893508030 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -65,27 +65,45 @@ static size_t max_of(int n, ...)
 }
 
 static void qat_clear_arrays(struct qat_asym_op_cookie *cookie,
-		int in_count, int out_count, int in_size, int out_size)
+		int in_count, int out_count, int alg_size)
 {
 	int i;
 
 	for (i = 0; i < in_count; i++)
-		memset(cookie->input_array[i], 0x0, in_size);
+		memset(cookie->input_array[i], 0x0, alg_size);
 	for (i = 0; i < out_count; i++)
-		memset(cookie->output_array[i], 0x0, out_size);
+		memset(cookie->output_array[i], 0x0, alg_size);
+}
+
+static void qat_clear_arrays_crt(struct qat_asym_op_cookie *cookie,
+		int alg_size)
+{
+	int i;
+
+	memset(cookie->input_array[0], 0x0, alg_size);
+	for (i = 1; i < QAT_ASYM_RSA_QT_NUM_IN_PARAMS; i++)
+		memset(cookie->input_array[i], 0x0, alg_size / 2);
+	for (i = 0; i < QAT_ASYM_RSA_NUM_OUT_PARAMS; i++)
+		memset(cookie->output_array[i], 0x0, alg_size);
 }
 
 static void qat_clear_arrays_by_alg(struct qat_asym_op_cookie *cookie,
-		enum rte_crypto_asym_xform_type alg, int in_size, int out_size)
+		struct rte_crypto_asym_xform *xform, int alg_size)
 {
-	if (alg == RTE_CRYPTO_ASYM_XFORM_MODEX)
+	if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX)
 		qat_clear_arrays(cookie, QAT_ASYM_MODEXP_NUM_IN_PARAMS,
-				QAT_ASYM_MODEXP_NUM_OUT_PARAMS, in_size,
-				out_size);
-	else if (alg == RTE_CRYPTO_ASYM_XFORM_MODINV)
+				QAT_ASYM_MODEXP_NUM_OUT_PARAMS, alg_size);
+	else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV)
 		qat_clear_arrays(cookie, QAT_ASYM_MODINV_NUM_IN_PARAMS,
-				QAT_ASYM_MODINV_NUM_OUT_PARAMS, in_size,
-				out_size);
+				QAT_ASYM_MODINV_NUM_OUT_PARAMS, alg_size);
+	else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) {
+		if (xform->rsa.key_type == RTE_RSA_KET_TYPE_QT)
+			qat_clear_arrays_crt(cookie, alg_size);
+		else {
+			qat_clear_arrays(cookie, QAT_ASYM_RSA_NUM_IN_PARAMS,
+				QAT_ASYM_RSA_NUM_OUT_PARAMS, alg_size);
+		}
+	}
 }
 
 static int qat_asym_check_nonzero(rte_crypto_param n)
@@ -657,8 +675,7 @@ static void qat_asym_collect_response(struct rte_crypto_op *rx_op,
 			}
 		}
 	}
-	qat_clear_arrays_by_alg(cookie, xform->xform_type, alg_size_in_bytes,
-			alg_size_in_bytes);
+	qat_clear_arrays_by_alg(cookie, xform, alg_size_in_bytes);
 }
 
 void
-- 
2.33.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-11-10 14:17:12.045415529 +0800
+++ 0230-crypto-qat-fix-uncleared-cookies-after-operation.patch	2021-11-10 14:17:02.060744536 +0800
@@ -1 +1 @@
-From 867ba300f915291629c33b2eadf6a98564c622a0 Mon Sep 17 00:00:00 2001
+From 7982968fd4ffb1a32ca4e90a8f7c8fc10226a930 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 867ba300f915291629c33b2eadf6a98564c622a0 ]
@@ -10 +12,0 @@
-Cc: stable at dpdk.org


More information about the stable mailing list