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 4E44B45DB9 for ; Wed, 27 Nov 2024 18:22:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B3EF406BB; Wed, 27 Nov 2024 18:22:15 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 4414740A6E for ; Wed, 27 Nov 2024 18:22:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732728133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZqYWQr5ufTxpySijDy8F/SS7K+K7MyQ0lx0iVKnhAAQ=; b=RT+L6J3+lm2UNgzXQofzjBir7gC7UaH+0h7YIffHlRiJlc3n4bIxwrFyPt4DPlJ3E307cV y39sz3ah5Z88p50ndlphtnF41Qnmd1pbXDdswiuZZ/THoUFNtu6bm2KSR3/tO+3aUB8lH5 KIxUzooMjl1DdsQht6805C/q3QkGKRM= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-597-pVktR4aONi6OSC7aDjsevQ-1; Wed, 27 Nov 2024 12:22:10 -0500 X-MC-Unique: pVktR4aONi6OSC7aDjsevQ-1 X-Mimecast-MFC-AGG-ID: pVktR4aONi6OSC7aDjsevQ Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AC7A819560B0; Wed, 27 Nov 2024 17:22:09 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.52]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 12BF13003B71; Wed, 27 Nov 2024 17:22:07 +0000 (UTC) From: Kevin Traynor 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 21.11.9 Date: Wed, 27 Nov 2024 17:18:22 +0000 Message-ID: <20241127171916.690404-75-ktraynor@redhat.com> In-Reply-To: <20241127171916.690404-1-ktraynor@redhat.com> References: <20241127171916.690404-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 4ynaqY9NI2d8JE6BMXjR96OxmiQKMYzyb7nA8ntsjXA_1732728129 X-Mimecast-Originator: redhat.com 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 21.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/02/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/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/9f3dc338f2f4e357e422431bc778992d94d60ace Thanks. Kevin --- >From 9f3dc338f2f4e357e422431bc778992d94d60ace 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 a321258980..a75fb094ee 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -5,4 +5,5 @@ #define OPENSSL_API_COMPAT 0x10100000L +#include #include #include @@ -44,20 +45,4 @@ static void HMAC_CTX_free(HMAC_CTX *ctx) 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); -} - /* *------------------------------------------------------------------------------ @@ -1013,5 +998,6 @@ 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; @@ -1029,13 +1015,17 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst, 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.47.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-11-27 17:17:40.617307151 +0000 +++ 0075-crypto-openssl-fix-3DES-CTR-with-big-endian-CPUs.patch 2024-11-27 17:17:38.273269622 +0000 @@ -1 +1 @@ -From 97afd07ca79c7270480a65febd7f616a4c0b07ca Mon Sep 17 00:00:00 2001 +From 9f3dc338f2f4e357e422431bc778992d94d60ace 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 a321258980..a75fb094ee 100644 @@ -31,2 +32,2 @@ -@@ -3,4 +3,5 @@ - */ +@@ -5,4 +5,5 @@ + #define OPENSSL_API_COMPAT 0x10100000L @@ -37 +38 @@ -@@ -100,20 +101,4 @@ digest_name_get(enum rte_crypto_auth_algorithm algo) +@@ -44,20 +45,4 @@ static void HMAC_CTX_free(HMAC_CTX *ctx) @@ -58 +59 @@ -@@ -1193,5 +1178,6 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst, +@@ -1013,5 +998,6 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst, @@ -66 +67 @@ -@@ -1209,13 +1195,17 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst, +@@ -1029,13 +1015,17 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst,