From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id F23B1455AD
	for <public@inbox.dpdk.org>; Mon, 15 Jul 2024 17:27:47 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id ED3F340A73;
	Mon, 15 Jul 2024 17:27:47 +0200 (CEST)
Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com
 [209.85.167.51]) by mails.dpdk.org (Postfix) with ESMTP id 8F4C140A71
 for <stable@dpdk.org>; Mon, 15 Jul 2024 17:27:46 +0200 (CEST)
Received: by mail-lf1-f51.google.com with SMTP id
 2adb3069b0e04-52e94eaf5efso5297045e87.2
 for <stable@dpdk.org>; Mon, 15 Jul 2024 08:27:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1721057266; x=1721662066; darn=dpdk.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=3HW+Xx3uIiykuWSLVrz00iLYdkiuN0go7+tIIZKsQiA=;
 b=VuR8Tmk8bu4eoyPO3JwG0IurhDL+/oiTBvNHQSb1sIZTZeFLRxA+DgKArgZiMLHE1f
 qfQMzIx6tQtTngC2X9i0bw4irp6b3B1ZrOnBlH6S/NJPiJxn/A5dtFm9NojeLpQzUPm5
 GZYU7/S9XBZeuJ1OXLUAd3em6XlMyXN0fEeVpab1jGvOoTwRZeI/ySNY/Kgr+3t0d4NR
 f431/4bLG9sP7C2qDPdhKYYQLkQr83OlF7o/2DsoFQ2UDW3XjmZGpFIcUb2L/2hkSIjn
 hpQbS6xBVIrXkQB03G8KS2EITF6RDaXVRHwc2O1MVwcX4hPM/erPgygoXfkGJLNbrH2B
 m38A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1721057266; x=1721662066;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=3HW+Xx3uIiykuWSLVrz00iLYdkiuN0go7+tIIZKsQiA=;
 b=f+yzHFYvzsFNKcVfzTTxXGNSes0GFC6sLr6WzEALVXJbqTh3ZLyTRYR7eVaZUrylEw
 ysEYFccy4IU1jK73frPemGJhNmp968KmCzpQlYkgoZhtF/ZaAMjUwHwUcWrePF6Nuzt0
 b+sjvsTIci88UbpaVT9STQ4jKdM1Hsqr/yj6t1bsVI1jgA+pLjhXf9sLMlud5TA/ZIw1
 H8VlMPyyeLIcm2e7EdNQSMoam2zBOzeJtbqGHP8uDXIgRU9VV6PTnXE8of0n6OndGXNJ
 BiUXHX5bR13KVgh3a++WJEOoI5JRAPYg/XvW69Ef90iH1IVwfNCxqZvZOTtp5MZWTgJa
 ud6g==
X-Gm-Message-State: AOJu0Yzk0zUM3+nYg6uQITGJsQm22G/tUfXY/tKjPEHtJxqhuVaofqwO
 g3xbuvSsjC3bIE4lTXdPJZWz8cDp6KyA7Q/ubE3n/DXEQSW8lk2N5jiEA0sO
X-Google-Smtp-Source: AGHT+IG4wrzyO3AHE4B7OnbtEZueQA+jI0dSTE+YrPB/tPq1rEA8vJAxG0c6bEi+rqBaG5kNxUjOiA==
X-Received: by 2002:a05:6512:3ca0:b0:52e:be84:225c with SMTP id
 2adb3069b0e04-52ebe8423a0mr10134742e87.33.1721057265891; 
 Mon, 15 Jul 2024 08:27:45 -0700 (PDT)
Received: from localhost ([137.220.120.171]) by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-427a5edb540sm92078695e9.30.2024.07.15.08.27.45
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 15 Jul 2024 08:27:45 -0700 (PDT)
From: luca.boccassi@gmail.com
To: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Cc: dpdk stable <stable@dpdk.org>
Subject: patch 'crypto/cnxk: fix minimal input normalization' has been queued
 to stable release 22.11.6
Date: Mon, 15 Jul 2024 16:25:51 +0100
Message-Id: <20240715152704.2229503-13-luca.boccassi@gmail.com>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <20240715152704.2229503-1-luca.boccassi@gmail.com>
References: <20240624235907.885628-81-luca.boccassi@gmail.com>
 <20240715152704.2229503-1-luca.boccassi@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org

Hi,

FYI, your patch has been queued to stable release 22.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 07/17/24. 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/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/734137651508036d90198aa057d06b20186391f7

Thanks.

Luca Boccassi

