From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A71F145C9B for ; Tue, 12 Nov 2024 23:08:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A279940689; Tue, 12 Nov 2024 23:08:26 +0100 (CET) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mails.dpdk.org (Postfix) with ESMTP id 3C7654021E for ; Tue, 12 Nov 2024 23:08:25 +0100 (CET) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4316e9f4a40so53919385e9.2 for ; Tue, 12 Nov 2024 14:08:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731449305; x=1732054105; 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=ghhDA7EYVWUUJYsLrD45mcN+xQpsvOjJHmcdcVo4bZ0=; b=G3N1eBWdO0GFqdq6UiYqXzF+YFM5ROYs+sHx1cPSsYERiQHfU3vIDB8vFNNa+UdyjW XfqhtTx7/qyhsHHuG1w3mPTifds91FPMlJl1+gpIcJoai/7M2nGBQNoOVhBUxPpncUkX FGLEInSg9P6ryh0+pihAxg1xvZSN/g4JW0sKwAvh6u75SxakWeYuuS5NnimxDC9V7UvK 89y+MvZYtqqn/nbbfQKk8YG+NVmWadda0yd0ttriGevPlnsLcDkc8gH1NF/PA7QVECtj dE2vJ8UuVNrk8yEHUeQGMYPFYwsdlaWcg1rbR9gsWokcsoA07ty5+9930DGW5xAwNJPo L5ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731449305; x=1732054105; 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=ghhDA7EYVWUUJYsLrD45mcN+xQpsvOjJHmcdcVo4bZ0=; b=AoSHBiI6BYZ3rbUGDepcVoZkmsTefyCSNaTCRIV0Cn59/bjtdbD35wwlPFgX7Zh0+B GlvGXg1JiFSkZLR1h8zHBmDrVZrLAQvRBFYDG2iV3bNjl/tXTVUXqhJ8aTadJl7gT+UX 4c70HGsZBoxdIr2bm8jKGgVRrOOZ11W4G5RL60jIUww31QBBmo41reV1PuDyHQlhmM9V KF3MOJ1n4Hjlz2uBl9XXnadNcCHrLiHbfEnoew8GjGlaGYmeQQJaua0k4sW7XDGX56ET thmFrIp2SPgR3bmsUiFDS5qv2HKCR+nYu9LVQgHWtgDc006Epe9bgrG+c+Ix3sA/bwuQ nB7w== X-Forwarded-Encrypted: i=1; AJvYcCVSm9M6XME/gTQt5pmrIcJEFxiCLt90bRWwTvxBh4/0xWAuxJpsThMYUhaPRlKwYbFuPilrljw=@dpdk.org X-Gm-Message-State: AOJu0YwzUOHSv6Q3/Nd8XpRFyHAhyfHIPfeOIKoxe/2aOJooPPP6JefJ VXGeRYplalutTFfq/leBo5QfhAOtueGwyufRJKqp4aYfxpepGpwQ34eqFQ== X-Google-Smtp-Source: AGHT+IFhhhcN4LHYWksu0MVrUPAH+GggLoELxhF0RBZk+TlcYsLFR0ttVYw5m4aLvZrp+XLQI69VBA== X-Received: by 2002:a05:600c:1c12:b0:431:5d4f:73a3 with SMTP id 5b1f17b1804b1-432b750606cmr165925815e9.18.1731449304727; Tue, 12 Nov 2024 14:08:24 -0800 (PST) Received: from localhost ([2a01:4b00:d036:ae00:e89d:e9a1:da72:2f9d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432d54f76b9sm982205e9.14.2024.11.12.14.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 14:08:23 -0800 (PST) From: luca.boccassi@gmail.com To: David Marchand Cc: =?UTF-8?q?Morten=20Br=C3=B8rup?= , Hemant Agrawal , dpdk stable Subject: patch 'crypto/openssl: fix 3DES-CTR with big endian CPUs' has been queued to stable release 22.11.7 Date: Tue, 12 Nov 2024 22:07:18 +0000 Message-ID: <20241112220754.666489-8-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241112220754.666489-1-luca.boccassi@gmail.com> References: <20241023211704.1216956-79-luca.boccassi@gmail.com> <20241112220754.666489-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.7 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/14/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/15f924f62f25524d2a9d4682fefb3072e9e72b3b Thanks. Luca Boccassi --- >From 15f924f62f25524d2a9d4682fefb3072e9e72b3b Mon Sep 17 00:00:00 2001 From: David Marchand Date: Fri, 25 Oct 2024 09:04:21 +0200 Subject: [PATCH] crypto/openssl: fix 3DES-CTR with big endian CPUs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ upstream commit 97afd07ca79c7270480a65febd7f616a4c0b07ca ] Caught by code review. Don't byte swap unconditionally (assuming that CPU is little endian is wrong). Instead, convert from big endian to cpu and vice versa. Besides, avoid unaligned accesses and remove the ctr_inc helper that is not used anywhere else. Fixes: d61f70b4c918 ("crypto/libcrypto: add driver for OpenSSL library") Signed-off-by: David Marchand Acked-by: Morten Brørup Acked-by: Hemant Agrawal --- drivers/crypto/openssl/rte_openssl_pmd.c | 28 ++++++++---------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index 9fc8194366..0d4c84c18b 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -2,6 +2,7 @@ * Copyright(c) 2016-2017 Intel Corporation */ +#include #include #include #include @@ -98,22 +99,6 @@ digest_name_get(enum rte_crypto_auth_algorithm algo) static int cryptodev_openssl_remove(struct rte_vdev_device *vdev); -/*----------------------------------------------------------------------------*/ - -/** - * Increment counter by 1 - * Counter is 64 bit array, big-endian - */ -static void -ctr_inc(uint8_t *ctr) -{ - uint64_t *ctr64 = (uint64_t *)ctr; - - *ctr64 = __builtin_bswap64(*ctr64); - (*ctr64)++; - *ctr64 = __builtin_bswap64(*ctr64); -} - /* *------------------------------------------------------------------------------ * Session Prepare @@ -1191,7 +1176,8 @@ static int process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst, int offset, uint8_t *iv, int srclen, EVP_CIPHER_CTX *ctx) { - uint8_t ebuf[8], ctr[8]; + uint8_t ebuf[8]; + uint64_t ctr; int unused, n; struct rte_mbuf *m; uint8_t *src; @@ -1207,15 +1193,19 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst, src = rte_pktmbuf_mtod_offset(m, uint8_t *, offset); l = rte_pktmbuf_data_len(m) - offset; - memcpy(ctr, iv, 8); + memcpy(&ctr, iv, 8); for (n = 0; n < srclen; n++) { if (n % 8 == 0) { + uint64_t cpu_ctr; + if (EVP_EncryptUpdate(ctx, (unsigned char *)&ebuf, &unused, (const unsigned char *)&ctr, 8) <= 0) goto process_cipher_des3ctr_err; - ctr_inc(ctr); + cpu_ctr = rte_be_to_cpu_64(ctr); + cpu_ctr++; + ctr = rte_cpu_to_be_64(cpu_ctr); } dst[n] = *(src++) ^ ebuf[n % 8]; -- 2.45.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-11-12 22:06:58.954346712 +0000 +++ 0008-crypto-openssl-fix-3DES-CTR-with-big-endian-CPUs.patch 2024-11-12 22:06:58.639306763 +0000 @@ -1 +1 @@ -From 97afd07ca79c7270480a65febd7f616a4c0b07ca Mon Sep 17 00:00:00 2001 +From 15f924f62f25524d2a9d4682fefb3072e9e72b3b Mon Sep 17 00:00:00 2001 @@ -8,0 +9,2 @@ +[ upstream commit 97afd07ca79c7270480a65febd7f616a4c0b07ca ] + @@ -18 +19,0 @@ -Cc: stable@dpdk.org @@ -28 +29 @@ -index 9657b70c7a..0616383921 100644 +index 9fc8194366..0d4c84c18b 100644 @@ -39 +40 @@ -@@ -99,22 +100,6 @@ digest_name_get(enum rte_crypto_auth_algorithm algo) +@@ -98,22 +99,6 @@ digest_name_get(enum rte_crypto_auth_algorithm algo) @@ -62 +63 @@ -@@ -1192,7 +1177,8 @@ static int +@@ -1191,7 +1176,8 @@ static int @@ -72 +73 @@ -@@ -1208,15 +1194,19 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst, +@@ -1207,15 +1193,19 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst,