[2/2] crypto/virtio: fix cipher data src length

Message ID 20250403122603.3508135-1-rmudimadugul@marvell.com (mailing list archive)
State New
Delegated to: Maxime Coquelin
Headers
Series [1/2] vhost: fix cipher data length |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-mellanox-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS

Commit Message

Rajesh Mudimadugula April 3, 2025, 12:26 p.m. UTC
In symmetric algorithm chaining, we need to consider both
cipher and auth data length for cipher source.

Fixes: 82adb12a1fce ("crypto/virtio: support burst enqueue/dequeue")

Signed-off-by: Rajesh Mudimadugula <rmudimadugul@marvell.com>
---
 drivers/crypto/virtio/virtio_rxtx.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
  

Comments

Akhil Goyal April 10, 2025, 5:14 a.m. UTC | #1
> In symmetric algorithm chaining, we need to consider both
> cipher and auth data length for cipher source.
> 
> Fixes: 82adb12a1fce ("crypto/virtio: support burst enqueue/dequeue")
Cc: stable@dpdk.org

> 
> Signed-off-by: Rajesh Mudimadugula <rmudimadugul@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
  

Patch

diff --git a/drivers/crypto/virtio/virtio_rxtx.c b/drivers/crypto/virtio/virtio_rxtx.c
index 0cc904485c..a7f1bd9753 100644
--- a/drivers/crypto/virtio/virtio_rxtx.c
+++ b/drivers/crypto/virtio/virtio_rxtx.c
@@ -243,8 +243,10 @@  virtqueue_crypto_sym_pkt_header_arrange(
 		req_data->u.sym_req.u.chain.para.aad_len = session->aad.length;
 
 		req_data->u.sym_req.u.chain.para.src_data_len =
-			(sym_op->cipher.data.length +
-				sym_op->cipher.data.offset);
+			RTE_MAX((sym_op->cipher.data.length +
+				 sym_op->cipher.data.offset),
+				(sym_op->auth.data.length +
+				 sym_op->auth.data.offset));
 		req_data->u.sym_req.u.chain.para.dst_data_len =
 			req_data->u.sym_req.u.chain.para.src_data_len;
 		req_data->u.sym_req.u.chain.para.cipher_start_src_offset =
@@ -298,6 +300,7 @@  virtqueue_crypto_sym_enqueue_xmit_split(
 	uint32_t hash_result_len = 0;
 	struct virtio_crypto_op_cookie *crypto_op_cookie;
 	struct virtio_crypto_alg_chain_session_para *para;
+	uint32_t src_len;
 
 	if (unlikely(sym_op->m_src->nb_segs != 1))
 		return -EMSGSIZE;
@@ -371,21 +374,22 @@  virtqueue_crypto_sym_enqueue_xmit_split(
 		desc[idx++].flags = VRING_DESC_F_NEXT;
 	}
 
+	src_len = RTE_MAX((sym_op->cipher.data.offset +
+			   sym_op->cipher.data.length),
+			  (sym_op->auth.data.length +
+			   sym_op->auth.data.offset));
 	/* indirect vring: src data */
 	desc[idx].addr = rte_pktmbuf_iova_offset(sym_op->m_src, 0);
-	desc[idx].len = (sym_op->cipher.data.offset
-		+ sym_op->cipher.data.length);
+	desc[idx].len = src_len;
 	desc[idx++].flags = VRING_DESC_F_NEXT;
 
 	/* indirect vring: dst data */
 	if (sym_op->m_dst) {
 		desc[idx].addr = rte_pktmbuf_iova_offset(sym_op->m_dst, 0);
-		desc[idx].len = (sym_op->cipher.data.offset
-			+ sym_op->cipher.data.length);
+		desc[idx].len = src_len;
 	} else {
 		desc[idx].addr = rte_pktmbuf_iova_offset(sym_op->m_src, 0);
-		desc[idx].len = (sym_op->cipher.data.offset
-			+ sym_op->cipher.data.length);
+		desc[idx].len = src_len;
 	}
 	desc[idx++].flags = VRING_DESC_F_WRITE | VRING_DESC_F_NEXT;