---
>From 734137651508036d90198aa057d06b20186391f7 Mon Sep 17 00:00:00 2001
From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Date: Wed, 26 Jun 2024 15:48:18 +0530
Subject: [PATCH] crypto/cnxk: fix minimal input normalization

[ upstream commit 42ebfb0380cfc5e7c82555648b2ce064a9f4a3ad ]

Fix modex to nomalize input only when MSW is zero.

Fixes: 5a3513caeb45 ("crypto/cnxk: add asymmetric session")

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/crypto/cnxk/cnxk_ae.h | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index adf719da73..156bd2e94f 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -27,13 +27,22 @@ struct cnxk_ae_sess {
 };
 
 static __rte_always_inline void
-cnxk_ae_modex_param_normalize(uint8_t **data, size_t *len)
+cnxk_ae_modex_param_normalize(uint8_t **data, size_t *len, size_t max)
 {
+	uint8_t msw_len = *len % 8;
+	uint64_t msw_val = 0;
 	size_t i;
 
-	/* Strip leading NUL bytes */
-	for (i = 0; i < *len; i++) {
-		if ((*data)[i] != 0)
+	if (*len <= 8)
+		return;
+
+	memcpy(&msw_val, *data, msw_len);
+	if (msw_val != 0)
+		return;
+
+	for (i = msw_len; i < *len && (*len - i) < max; i += 8) {
+		memcpy(&msw_val, &(*data)[i], 8);
+		if (msw_val != 0)
 			break;
 	}
 	*data += i;
@@ -50,8 +59,8 @@ cnxk_ae_fill_modex_params(struct cnxk_ae_sess *sess,
 	uint8_t *exp = xform->modex.exponent.data;
 	uint8_t *mod = xform->modex.modulus.data;
 
-	cnxk_ae_modex_param_normalize(&mod, &mod_len);
-	cnxk_ae_modex_param_normalize(&exp, &exp_len);
+	cnxk_ae_modex_param_normalize(&mod, &mod_len, SIZE_MAX);
+	cnxk_ae_modex_param_normalize(&exp, &exp_len, mod_len);
 
 	if (unlikely(exp_len == 0 || mod_len == 0))
 		return -EINVAL;
@@ -240,7 +249,7 @@ cnxk_ae_modex_prep(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
 	struct rte_crypto_mod_op_param mod_op;
 	uint64_t total_key_len;
 	union cpt_inst_w4 w4;
-	uint32_t base_len;
+	size_t base_len;
 	uint32_t dlen;
 	uint8_t *dptr;
 
@@ -248,8 +257,11 @@ cnxk_ae_modex_prep(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
 
 	base_len = mod_op.base.length;
 	if (unlikely(base_len > mod_len)) {
-		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-		return -ENOTSUP;
+		cnxk_ae_modex_param_normalize(&mod_op.base.data, &base_len, mod_len);
+		if (base_len > mod_len) {
+			op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+			return -ENOTSUP;
+		}
 	}
 
 	total_key_len = mod_len + exp_len;
-- 
2.39.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-07-15 16:19:35.462262863 +0100
+++ 0013-crypto-cnxk-fix-minimal-input-normalization.patch	2024-07-15 16:19:34.452203987 +0100
@@ -1 +1 @@
-From 42ebfb0380cfc5e7c82555648b2ce064a9f4a3ad Mon Sep 17 00:00:00 2001
+From 734137651508036d90198aa057d06b20186391f7 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 42ebfb0380cfc5e7c82555648b2ce064a9f4a3ad ]
+
@@ -9 +10,0 @@
-Cc: stable@dpdk.org
@@ -17 +18 @@
-index a843d6b5ef..ef9cb5eb91 100644
+index adf719da73..156bd2e94f 100644
@@ -20 +21 @@
-@@ -49,13 +49,22 @@ struct cnxk_ae_sess {
+@@ -27,13 +27,22 @@ struct cnxk_ae_sess {
@@ -47 +48 @@
-@@ -72,8 +81,8 @@ cnxk_ae_fill_modex_params(struct cnxk_ae_sess *sess,
+@@ -50,8 +59,8 @@ cnxk_ae_fill_modex_params(struct cnxk_ae_sess *sess,
@@ -58 +59 @@
-@@ -288,7 +297,7 @@ cnxk_ae_modex_prep(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
+@@ -240,7 +249,7 @@ cnxk_ae_modex_prep(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
@@ -67 +68 @@
-@@ -296,8 +305,11 @@ cnxk_ae_modex_prep(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,
+@@ -248,8 +257,11 @@ cnxk_ae_modex_prep(struct rte_crypto_op *op, struct roc_ae_buf_ptr *meta_buf,