[dpdk-stable] patch 'net/failsafe: fix fd leak' has been queued to stable release 19.11.3

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue May 19 15:05:16 CEST 2020


Hi,

FYI, your patch has been queued to stable release 19.11.3

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

Thanks.

Luca Boccassi

---
>From 556ae6bd83a2970e0b7cf2ae216ef87eac2d1ab4 Mon Sep 17 00:00:00 2001
From: Yunjian Wang <wangyunjian at huawei.com>
Date: Mon, 27 Apr 2020 18:44:19 +0800
Subject: [PATCH] net/failsafe: fix fd leak

[ upstream commit b9663f60359296bcb6f0be8a3d6a2a838c77ee30 ]

Zero is a valid fd. The fd won't be closed thus leading fd leak,
when it is zero.

Also the service proxy is initialized at 0. This is assuming that all of
its fields are invalid at 0. The issue is that a file descriptor at 0 is
a valid one.

The value -1 is used as sentinel during cleanup. Initialize the RX proxy
file descriptor to -1.

Fixes: f234e5bd996d ("net/failsafe: register slaves Rx interrupts")
Fixes: 9e0360aebf23 ("net/failsafe: register as Rx interrupt mode")

Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
Signed-off-by: Gaetan Rivet <grive at u256.net>
Tested-by: Ali Alnubani <alialnu at mellanox.com>
---
 drivers/net/failsafe/failsafe.c         | 1 +
 drivers/net/failsafe/failsafe_intr.c    | 2 +-
 drivers/net/failsafe/failsafe_ops.c     | 2 +-
 drivers/net/failsafe/failsafe_private.h | 8 ++++++++
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index 8af31d71b3..72362f35de 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -190,6 +190,7 @@ fs_eth_dev_create(struct rte_vdev_device *vdev)
 	}
 	priv = PRIV(dev);
 	priv->data = dev->data;
+	priv->rxp = FS_RX_PROXY_INIT;
 	dev->dev_ops = &failsafe_ops;
 	dev->data->mac_addrs = &PRIV(dev)->mac_addrs[0];
 	dev->data->dev_link = eth_link;
diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/failsafe_intr.c
index 0f34c5bbac..bb5b089b31 100644
--- a/drivers/net/failsafe/failsafe_intr.c
+++ b/drivers/net/failsafe/failsafe_intr.c
@@ -394,7 +394,7 @@ fs_rx_event_proxy_uninstall(struct fs_priv *priv)
 		free(priv->rxp.evec);
 		priv->rxp.evec = NULL;
 	}
-	if (priv->rxp.efd > 0) {
+	if (priv->rxp.efd >= 0) {
 		close(priv->rxp.efd);
 		priv->rxp.efd = -1;
 	}
diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c
index 50f2aca4e7..e1d08e46c8 100644
--- a/drivers/net/failsafe/failsafe_ops.c
+++ b/drivers/net/failsafe/failsafe_ops.c
@@ -380,7 +380,7 @@ fs_rx_queue_release(void *queue)
 	rxq = queue;
 	dev = &rte_eth_devices[rxq->priv->data->port_id];
 	fs_lock(dev, 0);
-	if (rxq->event_fd > 0)
+	if (rxq->event_fd >= 0)
 		close(rxq->event_fd);
 	FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
 		if (ETH(sdev)->data->rx_queues != NULL &&
diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h
index 8e9706aef0..651578a128 100644
--- a/drivers/net/failsafe/failsafe_private.h
+++ b/drivers/net/failsafe/failsafe_private.h
@@ -58,6 +58,14 @@ struct rx_proxy {
 	enum rxp_service_state sstate;
 };
 
+#define FS_RX_PROXY_INIT (struct rx_proxy){ \
+	.efd = -1, \
+	.evec = NULL, \
+	.sid = 0, \
+	.scid = 0, \
+	.sstate = SS_NO_SERVICE, \
+}
+
 struct rxq {
 	struct fs_priv *priv;
 	uint16_t qid;
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-05-19 14:04:51.913176286 +0100
+++ 0181-net-failsafe-fix-fd-leak.patch	2020-05-19 14:04:44.524653956 +0100
@@ -1,8 +1,10 @@
-From b9663f60359296bcb6f0be8a3d6a2a838c77ee30 Mon Sep 17 00:00:00 2001
+From 556ae6bd83a2970e0b7cf2ae216ef87eac2d1ab4 Mon Sep 17 00:00:00 2001
 From: Yunjian Wang <wangyunjian at huawei.com>
 Date: Mon, 27 Apr 2020 18:44:19 +0800
 Subject: [PATCH] net/failsafe: fix fd leak
 
+[ upstream commit b9663f60359296bcb6f0be8a3d6a2a838c77ee30 ]
+
 Zero is a valid fd. The fd won't be closed thus leading fd leak,
 when it is zero.
 
@@ -15,7 +17,6 @@
 
 Fixes: f234e5bd996d ("net/failsafe: register slaves Rx interrupts")
 Fixes: 9e0360aebf23 ("net/failsafe: register as Rx interrupt mode")
-Cc: stable at dpdk.org
 
 Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
 Signed-off-by: Gaetan Rivet <grive at u256.net>
@@ -40,10 +41,10 @@
  	dev->data->mac_addrs = &PRIV(dev)->mac_addrs[0];
  	dev->data->dev_link = eth_link;
 diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/failsafe_intr.c
-index d8728fe7e3..602c04033c 100644
+index 0f34c5bbac..bb5b089b31 100644
 --- a/drivers/net/failsafe/failsafe_intr.c
 +++ b/drivers/net/failsafe/failsafe_intr.c
-@@ -393,7 +393,7 @@ fs_rx_event_proxy_uninstall(struct fs_priv *priv)
+@@ -394,7 +394,7 @@ fs_rx_event_proxy_uninstall(struct fs_priv *priv)
  		free(priv->rxp.evec);
  		priv->rxp.evec = NULL;
  	}


More information about the stable mailing list