patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] crypto/virtio: add request check on request side
@ 2025-05-23 14:04 Radu Nicolau
  2025-05-27 19:24 ` Zhang, Fan
  2025-05-29  3:36 ` Jiang, YuX
  0 siblings, 2 replies; 3+ messages in thread
From: Radu Nicolau @ 2025-05-23 14:04 UTC (permalink / raw)
  To: Jay Zhou, Fan Zhang, Chenbo Xia; +Cc: dev, Radu Nicolau, roy.fan.zhang, stable

Add same request checks on the request side.

Fixes: b2866f473369 ("vhost/crypto: fix missed request check for copy mode")
Cc: roy.fan.zhang@intel.com
Cc: stable@dpdk.org

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 drivers/crypto/virtio/virtio_rxtx.c | 40 +++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/crypto/virtio/virtio_rxtx.c b/drivers/crypto/virtio/virtio_rxtx.c
index 0cc904485c..afdb8fb406 100644
--- a/drivers/crypto/virtio/virtio_rxtx.c
+++ b/drivers/crypto/virtio/virtio_rxtx.c
@@ -193,6 +193,40 @@ virtqueue_dequeue_burst_rx_packed(struct virtqueue *vq,
 	return i;
 }
 
+static __rte_always_inline uint8_t
+virtqueue_crypto_check_cipher_request(struct virtio_crypto_cipher_data_req *req)
+{
+	if (likely((req->para.iv_len <= VIRTIO_CRYPTO_MAX_IV_SIZE) &&
+		(req->para.src_data_len <= RTE_MBUF_DEFAULT_BUF_SIZE) &&
+		(req->para.dst_data_len >= req->para.src_data_len) &&
+		(req->para.dst_data_len <= RTE_MBUF_DEFAULT_BUF_SIZE)))
+		return VIRTIO_CRYPTO_OK;
+	return VIRTIO_CRYPTO_BADMSG;
+}
+
+static __rte_always_inline uint8_t
+virtqueue_crypto_check_chain_request(struct virtio_crypto_alg_chain_data_req *req)
+{
+	if (likely((req->para.iv_len <= VIRTIO_CRYPTO_MAX_IV_SIZE) &&
+		(req->para.src_data_len <= RTE_MBUF_DEFAULT_BUF_SIZE) &&
+		(req->para.dst_data_len >= req->para.src_data_len) &&
+		(req->para.dst_data_len <= RTE_MBUF_DEFAULT_BUF_SIZE) &&
+		(req->para.cipher_start_src_offset <
+			RTE_MBUF_DEFAULT_BUF_SIZE) &&
+		(req->para.len_to_cipher <= RTE_MBUF_DEFAULT_BUF_SIZE) &&
+		(req->para.hash_start_src_offset <
+			RTE_MBUF_DEFAULT_BUF_SIZE) &&
+		(req->para.len_to_hash <= RTE_MBUF_DEFAULT_BUF_SIZE) &&
+		(req->para.cipher_start_src_offset + req->para.len_to_cipher <=
+			req->para.src_data_len) &&
+		(req->para.hash_start_src_offset + req->para.len_to_hash <=
+			req->para.src_data_len) &&
+		(req->para.dst_data_len + req->para.hash_result_len <=
+			RTE_MBUF_DEFAULT_BUF_SIZE)))
+		return VIRTIO_CRYPTO_OK;
+	return VIRTIO_CRYPTO_BADMSG;
+}
+
 static inline int
 virtqueue_crypto_sym_pkt_header_arrange(
 		struct rte_crypto_op *cop,
@@ -228,6 +262,9 @@ virtqueue_crypto_sym_pkt_header_arrange(
 				sym_op->cipher.data.offset);
 		req_data->u.sym_req.u.cipher.para.dst_data_len =
 			req_data->u.sym_req.u.cipher.para.src_data_len;
+		if (virtqueue_crypto_check_cipher_request(
+			&req_data->u.sym_req.u.cipher) != VIRTIO_CRYPTO_OK)
+			return -1;
 		break;
 	case VIRTIO_CRYPTO_SYM_OP_ALGORITHM_CHAINING:
 		req_data->u.sym_req.op_type =
@@ -265,6 +302,9 @@ virtqueue_crypto_sym_pkt_header_arrange(
 			VIRTIO_CRYPTO_SYM_HASH_MODE_AUTH)
 			req_data->u.sym_req.u.chain.para.hash_result_len =
 				chain_para->u.mac_param.hash_result_len;
+		if (virtqueue_crypto_check_chain_request(
+			&req_data->u.sym_req.u.chain) != VIRTIO_CRYPTO_OK)
+			return -1;
 		break;
 	default:
 		return -1;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto/virtio: add request check on request side
  2025-05-23 14:04 [PATCH] crypto/virtio: add request check on request side Radu Nicolau
@ 2025-05-27 19:24 ` Zhang, Fan
  2025-05-29  3:36 ` Jiang, YuX
  1 sibling, 0 replies; 3+ messages in thread
From: Zhang, Fan @ 2025-05-27 19:24 UTC (permalink / raw)
  To: Radu Nicolau, Jay Zhou, Chenbo Xia; +Cc: dev, stable

[-- Attachment #1: Type: text/plain, Size: 327 bytes --]


On 5/23/2025 3:04 PM, Radu Nicolau wrote:
> Add same request checks on the request side.
>
> Fixes: b2866f473369 ("vhost/crypto: fix missed request check for copy mode")
> Cc:roy.fan.zhang@intel.com
> Cc:stable@dpdk.org
>
> Signed-off-by: Radu Nicolau<radu.nicolau@intel.com>
> ---
Acked-by: Fan Zhang <fanzhang.oss@gmail.com>

[-- Attachment #2: Type: text/html, Size: 1050 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] crypto/virtio: add request check on request side
  2025-05-23 14:04 [PATCH] crypto/virtio: add request check on request side Radu Nicolau
  2025-05-27 19:24 ` Zhang, Fan
@ 2025-05-29  3:36 ` Jiang, YuX
  1 sibling, 0 replies; 3+ messages in thread
From: Jiang, YuX @ 2025-05-29  3:36 UTC (permalink / raw)
  To: Nicolau, Radu, Jay Zhou, Fan Zhang, Chenbo Xia
  Cc: dev, Nicolau, Radu, roy.fan.zhang, stable

> -----Original Message-----
> From: Radu Nicolau <radu.nicolau@intel.com>
> Sent: Friday, May 23, 2025 10:05 PM
> To: Jay Zhou <jianjay.zhou@huawei.com>; Fan Zhang
> <fanzhang.oss@gmail.com>; Chenbo Xia <chenbox@nvidia.com>
> Cc: dev@dpdk.org; Nicolau, Radu <radu.nicolau@intel.com>;
> roy.fan.zhang@intel.com; stable@dpdk.org
> Subject: [PATCH] crypto/virtio: add request check on request side
> 
> Add same request checks on the request side.
> 
> Fixes: b2866f473369 ("vhost/crypto: fix missed request check for copy
> mode")
> Cc: roy.fan.zhang@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
>  drivers/crypto/virtio/virtio_rxtx.c | 40 +++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
Tested-by:  Yu Jiang <yux.jiang@intel.com>

Best regards,
Yu Jiang

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-29  3:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-23 14:04 [PATCH] crypto/virtio: add request check on request side Radu Nicolau
2025-05-27 19:24 ` Zhang, Fan
2025-05-29  3:36 ` Jiang, YuX

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).