Skip to contentSkip to conversation

hw/virtio: vdpa: Fix leak of host-notifier memory-region

PATCH In review Laurent Vivier 4 participants 6 messages Feb 11, 2022 – Feb 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/virtio: vdpa: Fix leak of host-notifier memory-region

If call virtio_queue_set_host_notifier_mr fails, should free host-notifier memory-region.

This problem can trigger a coredump with some vDPA drivers (mlx5, but not with the vdpasim), if we unplug the virtio-net card from the guest after a stop/start.

The same fix has been done for vhost-user:
1f89d3b91e3e ("hw/virtio: Fix leak of host-notifier memory-region")

Fixes d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possible")

Resolves: https://bugzilla.redhat.com/2027208

---
 hw/virtio/vhost-vdpa.c | 1 +
 1 file changed, 1 insertion(+)
hw/virtio/vhost-vdpa.c +1 -0
index 04ea43704f5d..11f696468dc1 100644
@@ -431,6 +431,7 @@ static int vhost_vdpa_host_notifier_init(struct vhost_dev *dev, int queue_index)
     g_free(name);
 
     if (virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, true)) {
+        object_unparent(OBJECT(&n->mr));
         munmap(addr, page_size);
         goto err;
     }
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Laurent Vivier

If call virtio_queue_set_host_notifier_mr fails, should free host-notifier memory-region.

This problem can trigger a coredump with some vDPA drivers (mlx5, but not with the vdpasim), if we unplug the virtio-net card from the guest after a stop/start.

Quoted 7 lines

The same fix has been done for vhost-user:
1f89d3b91e3e ("hw/virtio: Fix leak of host-notifier memory-region")

Fixes d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possible")

Resolves: https://bugzilla.redhat.com/2027208

Quoted 19 lines
---
 hw/virtio/vhost-vdpa.c | 1 +
 1 file changed, 1 insertion(+)
hw/virtio/vhost-vdpa.c +1 -1
index 04ea43704f5d..11f696468dc1 100644
@@ -431,6 +431,7 @@ static int vhost_vdpa_host_notifier_init(struct vhost_dev *dev, int queue_index)
     g_free(name);
 
     if (virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, true)) {
+        object_unparent(OBJECT(&n->mr));
         munmap(addr, page_size);
         goto err;
     }
--

2.34.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Laurent Vivier
Quoted 10 lines · Laurent Vivier

If call virtio_queue_set_host_notifier_mr fails, should free host-notifier memory-region.

This problem can trigger a coredump with some vDPA drivers (mlx5, but not with the vdpasim), if we unplug the virtio-net card from the guest after a stop/start.

The same fix has been done for vhost-user:
1f89d3b91e3e ("hw/virtio: Fix leak of host-notifier memory-region")

Quoted 7 lines
Fixes d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possible")

Resolves: https://bugzilla.redhat.com/2027208

---
hw/virtio/vhost-vdpa.c | 1 +

1 file changed, 1 insertion(+)
Quoted 17 lines
hw/virtio/vhost-vdpa.c +1 -0
index 04ea43704f5d..11f696468dc1 100644
@@ -431,6 +431,7 @@ static int vhost_vdpa_host_notifier_init(struct vhost_dev *dev, int queue_index)
    g_free(name);
 
    if (virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, true)) {
+        object_unparent(OBJECT(&n->mr));
        munmap(addr, page_size);
        goto err;
    }
Signature · 1 line
2.34.1
#3 lore raw
In reply to Laurent Vivier

Michael,

do you plan to merge this soon?

This is a bugfix for a QEMU coredump.

Thanks,
Laurent

Quoted 30 lines · Laurent Vivier

If call virtio_queue_set_host_notifier_mr fails, should free host-notifier memory-region.

This problem can trigger a coredump with some vDPA drivers (mlx5, but not with the vdpasim), if we unplug the virtio-net card from the guest after a stop/start.

The same fix has been done for vhost-user:
1f89d3b91e3e ("hw/virtio: Fix leak of host-notifier memory-region")

Fixes d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possible")

Resolves: https://bugzilla.redhat.com/2027208

---
  hw/virtio/vhost-vdpa.c | 1 +
  1 file changed, 1 insertion(+)
hw/virtio/vhost-vdpa.c +1 -0
index 04ea43704f5d..11f696468dc1 100644
@@ -431,6 +431,7 @@ static int vhost_vdpa_host_notifier_init(struct vhost_dev *dev, int queue_index)
      g_free(name);
 
      if (virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, true)) {
+        object_unparent(OBJECT(&n->mr));
          munmap(addr, page_size);
          goto err;
      }
#4 lore raw

Ping?

Thanks,
Laurent

Quoted 41 lines · Laurent Vivier

Michael,

do you plan to merge this soon?

This is a bugfix for a QEMU coredump.

Thanks,
Laurent

Quoted 30 lines · Laurent Vivier

If call virtio_queue_set_host_notifier_mr fails, should free host-notifier memory-region.

This problem can trigger a coredump with some vDPA drivers (mlx5, but not with the vdpasim), if we unplug the virtio-net card from the guest after a stop/start.

The same fix has been done for vhost-user:
   1f89d3b91e3e ("hw/virtio: Fix leak of host-notifier memory-region")

Fixes d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possible")

Resolves: https://bugzilla.redhat.com/2027208

---
  hw/virtio/vhost-vdpa.c | 1 +

  1 file changed, 1 insertion(+)
hw/virtio/vhost-vdpa.c +1 -0
index 04ea43704f5d..11f696468dc1 100644
@@ -431,6 +431,7 @@ static int vhost_vdpa_host_notifier_init(struct vhost_dev *dev, int 
 queue_index)
       g_free(name);
       if (virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, true)) {
+        object_unparent(OBJECT(&n->mr));
           munmap(addr, page_size);
           goto err;
       }
#5 lore raw

yes - in the next pull, thanks!

Quoted 47 lines · Laurent Vivier

Ping?

Thanks,
Laurent

Quoted 41 lines · Laurent Vivier

Michael,

do you plan to merge this soon?

This is a bugfix for a QEMU coredump.

Thanks,
Laurent

Quoted 30 lines · Laurent Vivier

If call virtio_queue_set_host_notifier_mr fails, should free host-notifier memory-region.

This problem can trigger a coredump with some vDPA drivers (mlx5, but not with the vdpasim), if we unplug the virtio-net card from the guest after a stop/start.

The same fix has been done for vhost-user:
   1f89d3b91e3e ("hw/virtio: Fix leak of host-notifier memory-region")

Fixes d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possible")

Resolves: https://bugzilla.redhat.com/2027208

---
  hw/virtio/vhost-vdpa.c | 1 +

  1 file changed, 1 insertion(+)
hw/virtio/vhost-vdpa.c +1 -0
index 04ea43704f5d..11f696468dc1 100644
@@ -431,6 +431,7 @@ static int vhost_vdpa_host_notifier_init(struct
 vhost_dev *dev, int queue_index)
       g_free(name);
       if (virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, true)) {
+        object_unparent(OBJECT(&n->mr));
           munmap(addr, page_size);
           goto err;
       }