* [PATCH] virtio-pci: fix vector_irqfd leak in virtio_pci_set_guest_notifiers
@ 2022-08-09 0:25 Lei Xiang
2022-08-26 3:06 ` [RESEND PATCH] " leixiang
0 siblings, 1 reply; 7+ messages in thread
From: Lei Xiang @ 2022-08-09 0:25 UTC (permalink / raw)
To: mst; +Cc: qemu-devel, xieming, Lei Xiang, Lei Xiang
From: Lei Xiang <ninollx@hotmail.com>
proxy->vector_irqfd did not free when set guest notifier failed.
Signed-off-by: Lei Xiang <leixiang@kylinos.cn>
Tested-by: Zeng Chi <zengchi@kylinos.cn>
Suggested-by: Xie Ming <xieming@kylinos.cn>
---
hw/virtio/virtio-pci.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 45327f0..75188a9 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1058,6 +1058,10 @@ assign_error:
while (--n >= 0) {
virtio_pci_set_guest_notifier(d, n, !assign, with_irqfd);
}
+
+ g_free(proxy->vector_irqfd);
+ proxy->vector_irqfd = NULL;
+
return r;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RESEND PATCH] virtio-pci: fix vector_irqfd leak in virtio_pci_set_guest_notifiers
2022-08-09 0:25 [PATCH] virtio-pci: fix vector_irqfd leak in virtio_pci_set_guest_notifiers Lei Xiang
@ 2022-08-26 3:06 ` leixiang
2022-11-30 5:52 ` leixiang
2022-11-30 5:56 ` leixiang
0 siblings, 2 replies; 7+ messages in thread
From: leixiang @ 2022-08-26 3:06 UTC (permalink / raw)
To: mst; +Cc: qemu-devel, xieming, leixiang, Zeng Chi
proxy->vector_irqfd did not free when set guest notifier failed.
Signed-off-by: Lei Xiang <leixiang@kylinos.cn>
Tested-by: Zeng Chi <zengchi@kylinos.cn>
Suggested-by: Xie Ming <xieming@kylinos.cn>
---
hw/virtio/virtio-pci.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index c6b47a9c..4862f83b 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1038,6 +1038,12 @@ assign_error:
while (--n >= 0) {
virtio_pci_set_guest_notifier(d, n, !assign, with_irqfd);
}
+
+ g_free(proxy->vector_irqfd);
+ proxy->vector_irqfd = NULL;
+
return r;
}
--
No virus found
Checked by Hillstone Network AntiVirus
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RESEND PATCH] virtio-pci: fix vector_irqfd leak in virtio_pci_set_guest_notifiers
2022-08-26 3:06 ` [RESEND PATCH] " leixiang
@ 2022-11-30 5:52 ` leixiang
2022-11-30 5:56 ` leixiang
1 sibling, 0 replies; 7+ messages in thread
From: leixiang @ 2022-11-30 5:52 UTC (permalink / raw)
To: leixiang; +Cc: mst, qemu-devel, xieming, zengchi
proxy->vector_irqfd did not free when set guest notifier failed.
Signed-off-by: Lei Xiang <leixiang@kylinos.cn>
Tested-by: Zeng Chi <zengchi@kylinos.cn>
Suggested-by: Xie Ming <xieming@kylinos.cn>
---
hw/virtio/virtio-pci.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index c6b47a9c..4862f83b 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1038,6 +1038,12 @@ assign_error:
while (--n >= 0) {
virtio_pci_set_guest_notifier(d, n, !assign, with_irqfd);
}
+
+ g_free(proxy->vector_irqfd);
+ proxy->vector_irqfd = NULL;
+
return r;
}
--
No virus found
Checked by Hillstone Network AntiVirus
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RESEND PATCH] virtio-pci: fix vector_irqfd leak in virtio_pci_set_guest_notifiers
2022-08-26 3:06 ` [RESEND PATCH] " leixiang
2022-11-30 5:52 ` leixiang
@ 2022-11-30 5:56 ` leixiang
2022-11-30 6:59 ` Michael S. Tsirkin
2022-12-20 14:42 ` Michael S. Tsirkin
1 sibling, 2 replies; 7+ messages in thread
From: leixiang @ 2022-11-30 5:56 UTC (permalink / raw)
To: mst; +Cc: qemu-devel, xieming, zengchi, leixiang
proxy->vector_irqfd did not free when set guest notifier failed.
Signed-off-by: Lei Xiang <leixiang@kylinos.cn>
Tested-by: Zeng Chi <zengchi@kylinos.cn>
Suggested-by: Xie Ming <xieming@kylinos.cn>
---
hw/virtio/virtio-pci.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index c6b47a9c..4862f83b 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1038,6 +1038,12 @@ assign_error:
while (--n >= 0) {
virtio_pci_set_guest_notifier(d, n, !assign, with_irqfd);
}
+
+ g_free(proxy->vector_irqfd);
+ proxy->vector_irqfd = NULL;
+
return r;
}
--
No virus found
Checked by Hillstone Network AntiVirus
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH] virtio-pci: fix vector_irqfd leak in virtio_pci_set_guest_notifiers
2022-11-30 5:56 ` leixiang
@ 2022-11-30 6:59 ` Michael S. Tsirkin
2022-12-20 14:42 ` Michael S. Tsirkin
1 sibling, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2022-11-30 6:59 UTC (permalink / raw)
To: leixiang; +Cc: qemu-devel, xieming, zengchi
On Wed, Nov 30, 2022 at 01:56:11PM +0800, leixiang wrote:
> proxy->vector_irqfd did not free when set guest notifier failed.
>
> Signed-off-by: Lei Xiang <leixiang@kylinos.cn>
> Tested-by: Zeng Chi <zengchi@kylinos.cn>
> Suggested-by: Xie Ming <xieming@kylinos.cn>
Thanks a lot! Fixes tag? When was the leak introduced?
> ---
> hw/virtio/virtio-pci.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index c6b47a9c..4862f83b 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -1038,6 +1038,12 @@ assign_error:
> while (--n >= 0) {
> virtio_pci_set_guest_notifier(d, n, !assign, with_irqfd);
> }
> +
> + g_free(proxy->vector_irqfd);
> + proxy->vector_irqfd = NULL;
> +
> return r;
> }
>
> --
>
>
> No virus found
> Checked by Hillstone Network AntiVirus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH] virtio-pci: fix vector_irqfd leak in virtio_pci_set_guest_notifiers
2022-11-30 5:56 ` leixiang
2022-11-30 6:59 ` Michael S. Tsirkin
@ 2022-12-20 14:42 ` Michael S. Tsirkin
2022-12-27 8:16 ` [RESEND PATCH] virtio-pci: fix proxy->vector_irqfd " leixiang
1 sibling, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2022-12-20 14:42 UTC (permalink / raw)
To: leixiang; +Cc: qemu-devel, xieming, zengchi
On Wed, Nov 30, 2022 at 01:56:11PM +0800, leixiang wrote:
> proxy->vector_irqfd did not free when set guest notifier failed.
Can you pls add a Fixes tag so people know where to backport this?
> Signed-off-by: Lei Xiang <leixiang@kylinos.cn>
> Tested-by: Zeng Chi <zengchi@kylinos.cn>
> Suggested-by: Xie Ming <xieming@kylinos.cn>
Looking at the code I see this:
/* Must set vector notifier after guest notifier has been assigned */
if ((with_irqfd ||
(vdev->use_guest_notifier_mask && k->guest_notifier_mask)) &&
assign) {
if (with_irqfd) {
proxy->vector_irqfd =
g_malloc0(sizeof(*proxy->vector_irqfd) *
msix_nr_vectors_allocated(&proxy->pci_dev));
r = kvm_virtio_pci_vector_vq_use(proxy, nvqs);
if (r < 0) {
goto config_assign_error;
}
r = kvm_virtio_pci_vector_config_use(proxy);
if (r < 0) {
goto config_error;
}
}
r = msix_set_vector_notifiers(&proxy->pci_dev, virtio_pci_vector_unmask,
virtio_pci_vector_mask,
virtio_pci_vector_poll);
if (r < 0) {
goto notifiers_error;
}
}
doesn't this mean g_free belongs at the label config_assign_error?
> ---
> hw/virtio/virtio-pci.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index c6b47a9c..4862f83b 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -1038,6 +1038,12 @@ assign_error:
> while (--n >= 0) {
> virtio_pci_set_guest_notifier(d, n, !assign, with_irqfd);
> }
> +
> + g_free(proxy->vector_irqfd);
> + proxy->vector_irqfd = NULL;
> +
> return r;
> }
>
> --
>
>
> No virus found
> Checked by Hillstone Network AntiVirus
The patch is corrupted. Line counts are wrong, and your antivirus added
trash at the end.
--
MST
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RESEND PATCH] virtio-pci: fix proxy->vector_irqfd leak in virtio_pci_set_guest_notifiers
2022-12-20 14:42 ` Michael S. Tsirkin
@ 2022-12-27 8:16 ` leixiang
0 siblings, 0 replies; 7+ messages in thread
From: leixiang @ 2022-12-27 8:16 UTC (permalink / raw)
To: mst; +Cc: qemu-devel, xieming, zengchi, leixiang
proxy->vector_irqfd did not free when kvm_virtio_pci_vector_use or
msix_set_vector_notifiers failed in virtio_pci_set_guest_notifiers.
Fixes: 7d37d351
Signed-off-by: Lei Xiang <leixiang@kylinos.cn>
Tested-by: Zeng Chi <zengchi@kylinos.cn>
Suggested-by: Xie Ming <xieming@kylinos.cn>
---
hw/virtio/virtio-pci.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index a50c5a57d7..5339be4e01 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1063,6 +1063,8 @@ assign_error:
while (--n >= 0) {
virtio_pci_set_guest_notifier(d, n, !assign, with_irqfd);
}
+ g_free(proxy->vector_irqfd);
+ proxy->vector_irqfd = NULL;
return r;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-12-27 8:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-09 0:25 [PATCH] virtio-pci: fix vector_irqfd leak in virtio_pci_set_guest_notifiers Lei Xiang
2022-08-26 3:06 ` [RESEND PATCH] " leixiang
2022-11-30 5:52 ` leixiang
2022-11-30 5:56 ` leixiang
2022-11-30 6:59 ` Michael S. Tsirkin
2022-12-20 14:42 ` Michael S. Tsirkin
2022-12-27 8:16 ` [RESEND PATCH] virtio-pci: fix proxy->vector_irqfd " leixiang
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).