patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 19.11] net/mlx5: fix Verbs FD leak in secondary process
@ 2022-11-16 19:25 Long Li
  2022-11-17  7:40 ` Christian Ehrhardt
  0 siblings, 1 reply; 2+ messages in thread
From: Long Li @ 2022-11-16 19:25 UTC (permalink / raw)
  To: stable; +Cc: longli

[ upstream commit bc5d8fdb7008210e2698fa1f91e51d7dfba00f77 ]

FDs passed from rte_mp_msg are duplicated to the secondary process and
need to be closed.

Fixes: 9a8ab29b84 ("net/mlx5: replace IPC socket with EAL API")
Cc: stable@dpdk.org

Signed-off-by: Long Li <longli@microsoft.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/mlx5.c    | 9 ++++++---
 drivers/net/mlx5/mlx5_mp.c | 6 +++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index dee018bbba..2d0f9625fb 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -2291,6 +2291,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	}
 	DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name);
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+		int fd;
+
 		eth_dev = rte_eth_dev_attach_secondary(name);
 		if (eth_dev == NULL) {
 			DRV_LOG(ERR, "can not attach rte ethdev");
@@ -2303,11 +2305,12 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 		if (err)
 			return NULL;
 		/* Receive command fd from primary process */
-		err = mlx5_mp_req_verbs_cmd_fd(eth_dev);
-		if (err < 0)
+		fd = mlx5_mp_req_verbs_cmd_fd(eth_dev);
+		if (fd < 0)
 			goto err_secondary;
 		/* Remap UAR for Tx queues. */
-		err = mlx5_tx_uar_init_secondary(eth_dev, err);
+		err = mlx5_tx_uar_init_secondary(eth_dev, fd);
+		close(fd);
 		if (err)
 			goto err_secondary;
 		/*
diff --git a/drivers/net/mlx5/mlx5_mp.c b/drivers/net/mlx5/mlx5_mp.c
index 6b7f5f3dcb..7e05217cda 100644
--- a/drivers/net/mlx5/mlx5_mp.c
+++ b/drivers/net/mlx5/mlx5_mp.c
@@ -142,14 +142,18 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 			mlx5_tx_uar_uninit_secondary(dev);
 			mlx5_proc_priv_uninit(dev);
 			ret = mlx5_proc_priv_init(dev);
-			if (ret)
+			if (ret) {
+				close(mp_msg->fds[0]);
 				return -rte_errno;
+			}
 			ret = mlx5_tx_uar_init_secondary(dev, mp_msg->fds[0]);
 			if (ret) {
+				close(mp_msg->fds[0]);
 				mlx5_proc_priv_uninit(dev);
 				return -rte_errno;
 			}
 		}
+		close(mp_msg->fds[0]);
 		rte_mb();
 		mp_init_msg(dev, &mp_res, param->type);
 		res->result = 0;
-- 
2.17.1


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

* Re: [PATCH 19.11] net/mlx5: fix Verbs FD leak in secondary process
  2022-11-16 19:25 [PATCH 19.11] net/mlx5: fix Verbs FD leak in secondary process Long Li
@ 2022-11-17  7:40 ` Christian Ehrhardt
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Ehrhardt @ 2022-11-17  7:40 UTC (permalink / raw)
  To: longli; +Cc: stable

On Wed, Nov 16, 2022 at 8:26 PM Long Li <longli@microsoft.com> wrote:
>
> [ upstream commit bc5d8fdb7008210e2698fa1f91e51d7dfba00f77 ]

Applied, thanks!

> FDs passed from rte_mp_msg are duplicated to the secondary process and
> need to be closed.
>
> Fixes: 9a8ab29b84 ("net/mlx5: replace IPC socket with EAL API")
> Cc: stable@dpdk.org
>
> Signed-off-by: Long Li <longli@microsoft.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> ---
>  drivers/net/mlx5/mlx5.c    | 9 ++++++---
>  drivers/net/mlx5/mlx5_mp.c | 6 +++++-
>  2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
> index dee018bbba..2d0f9625fb 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -2291,6 +2291,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
>         }
>         DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name);
>         if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
> +               int fd;
> +
>                 eth_dev = rte_eth_dev_attach_secondary(name);
>                 if (eth_dev == NULL) {
>                         DRV_LOG(ERR, "can not attach rte ethdev");
> @@ -2303,11 +2305,12 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
>                 if (err)
>                         return NULL;
>                 /* Receive command fd from primary process */
> -               err = mlx5_mp_req_verbs_cmd_fd(eth_dev);
> -               if (err < 0)
> +               fd = mlx5_mp_req_verbs_cmd_fd(eth_dev);
> +               if (fd < 0)
>                         goto err_secondary;
>                 /* Remap UAR for Tx queues. */
> -               err = mlx5_tx_uar_init_secondary(eth_dev, err);
> +               err = mlx5_tx_uar_init_secondary(eth_dev, fd);
> +               close(fd);
>                 if (err)
>                         goto err_secondary;
>                 /*
> diff --git a/drivers/net/mlx5/mlx5_mp.c b/drivers/net/mlx5/mlx5_mp.c
> index 6b7f5f3dcb..7e05217cda 100644
> --- a/drivers/net/mlx5/mlx5_mp.c
> +++ b/drivers/net/mlx5/mlx5_mp.c
> @@ -142,14 +142,18 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
>                         mlx5_tx_uar_uninit_secondary(dev);
>                         mlx5_proc_priv_uninit(dev);
>                         ret = mlx5_proc_priv_init(dev);
> -                       if (ret)
> +                       if (ret) {
> +                               close(mp_msg->fds[0]);
>                                 return -rte_errno;
> +                       }
>                         ret = mlx5_tx_uar_init_secondary(dev, mp_msg->fds[0]);
>                         if (ret) {
> +                               close(mp_msg->fds[0]);
>                                 mlx5_proc_priv_uninit(dev);
>                                 return -rte_errno;
>                         }
>                 }
> +               close(mp_msg->fds[0]);
>                 rte_mb();
>                 mp_init_msg(dev, &mp_res, param->type);
>                 res->result = 0;
> --
> 2.17.1
>


-- 
Christian Ehrhardt
Senior Staff Engineer, Ubuntu Server
Canonical Ltd

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

end of thread, other threads:[~2022-11-17  7:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16 19:25 [PATCH 19.11] net/mlx5: fix Verbs FD leak in secondary process Long Li
2022-11-17  7:40 ` Christian Ehrhardt

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