patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] net/virtio-user: fix leak when initialisation fails
@ 2023-04-13 10:10 David Marchand
  2023-04-17  6:43 ` Maxime Coquelin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Marchand @ 2023-04-13 10:10 UTC (permalink / raw)
  To: dev
  Cc: stable, Maxime Coquelin, Chenbo Xia, Yuanhan Liu, Wenfeng Liu,
	Jianfeng Tan

Caught with ASan.
If initialising a virtio_user port fails, we may leak the ifname passed
via a devargs.

Fixes: 4214a1b493f2 ("net/virtio-user: support changing tap interface name")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index f46a131b5c..744f3c30d2 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -696,11 +696,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
 	dev->frontend_features = 0;
 	dev->unsupported_features = 0;
 	dev->backend_type = backend_type;
-
-	if (*ifname) {
-		dev->ifname = *ifname;
-		*ifname = NULL;
-	}
+	dev->ifname = *ifname;
 
 	if (virtio_user_dev_setup(dev) < 0) {
 		PMD_INIT_LOG(ERR, "(%s) backend set up fails", dev->path);
@@ -794,6 +790,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
 		}
 	}
 
+	*ifname = NULL;
 	return 0;
 
 notify_uninit:
-- 
2.39.2


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

* Re: [PATCH] net/virtio-user: fix leak when initialisation fails
  2023-04-13 10:10 [PATCH] net/virtio-user: fix leak when initialisation fails David Marchand
@ 2023-04-17  6:43 ` Maxime Coquelin
  2023-04-18 18:15 ` Tyler Retzlaff
  2023-06-01 20:00 ` Maxime Coquelin
  2 siblings, 0 replies; 4+ messages in thread
From: Maxime Coquelin @ 2023-04-17  6:43 UTC (permalink / raw)
  To: David Marchand, dev
  Cc: stable, Chenbo Xia, Yuanhan Liu, Wenfeng Liu, Jianfeng Tan



On 4/13/23 12:10, David Marchand wrote:
> Caught with ASan.
> If initialising a virtio_user port fails, we may leak the ifname passed
> via a devargs.
> 
> Fixes: 4214a1b493f2 ("net/virtio-user: support changing tap interface name")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>   drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index f46a131b5c..744f3c30d2 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -696,11 +696,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
>   	dev->frontend_features = 0;
>   	dev->unsupported_features = 0;
>   	dev->backend_type = backend_type;
> -
> -	if (*ifname) {
> -		dev->ifname = *ifname;
> -		*ifname = NULL;
> -	}
> +	dev->ifname = *ifname;
>   
>   	if (virtio_user_dev_setup(dev) < 0) {
>   		PMD_INIT_LOG(ERR, "(%s) backend set up fails", dev->path);
> @@ -794,6 +790,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
>   		}
>   	}
>   
> +	*ifname = NULL;
>   	return 0;
>   
>   notify_uninit:

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime


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

* Re: [PATCH] net/virtio-user: fix leak when initialisation fails
  2023-04-13 10:10 [PATCH] net/virtio-user: fix leak when initialisation fails David Marchand
  2023-04-17  6:43 ` Maxime Coquelin
@ 2023-04-18 18:15 ` Tyler Retzlaff
  2023-06-01 20:00 ` Maxime Coquelin
  2 siblings, 0 replies; 4+ messages in thread
From: Tyler Retzlaff @ 2023-04-18 18:15 UTC (permalink / raw)
  To: David Marchand
  Cc: dev, stable, Maxime Coquelin, Chenbo Xia, Yuanhan Liu,
	Wenfeng Liu, Jianfeng Tan

On Thu, Apr 13, 2023 at 12:10:41PM +0200, David Marchand wrote:
> Caught with ASan.
> If initialising a virtio_user port fails, we may leak the ifname passed
> via a devargs.
> 
> Fixes: 4214a1b493f2 ("net/virtio-user: support changing tap interface name")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>


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

* Re: [PATCH] net/virtio-user: fix leak when initialisation fails
  2023-04-13 10:10 [PATCH] net/virtio-user: fix leak when initialisation fails David Marchand
  2023-04-17  6:43 ` Maxime Coquelin
  2023-04-18 18:15 ` Tyler Retzlaff
@ 2023-06-01 20:00 ` Maxime Coquelin
  2 siblings, 0 replies; 4+ messages in thread
From: Maxime Coquelin @ 2023-06-01 20:00 UTC (permalink / raw)
  To: David Marchand, dev
  Cc: stable, Chenbo Xia, Yuanhan Liu, Wenfeng Liu, Jianfeng Tan



On 4/13/23 12:10, David Marchand wrote:
> Caught with ASan.
> If initialising a virtio_user port fails, we may leak the ifname passed
> via a devargs.
> 
> Fixes: 4214a1b493f2 ("net/virtio-user: support changing tap interface name")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>   drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index f46a131b5c..744f3c30d2 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -696,11 +696,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
>   	dev->frontend_features = 0;
>   	dev->unsupported_features = 0;
>   	dev->backend_type = backend_type;
> -
> -	if (*ifname) {
> -		dev->ifname = *ifname;
> -		*ifname = NULL;
> -	}
> +	dev->ifname = *ifname;
>   
>   	if (virtio_user_dev_setup(dev) < 0) {
>   		PMD_INIT_LOG(ERR, "(%s) backend set up fails", dev->path);
> @@ -794,6 +790,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
>   		}
>   	}
>   
> +	*ifname = NULL;
>   	return 0;
>   
>   notify_uninit:


Applied to dpdk-next-virtio/main.

Thanks,
Maxime


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

end of thread, other threads:[~2023-06-01 20:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 10:10 [PATCH] net/virtio-user: fix leak when initialisation fails David Marchand
2023-04-17  6:43 ` Maxime Coquelin
2023-04-18 18:15 ` Tyler Retzlaff
2023-06-01 20:00 ` Maxime Coquelin

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