patch 'vhost: fix FD leak with inflight messages' has been queued to stable release 20.11.5

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue Mar 15 14:32:25 CET 2022


Hi,

FYI, your patch has been queued to stable release 20.11.5

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

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/8c3269273e80eeefc680ce41257a07e79bad8372

Thanks.

Luca Boccassi

---
>From 8c3269273e80eeefc680ce41257a07e79bad8372 Mon Sep 17 00:00:00 2001
From: David Marchand <david.marchand at redhat.com>
Date: Tue, 18 Jan 2022 15:53:30 +0100
Subject: [PATCH] vhost: fix FD leak with inflight messages

[ upstream commit af74f7db384ed149fe42b21dbd7975f8a54ef227 ]

Even if unlikely, a buggy vhost-user master might attach fds to inflight
messages. Add checks like for other types of vhost-user messages.

Fixes: d87f1a1cb7b6 ("vhost: support inflight info sharing")

Signed-off-by: David Marchand <david.marchand at redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 lib/librte_vhost/vhost_user.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index c829ce95fb..fbb854dad0 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1450,6 +1450,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev,
 	int fd, i, j;
 	void *addr;
 
+	if (validate_msg_fds(msg, 0) != 0)
+		return RTE_VHOST_MSG_RESULT_ERR;
+
 	if (msg->size != sizeof(msg->payload.inflight)) {
 		VHOST_LOG_CONFIG(ERR,
 			"invalid get_inflight_fd message size is %d\n",
@@ -1543,6 +1546,9 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg,
 	void *addr;
 	int fd, i;
 
+	if (validate_msg_fds(msg, 1) != 0)
+		return RTE_VHOST_MSG_RESULT_ERR;
+
 	fd = msg->fds[0];
 	if (msg->size != sizeof(msg->payload.inflight) || fd < 0) {
 		VHOST_LOG_CONFIG(ERR,
-- 
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-03-15 12:13:39.134833210 +0000
+++ 0002-vhost-fix-FD-leak-with-inflight-messages.patch	2022-03-15 12:13:39.028180097 +0000
@@ -1 +1 @@
-From af74f7db384ed149fe42b21dbd7975f8a54ef227 Mon Sep 17 00:00:00 2001
+From 8c3269273e80eeefc680ce41257a07e79bad8372 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit af74f7db384ed149fe42b21dbd7975f8a54ef227 ]
+
@@ -10 +11,0 @@
-Cc: stable at dpdk.org
@@ -15 +16 @@
- lib/vhost/vhost_user.c | 6 ++++++
+ lib/librte_vhost/vhost_user.c | 6 ++++++
@@ -18,6 +19,6 @@
-diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
-index 1ec4357bee..1d390677fa 100644
---- a/lib/vhost/vhost_user.c
-+++ b/lib/vhost/vhost_user.c
-@@ -1602,6 +1602,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev,
- 	int numa_node = SOCKET_ID_ANY;
+diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
+index c829ce95fb..fbb854dad0 100644
+--- a/lib/librte_vhost/vhost_user.c
++++ b/lib/librte_vhost/vhost_user.c
+@@ -1450,6 +1450,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev,
+ 	int fd, i, j;
@@ -26 +27 @@
-+	if (validate_msg_fds(dev, ctx, 0) != 0)
++	if (validate_msg_fds(msg, 0) != 0)
@@ -29,4 +30,5 @@
- 	if (ctx->msg.size != sizeof(ctx->msg.payload.inflight)) {
- 		VHOST_LOG_CONFIG(ERR, "(%s) invalid get_inflight_fd message size is %d\n",
- 			dev->ifname, ctx->msg.size);
-@@ -1699,6 +1702,9 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev,
+ 	if (msg->size != sizeof(msg->payload.inflight)) {
+ 		VHOST_LOG_CONFIG(ERR,
+ 			"invalid get_inflight_fd message size is %d\n",
+@@ -1543,6 +1546,9 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg,
+ 	void *addr;
@@ -34 +35,0 @@
- 	int numa_node = SOCKET_ID_ANY;
@@ -36 +37 @@
-+	if (validate_msg_fds(dev, ctx, 1) != 0)
++	if (validate_msg_fds(msg, 1) != 0)
@@ -39,3 +40,3 @@
- 	fd = ctx->fds[0];
- 	if (ctx->msg.size != sizeof(ctx->msg.payload.inflight) || fd < 0) {
- 		VHOST_LOG_CONFIG(ERR, "(%s) invalid set_inflight_fd message size is %d,fd is %d\n",
+ 	fd = msg->fds[0];
+ 	if (msg->size != sizeof(msg->payload.inflight) || fd < 0) {
+ 		VHOST_LOG_CONFIG(ERR,


More information about the stable mailing list