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 AF44646BAE for ; Fri, 18 Jul 2025 21:33:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A96DB40611; Fri, 18 Jul 2025 21:33:47 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 7132C40611 for ; Fri, 18 Jul 2025 21:33:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752867226; 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=hHKZFbCCIXP0SG36qXuaP6CdUW+Q/m/gxLbwId9v1aw=; b=X3PYjoEfKW42ZjklKeGiBlfupUAXcWBpuBiqXuwdbk+6KH++eeGZFrt/CbGYz2Zg3RKkie yKMdqsVjnpOxsmytKg4bd2VgQv21g2A6Sh92I3ODIJ8zf9mnmpoBrVHlGatTq0NHqWKvYC E3XVG135M8pNUjyEnMNgmqVmFUb7lUQ= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-90-J3pCsSqkPt6bOlQ3CFAwGw-1; Fri, 18 Jul 2025 15:33:42 -0400 X-MC-Unique: J3pCsSqkPt6bOlQ3CFAwGw-1 X-Mimecast-MFC-AGG-ID: J3pCsSqkPt6bOlQ3CFAwGw_1752867222 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EB6F31800371; Fri, 18 Jul 2025 19:33:41 +0000 (UTC) Received: from rh.redhat.com (unknown [10.44.32.40]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 672DB18003FC; Fri, 18 Jul 2025 19:33:40 +0000 (UTC) From: Kevin Traynor To: Arkadiusz Kusztal Cc: Brian Dooley , dpdk stable Subject: patch 'crypto/qat: fix out-of-place header bytes in AEAD raw API' has been queued to stable release 24.11.3 Date: Fri, 18 Jul 2025 20:29:16 +0100 Message-ID: <20250718193247.1008129-22-ktraynor@redhat.com> In-Reply-To: <20250718193247.1008129-1-ktraynor@redhat.com> References: <20250718193247.1008129-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ViqlK0aB7Owmzc3amWblk06jf_7VGT-nXu_5I8ZegE4_1752867222 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 24.11.3 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/23/25. 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/ba3728749bb319bd6dd54d144ed54d464d09fe5a Thanks. Kevin --- >From ba3728749bb319bd6dd54d144ed54d464d09fe5a Mon Sep 17 00:00:00 2001 From: Arkadiusz Kusztal Date: Thu, 20 Mar 2025 16:57:02 +0000 Subject: [PATCH] crypto/qat: fix out-of-place header bytes in AEAD raw API [ upstream commit 06597aaac85638eaa92b66f341185cd0ba39aca6 ] This commit fixes a problem with overwriting data in the OOP header in RAW API crypto processing when using AEAD algorithms. Fixes: 85fec6fd9674 ("crypto/qat: unify raw data path functions") Signed-off-by: Arkadiusz Kusztal Acked-by: Brian Dooley --- drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 134 +++++++++++++++++++ drivers/crypto/qat/dev/qat_sym_pmd_gen1.c | 13 +- 2 files changed, 142 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h index 35c1888082..c447f2cb45 100644 --- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h +++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h @@ -7,7 +7,10 @@ #include +#include +#include #include "qat_crypto.h" #include "qat_sym_session.h" #include "qat_sym.h" +#include "icp_qat_fw_la.h" #define AES_OR_3DES_MISALIGNED (ctx->qat_mode == ICP_QAT_HW_CIPHER_CBC_MODE && \ @@ -147,4 +150,135 @@ qat_cipher_is_len_in_bits(struct qat_sym_session *ctx, } +static inline +uint32_t qat_reqs_mid_set(int *error, struct icp_qat_fw_la_bulk_req *const req, + struct qat_sym_op_cookie *const cookie, const void *const opaque, + const struct rte_crypto_sgl *sgl_src, const struct rte_crypto_sgl *sgl_dst, + const union rte_crypto_sym_ofs ofs) +{ + uint32_t src_tot_length = 0; /* Returned value */ + uint32_t dst_tot_length = 0; /* Used only for input validity checks */ + uint32_t src_length = 0; + uint32_t dst_length = 0; + uint64_t src_data_addr = 0; + uint64_t dst_data_addr = 0; + const struct rte_crypto_vec * const vec_src = sgl_src->vec; + const struct rte_crypto_vec * const vec_dst = sgl_dst->vec; + const uint32_t n_src = sgl_src->num; + const uint32_t n_dst = sgl_dst->num; + const uint16_t offset = RTE_MAX(ofs.ofs.cipher.head, ofs.ofs.auth.head); + const uint8_t is_flat = !(n_src > 1 || n_dst > 1); /* Flat buffer or the SGL */ + const uint8_t is_in_place = !n_dst; /* In-place or out-of-place */ + + *error = 0; + if (unlikely((n_src < 1 || n_src > QAT_SYM_SGL_MAX_NUMBER) || + n_dst > QAT_SYM_SGL_MAX_NUMBER)) { + QAT_LOG(DEBUG, + "Invalid number of sgls, source no: %u, dst no: %u, opaque: %p", + n_src, n_dst, opaque); + *error = -1; + return 0; + } + + /* --- Flat buffer --- */ + if (is_flat) { + src_data_addr = vec_src->iova; + dst_data_addr = vec_src->iova; + src_length = vec_src->len; + dst_length = vec_src->len; + + if (is_in_place) + goto done; + /* Out-of-place + * If OOP, we need to keep in mind that offset needs to + * start where the aead starts + */ + dst_length = vec_dst->len; + /* Integer promotion here, but it does not bother this time */ + if (unlikely(offset > src_length || offset > dst_length)) { + QAT_LOG(DEBUG, + "Invalid size of the vector parameters, source length: %u, dst length: %u, opaque: %p", + src_length, dst_length, opaque); + *error = -1; + return 0; + } + src_data_addr += offset; + dst_data_addr = vec_dst->iova + offset; + src_length -= offset; + dst_length -= offset; + src_tot_length = src_length; + dst_tot_length = dst_length; + goto check; + } + + /* --- Scatter-gather list --- */ + struct qat_sgl * const qat_sgl_src = (struct qat_sgl *)&cookie->qat_sgl_src; + uint16_t i; + + ICP_QAT_FW_COMN_PTR_TYPE_SET(req->comn_hdr.comn_req_flags, + QAT_COMN_PTR_TYPE_SGL); + qat_sgl_src->num_bufs = n_src; + src_data_addr = cookie->qat_sgl_src_phys_addr; + /* Fill all the source buffers but the first one */ + for (i = 1; i < n_src; i++) { + qat_sgl_src->buffers[i].len = (vec_src + i)->len; + qat_sgl_src->buffers[i].addr = (vec_src + i)->iova; + src_tot_length += qat_sgl_src->buffers[i].len; + } + + if (is_in_place) { + /* SGL source first entry, no OOP */ + qat_sgl_src->buffers[0].len = vec_src->len; + qat_sgl_src->buffers[0].addr = vec_src->iova; + dst_data_addr = src_data_addr; + goto done; + } + /* Out-of-place */ + struct qat_sgl * const qat_sgl_dst = + (struct qat_sgl *)&cookie->qat_sgl_dst; + /* + * Offset reaching outside of the first buffer is not supported (RAW api). + * Integer promotion here, but it does not bother this time + */ + if (unlikely(offset > vec_src->len || offset > vec_dst->len)) { + QAT_LOG(DEBUG, + "Invalid size of the vector parameters, source length: %u, dst length: %u, opaque: %p", + vec_src->len, vec_dst->len, opaque); + *error = -1; + return 0; + } + /* SGL source first entry, adjusted to OOP offsets */ + qat_sgl_src->buffers[0].addr = vec_src->iova + offset; + qat_sgl_src->buffers[0].len = vec_src->len - offset; + /* SGL destination first entry, adjusted to OOP offsets */ + qat_sgl_dst->buffers[0].addr = vec_dst->iova + offset; + qat_sgl_dst->buffers[0].len = vec_dst->len - offset; + /* Fill the remaining destination buffers */ + for (i = 1; i < n_dst; i++) { + qat_sgl_dst->buffers[i].len = (vec_dst + i)->len; + qat_sgl_dst->buffers[i].addr = (vec_dst + i)->iova; + dst_tot_length += qat_sgl_dst->buffers[i].len; + } + dst_tot_length += qat_sgl_dst->buffers[0].len; + qat_sgl_dst->num_bufs = n_dst; + dst_data_addr = cookie->qat_sgl_dst_phys_addr; + +check: /* If error, return directly. If success, jump to one of these labels */ + if (src_tot_length != dst_tot_length) { + QAT_LOG(DEBUG, + "Source length is not equal to the destination length %u, dst no: %u, opaque: %p", + src_tot_length, dst_tot_length, opaque); + *error = -1; + return 0; + } +done: + req->comn_mid.opaque_data = (uintptr_t)opaque; + req->comn_mid.src_data_addr = src_data_addr; + req->comn_mid.dest_data_addr = dst_data_addr; + req->comn_mid.src_length = src_length; + req->comn_mid.dst_length = dst_length; + + return src_tot_length; +} + static __rte_always_inline int32_t qat_sym_build_req_set_data(struct icp_qat_fw_la_bulk_req *req, diff --git a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c index 24e51a9318..3976d03179 100644 --- a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c +++ b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c @@ -943,4 +943,5 @@ qat_sym_dp_enqueue_aead_jobs_gen1(void *qp_data, uint8_t *drv_ctx, struct qat_sym_op_cookie *cookie = qp->op_cookies[tail >> tx_queue->trailz]; + int error = 0; req = (struct icp_qat_fw_la_bulk_req *)( @@ -949,8 +950,10 @@ qat_sym_dp_enqueue_aead_jobs_gen1(void *qp_data, uint8_t *drv_ctx, if (vec->dest_sgl) { - data_len = qat_sym_build_req_set_data(req, - user_data[i], cookie, - vec->src_sgl[i].vec, vec->src_sgl[i].num, - vec->dest_sgl[i].vec, vec->dest_sgl[i].num); + data_len = qat_reqs_mid_set(&error, req, cookie, user_data[i], + &vec->src_sgl[i], &vec->dest_sgl[i], ofs); + /* In oop there is no offset, src/dst addresses are moved + * to avoid overwriting the dst header + */ + ofs.ofs.cipher.head = 0; } else { data_len = qat_sym_build_req_set_data(req, @@ -960,5 +963,5 @@ qat_sym_dp_enqueue_aead_jobs_gen1(void *qp_data, uint8_t *drv_ctx, } - if (unlikely(data_len < 0)) + if (unlikely(data_len < 0) || error) break; -- 2.50.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-07-18 20:29:11.856646251 +0100 +++ 0022-crypto-qat-fix-out-of-place-header-bytes-in-AEAD-raw.patch 2025-07-18 20:29:10.825907009 +0100 @@ -1 +1 @@ -From 06597aaac85638eaa92b66f341185cd0ba39aca6 Mon Sep 17 00:00:00 2001 +From ba3728749bb319bd6dd54d144ed54d464d09fe5a Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 06597aaac85638eaa92b66f341185cd0ba39aca6 ] + @@ -10 +11,0 @@ -Cc: stable@dpdk.org