patch 'vhost: fix deadlock when message handling failed' has been queued to stable release 20.11.6

Xueming Li xuemingl at nvidia.com
Tue Jun 21 10:02:35 CEST 2022


Hi,

FYI, your patch has been queued to stable release 20.11.6

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/23/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/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/63005df100f41bc54d8146bdd1d2e8ab4c67ec38

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 63005df100f41bc54d8146bdd1d2e8ab4c67ec38 Mon Sep 17 00:00:00 2001
From: Wenwu Ma <wenwux.ma at intel.com>
Date: Sat, 7 May 2022 13:27:53 +0000
Subject: [PATCH] vhost: fix deadlock when message handling failed
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 9e89b06d027c6087624f36f288bd82c643c5a269 ]

In vhost_user_msg_handler(), if vhost message handling
failed, we should check whether the queue is locked and
release the lock before returning. Or, it will cause a
deadlock later.

Fixes: 7f31d4ea05ca ("vhost: fix lock on device readiness notification")

Signed-off-by: Wenwu Ma <wenwux.ma at intel.com>
Reviewed-by: Chenbo Xia <chenbo.xia at intel.com>
Tested-by: Wei Ling <weix.ling at intel.com>
Acked-by: David Marchand <david.marchand at redhat.com>
---
 lib/librte_vhost/vhost_user.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index fbb854dad0..25ebc0c37c 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -2789,7 +2789,6 @@ vhost_user_msg_handler(int vid, int fd)
 		return -1;
 	}
 
-	ret = 0;
 	request = msg.request.master;
 	if (request > VHOST_USER_NONE && request < VHOST_USER_MAX &&
 			vhost_message_str[request]) {
@@ -2931,9 +2930,11 @@ skip_to_post_handle:
 	} else if (ret == RTE_VHOST_MSG_RESULT_ERR) {
 		VHOST_LOG_CONFIG(ERR,
 			"vhost message handling failed.\n");
-		return -1;
+		ret = -1;
+		goto unlock;
 	}
 
+	ret = 0;
 	for (i = 0; i < dev->nr_vring; i++) {
 		struct vhost_virtqueue *vq = dev->virtqueue[i];
 		bool cur_ready = vq_is_ready(dev, vq);
@@ -2944,10 +2945,11 @@ skip_to_post_handle:
 		}
 	}
 
+unlock:
 	if (unlock_required)
 		vhost_user_unlock_all_queue_pairs(dev);
 
-	if (!virtio_is_ready(dev))
+	if (ret != 0 || !virtio_is_ready(dev))
 		goto out;
 
 	/*
@@ -2974,7 +2976,7 @@ skip_to_post_handle:
 	}
 
 out:
-	return 0;
+	return ret;
 }
 
 static int process_slave_message_reply(struct virtio_net *dev,
-- 
2.35.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-06-21 15:37:53.251533320 +0800
+++ 0089-vhost-fix-deadlock-when-message-handling-failed.patch	2022-06-21 15:37:49.184451772 +0800
@@ -1 +1 @@
-From 9e89b06d027c6087624f36f288bd82c643c5a269 Mon Sep 17 00:00:00 2001
+From 63005df100f41bc54d8146bdd1d2e8ab4c67ec38 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 9e89b06d027c6087624f36f288bd82c643c5a269 ]
@@ -12 +14,0 @@
-Cc: stable at dpdk.org
@@ -19 +21 @@
- lib/vhost/vhost_user.c | 10 ++++++----
+ lib/librte_vhost/vhost_user.c | 10 ++++++----
@@ -22,5 +24,5 @@
-diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
-index 850848c269..91e69d1d97 100644
---- a/lib/vhost/vhost_user.c
-+++ b/lib/vhost/vhost_user.c
-@@ -2887,7 +2887,6 @@ vhost_user_msg_handler(int vid, int fd)
+diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
+index fbb854dad0..25ebc0c37c 100644
+--- a/lib/librte_vhost/vhost_user.c
++++ b/lib/librte_vhost/vhost_user.c
+@@ -2789,7 +2789,6 @@ vhost_user_msg_handler(int vid, int fd)
@@ -31,5 +33,4 @@
- 	request = ctx.msg.request.master;
- 	if (request > VHOST_USER_NONE && request < RTE_DIM(vhost_message_handlers))
- 		msg_handler = &vhost_message_handlers[request];
-@@ -3031,9 +3030,11 @@ skip_to_post_handle:
- 		send_vhost_reply(dev, fd, &ctx);
+ 	request = msg.request.master;
+ 	if (request > VHOST_USER_NONE && request < VHOST_USER_MAX &&
+ 			vhost_message_str[request]) {
+@@ -2931,9 +2930,11 @@ skip_to_post_handle:
@@ -37 +38,2 @@
- 		VHOST_LOG_CONFIG(ERR, "(%s) vhost message handling failed.\n", dev->ifname);
+ 		VHOST_LOG_CONFIG(ERR,
+ 			"vhost message handling failed.\n");
@@ -47 +49 @@
-@@ -3044,10 +3045,11 @@ skip_to_post_handle:
+@@ -2944,10 +2945,11 @@ skip_to_post_handle:
@@ -60 +62 @@
-@@ -3074,7 +3076,7 @@ skip_to_post_handle:
+@@ -2974,7 +2976,7 @@ skip_to_post_handle:


More information about the stable mailing list