From: luca.boccassi@gmail.com
To: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
Cc: Brian Dooley <brian.dooley@intel.com>, dpdk stable <stable@dpdk.org>
Subject: patch 'crypto/qat: fix out-of-place header bytes in AEAD raw API' has been queued to stable release 22.11.9
Date: Thu, 12 Jun 2025 22:06:34 +0100 [thread overview]
Message-ID: <20250612210733.2506558-17-luca.boccassi@gmail.com> (raw)
In-Reply-To: <20250612210733.2506558-1-luca.boccassi@gmail.com>
Hi,
FYI, your patch has been queued to stable release 22.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 06/14/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/bluca/dpdk-stable
This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/ba810fcd7b21623f285ec3d519e89b8c74b8ecac
Thanks.
Luca Boccassi
---
From ba810fcd7b21623f285ec3d519e89b8c74b8ecac Mon Sep 17 00:00:00 2001
From: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
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 <arkadiuszx.kusztal@intel.com>
Acked-by: Brian Dooley <brian.dooley@intel.com>
---
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 266ab74a01..739649e793 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
@@ -6,9 +6,12 @@
#define _QAT_CRYPTO_PMD_GENS_H_
#include <rte_cryptodev.h>
+#include <rte_common.h>
+#include <rte_branch_prediction.h>
#include "qat_crypto.h"
#include "qat_sym_session.h"
#include "qat_sym.h"
+#include "icp_qat_fw_la.h"
#define QAT_SYM_DP_GET_MAX_ENQ(q, c, n) \
RTE_MIN((q->max_inflights - q->enqueued + q->dequeued - c), n)
@@ -127,6 +130,137 @@ qat_cipher_is_len_in_bits(struct qat_sym_session *ctx,
return 0;
}
+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,
void *opaque, struct qat_sym_op_cookie *cookie,
diff --git a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
index 888dea4ad9..d4eabc009a 100644
--- a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
+++ b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
@@ -915,16 +915,19 @@ qat_sym_dp_enqueue_aead_jobs_gen1(void *qp_data, uint8_t *drv_ctx,
for (i = 0; i < n; i++) {
struct qat_sym_op_cookie *cookie =
qp->op_cookies[tail >> tx_queue->trailz];
+ int error = 0;
req = (struct icp_qat_fw_la_bulk_req *)(
(uint8_t *)tx_queue->base_addr + tail);
rte_mov128((uint8_t *)req, (const uint8_t *)&(ctx->fw_req));
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,
user_data[i], cookie,
@@ -932,7 +935,7 @@ qat_sym_dp_enqueue_aead_jobs_gen1(void *qp_data, uint8_t *drv_ctx,
vec->src_sgl[i].num, NULL, 0);
}
- if (unlikely(data_len < 0))
+ if (unlikely(data_len < 0) || error)
break;
enqueue_one_aead_job_gen1(ctx, req, &vec->iv[i],
--
2.47.2
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2025-06-12 22:06:24.525349590 +0100
+++ 0017-crypto-qat-fix-out-of-place-header-bytes-in-AEAD-raw.patch 2025-06-12 22:06:23.806043286 +0100
@@ -1 +1 @@
-From 06597aaac85638eaa92b66f341185cd0ba39aca6 Mon Sep 17 00:00:00 2001
+From ba810fcd7b21623f285ec3d519e89b8c74b8ecac Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 06597aaac85638eaa92b66f341185cd0ba39aca6 ]
+
@@ -10 +11,0 @@
-Cc: stable@dpdk.org
@@ -20 +21 @@
-index 35c1888082..c447f2cb45 100644
+index 266ab74a01..739649e793 100644
@@ -34,3 +35,3 @@
- #define AES_OR_3DES_MISALIGNED (ctx->qat_mode == ICP_QAT_HW_CIPHER_CBC_MODE && \
- ((((ctx->qat_cipher_alg == ICP_QAT_HW_CIPHER_ALGO_AES128) || \
-@@ -146,6 +149,137 @@ qat_cipher_is_len_in_bits(struct qat_sym_session *ctx,
+ #define QAT_SYM_DP_GET_MAX_ENQ(q, c, n) \
+ RTE_MIN((q->max_inflights - q->enqueued + q->dequeued - c), n)
+@@ -127,6 +130,137 @@ qat_cipher_is_len_in_bits(struct qat_sym_session *ctx,
@@ -175 +176 @@
-index 24e51a9318..3976d03179 100644
+index 888dea4ad9..d4eabc009a 100644
@@ -178 +179 @@
-@@ -942,16 +942,19 @@ qat_sym_dp_enqueue_aead_jobs_gen1(void *qp_data, uint8_t *drv_ctx,
+@@ -915,16 +915,19 @@ qat_sym_dp_enqueue_aead_jobs_gen1(void *qp_data, uint8_t *drv_ctx,
@@ -202 +203 @@
-@@ -959,7 +962,7 @@ qat_sym_dp_enqueue_aead_jobs_gen1(void *qp_data, uint8_t *drv_ctx,
+@@ -932,7 +935,7 @@ qat_sym_dp_enqueue_aead_jobs_gen1(void *qp_data, uint8_t *drv_ctx,
next prev parent reply other threads:[~2025-06-12 21:08 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 21:06 patch 'net/i40e/base: remove unused variables' " luca.boccassi
2025-06-12 21:06 ` patch 'ci: bump tested distributions in GHA' " luca.boccassi
2025-06-12 21:06 ` patch 'net/fm10k/base: fix compilation warnings' " luca.boccassi
2025-06-12 21:06 ` patch 'net/ixgbe/base: correct definition of endianness macro' " luca.boccassi
2025-06-12 21:06 ` patch 'net/ixgbe/base: fix compilation warnings' " luca.boccassi
2025-06-12 21:06 ` patch 'net/i40e/base: fix unused value " luca.boccassi
2025-06-12 21:06 ` patch 'net/i40e/base: fix compiler " luca.boccassi
2025-06-12 21:06 ` patch 'acl: fix build with GCC 15 on aarch64' " luca.boccassi
2025-06-12 21:06 ` patch 'eal/linux: improve ASLR check' " luca.boccassi
2025-06-12 21:06 ` patch 'net/e1000: fix xstats name' " luca.boccassi
2025-06-12 21:06 ` patch 'net/e1000: fix EEPROM dump' " luca.boccassi
2025-06-12 21:06 ` patch 'net/ixgbe: fix port mask default value in filter' " luca.boccassi
2025-06-12 21:06 ` patch 'net/e1000: fix igb Tx queue offloads capability' " luca.boccassi
2025-06-12 21:06 ` patch 'vhost/crypto: fix cipher data length' " luca.boccassi
2025-06-12 21:06 ` patch 'crypto/virtio: fix cipher data source " luca.boccassi
2025-06-12 21:06 ` patch 'app/crypto-perf: fix AAD offset alignment' " luca.boccassi
2025-06-12 21:06 ` luca.boccassi [this message]
2025-06-12 21:06 ` patch 'crypto/qat: fix out-of-place chain/cipher/auth headers' " luca.boccassi
2025-06-12 21:06 ` patch 'net/mlx5: fix header modify action on group 0' " luca.boccassi
2025-06-12 21:06 ` patch 'net/mlx5: validate GTP PSC QFI width' " luca.boccassi
2025-06-12 21:06 ` patch 'net/mlx5: fix counter service cleanup on init failure' " luca.boccassi
2025-06-12 21:06 ` patch 'net/mlx5: remove unsupported flow meter action in HWS' " luca.boccassi
2025-06-12 21:06 ` patch 'net/mlx5: fix maximal queue size query' " luca.boccassi
2025-06-12 21:06 ` patch 'net/mlx5: align PF and VF/SF MAC address handling' " luca.boccassi
2025-06-12 21:06 ` patch 'app/testpmd: fix RSS hash key update' " luca.boccassi
2025-06-12 21:06 ` patch 'net/af_xdp: fix use after free in zero-copy Tx' " luca.boccassi
2025-06-12 21:06 ` patch 'net/hns3: fix integer overflow in interrupt unmap' " luca.boccassi
2025-06-12 21:06 ` patch 'net/hns3: fix memory leak on failure' " luca.boccassi
2025-06-12 21:06 ` patch 'net/hns3: fix extra wait for link up' " luca.boccassi
2025-06-12 21:06 ` patch 'net/hns3: fix memory leak for indirect flow action' " luca.boccassi
2025-06-12 21:06 ` patch 'net/hns3: fix interrupt rollback' " luca.boccassi
2025-06-12 21:06 ` patch 'net/hns3: fix divide by zero' " luca.boccassi
2025-06-12 21:06 ` patch 'net/hns3: fix resources release on reset' " luca.boccassi
2025-06-12 21:06 ` patch 'net/qede: fix use after free' " luca.boccassi
2025-06-12 21:06 ` patch 'bus/fslmc: " luca.boccassi
2025-06-12 21:06 ` patch 'net/null: fix packet copy' " luca.boccassi
2025-06-12 21:06 ` patch 'bus/vmbus: align ring buffer data to page boundary' " luca.boccassi
2025-06-12 21:06 ` patch 'bus/vmbus: use Hyper-V page size' " luca.boccassi
2025-06-12 21:06 ` patch 'net/netvsc: " luca.boccassi
2025-06-12 21:06 ` patch 'net/netvsc: add stats counters from VF' " luca.boccassi
2025-06-12 21:06 ` patch 'app/testpmd: relax number of TCs in DCB command' " luca.boccassi
2025-06-12 21:06 ` patch 'net/mana: check vendor ID when probing RDMA device' " luca.boccassi
2025-06-12 21:07 ` patch 'net/hns3: fix CRC data segment' " luca.boccassi
2025-06-12 21:07 ` patch 'net/tap: fix qdisc add failure handling' " luca.boccassi
2025-06-12 21:07 ` patch 'net/mlx5: fix VLAN stripping on hairpin queue' " luca.boccassi
2025-06-12 21:07 ` patch 'mem: fix lockup on address space shortage' " luca.boccassi
2025-06-12 21:07 ` patch 'test/malloc: improve resiliency' " luca.boccassi
2025-06-12 21:07 ` patch 'trace: fix overflow in per-lcore trace buffer' " luca.boccassi
2025-06-12 21:07 ` patch 'common/cnxk: fix E-tag pattern parsing' " luca.boccassi
2025-06-12 21:07 ` patch 'common/cnxk: fix CQ tail drop' " luca.boccassi
2025-06-12 21:07 ` patch 'net/cnxk: fix descriptor count update on reconfig' " luca.boccassi
2025-06-12 21:07 ` patch 'ethdev: fix error struct in flow configure' " luca.boccassi
2025-06-12 21:07 ` patch 'net/ice/base: fix integer overflow' " luca.boccassi
2025-06-12 21:07 ` patch 'net/ice/base: fix typo in device ID description' " luca.boccassi
2025-06-12 21:07 ` patch 'common/dpaax: fix PDCP key command race condition' " luca.boccassi
2025-06-12 21:07 ` patch 'common/dpaax: fix PDCP AES only 12-bit SN' " luca.boccassi
2025-06-12 21:07 ` patch 'crypto/virtio: add request check on request side' " luca.boccassi
2025-06-12 21:07 ` patch 'crypto/virtio: fix driver cleanup' " luca.boccassi
2025-06-12 21:07 ` patch 'ethdev: keep promiscuous/allmulti value before disabling' " luca.boccassi
2025-06-12 21:07 ` patch 'eal: fix return value of lcore role' " luca.boccassi
2025-06-12 21:07 ` patch 'eal: warn if no lcore is available' " luca.boccassi
2025-06-12 21:07 ` patch 'bus: cleanup device lists' " luca.boccassi
2025-06-12 21:07 ` patch 'eal/linux: unregister alarm callback before free' " luca.boccassi
2025-06-12 21:07 ` patch 'eal/freebsd: " luca.boccassi
2025-06-12 21:07 ` patch 'bus/pci/bsd: fix device existence check' " luca.boccassi
2025-06-12 21:07 ` patch 'power/intel_uncore: fix crash closing uninitialized driver' " luca.boccassi
2025-06-12 21:07 ` patch 'pcapng: fix null dereference in close' " luca.boccassi
2025-06-12 21:07 ` patch 'net/mlx5: avoid setting kernel MTU if not needed' " luca.boccassi
2025-06-12 21:07 ` patch 'net/mlx5: fix hypervisor detection in VLAN workaround' " luca.boccassi
2025-06-12 21:07 ` patch 'net/hns3: check requirement for hardware GRO' " luca.boccassi
2025-06-12 21:07 ` patch 'net/hns3: allow Tx vector when fast free not enabled' " luca.boccassi
2025-06-12 21:07 ` patch 'net/hns3: allow Rx vector mode with VLAN filter' " luca.boccassi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250612210733.2506558-17-luca.boccassi@gmail.com \
--to=luca.boccassi@gmail.com \
--cc=arkadiuszx.kusztal@intel.com \
--cc=brian.dooley@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).