patch 'examples/vhost: fix use after free' has been queued to stable release 20.11.7

luca.boccassi at gmail.com luca.boccassi at gmail.com
Thu Nov 3 10:26:58 CET 2022


Hi,

FYI, your patch has been queued to stable release 20.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/05/22. 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/cc65c7fccf4f361551ffa7526d61c3073fa04bbe

Thanks.

Luca Boccassi

---
>From cc65c7fccf4f361551ffa7526d61c3073fa04bbe Mon Sep 17 00:00:00 2001
From: Wenwu Ma <wenwux.ma at intel.com>
Date: Thu, 14 Jul 2022 13:11:06 +0800
Subject: [PATCH] examples/vhost: fix use after free

[ upstream commit 40abb903fe0aff0556d15d96385a4c7b647649b5 ]

In async_enqueue_pkts(), the failed pkts will
be freed before return, but, the failed pkts may be
retried later, it will cause use after free. So,
we free the failed pkts after retry.

Fixes: 1907ce4baec3 ("examples/vhost: fix retry logic on Rx path")

Signed-off-by: Wenwu Ma <wenwux.ma at intel.com>
Tested-by: Wei Ling <weix.ling at intel.com>
Reviewed-by: Chenbo Xia <chenbo.xia at intel.com>
---
 examples/vhost/main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 24e37f7ce5..b7ac9c2f15 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1163,8 +1163,13 @@ drain_eth_rx(struct vhost_dev *vdev)
 		rte_atomic64_add(&vdev->stats.rx_atomic, enqueue_count);
 	}
 
-	if (!async_vhost_driver)
+	if (!async_vhost_driver) {
 		free_pkts(pkts, rx_count);
+	} else {
+		uint16_t enqueue_fail = rx_count - enqueue_count;
+		if (enqueue_fail > 0)
+			free_pkts(&pkts[enqueue_count], enqueue_fail);
+	}
 }
 
 static __rte_always_inline void
-- 
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-11-03 09:27:27.870280891 +0000
+++ 0040-examples-vhost-fix-use-after-free.patch	2022-11-03 09:27:25.413423215 +0000
@@ -1 +1 @@
-From 40abb903fe0aff0556d15d96385a4c7b647649b5 Mon Sep 17 00:00:00 2001
+From cc65c7fccf4f361551ffa7526d61c3073fa04bbe Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 40abb903fe0aff0556d15d96385a4c7b647649b5 ]
+
@@ -12 +13,0 @@
-Cc: stable at dpdk.org
@@ -18,2 +19,2 @@
- examples/vhost/main.c | 19 ++++++++++++-------
- 1 file changed, 12 insertions(+), 7 deletions(-)
+ examples/vhost/main.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
@@ -22 +23 @@
-index 0fa4753e70..195ef84b3b 100644
+index 24e37f7ce5..b7ac9c2f15 100644
@@ -25,35 +26,2 @@
-@@ -1075,8 +1075,13 @@ drain_vhost(struct vhost_dev *vdev)
- 				__ATOMIC_SEQ_CST);
- 	}
- 
--	if (!dma_bind[vid2socketid[vdev->vid]].dmas[VIRTIO_RXQ].async_enabled)
-+	if (!dma_bind[vid2socketid[vdev->vid]].dmas[VIRTIO_RXQ].async_enabled) {
- 		free_pkts(m, nr_xmit);
-+	} else {
-+		uint16_t enqueue_fail = nr_xmit - ret;
-+		if (enqueue_fail > 0)
-+			free_pkts(&m[ret], enqueue_fail);
-+	}
- }
- 
- static __rte_always_inline void
-@@ -1352,17 +1357,12 @@ async_enqueue_pkts(struct vhost_dev *dev, uint16_t queue_id,
- 		struct rte_mbuf **pkts, uint32_t rx_count)
- {
- 	uint16_t enqueue_count;
--	uint16_t enqueue_fail = 0;
- 	uint16_t dma_id = dma_bind[vid2socketid[dev->vid]].dmas[VIRTIO_RXQ].dev_id;
- 
- 	complete_async_pkts(dev);
- 	enqueue_count = rte_vhost_submit_enqueue_burst(dev->vid, queue_id,
- 					pkts, rx_count, dma_id, 0);
- 
--	enqueue_fail = rx_count - enqueue_count;
--	if (enqueue_fail)
--		free_pkts(&pkts[enqueue_count], enqueue_fail);
--
- 	return enqueue_count;
- }
- 
-@@ -1407,8 +1407,13 @@ drain_eth_rx(struct vhost_dev *vdev)
- 				__ATOMIC_SEQ_CST);
+@@ -1163,8 +1163,13 @@ drain_eth_rx(struct vhost_dev *vdev)
+ 		rte_atomic64_add(&vdev->stats.rx_atomic, enqueue_count);
@@ -62,2 +30,2 @@
--	if (!dma_bind[vid2socketid[vdev->vid]].dmas[VIRTIO_RXQ].async_enabled)
-+	if (!dma_bind[vid2socketid[vdev->vid]].dmas[VIRTIO_RXQ].async_enabled) {
+-	if (!async_vhost_driver)
++	if (!async_vhost_driver) {
@@ -72 +40 @@
- uint16_t async_dequeue_pkts(struct vhost_dev *dev, uint16_t queue_id,
+ static __rte_always_inline void


More information about the stable mailing list