* [PATCH 2/2] crypto/virtio: fix cipher data src length
@ 2025-04-03 12:26 Rajesh Mudimadugula
0 siblings, 0 replies; only message in thread
From: Rajesh Mudimadugula @ 2025-04-03 12:26 UTC (permalink / raw)
To: dev; +Cc: jianjay.zhou, Rajesh Mudimadugula
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(-)
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;
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-04-03 12:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-03 12:26 [PATCH 2/2] crypto/virtio: fix cipher data src length Rajesh Mudimadugula
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).