Skip to contentSkip to conversation

hw/vfio/container: Fix SIGSEV on vfio_container_instance_finalize()

PATCH Applied Eric Auger 3 participants 4 messages Jul 19, 2024 – Jul 22, 2024

lore
Share & tools
lore

Eric Auger

author
#0 lore raw

PATCH 1/1 hw/vfio/container: Fix SIGSEV on vfio_container_instance_finalize()

In vfio_connect_container's error path, the base container is removed twice form the VFIOAddressSpace QLIST: first on the listener_release_exit label and second, on free_container_exit label, through object_unref(container), which calls vfio_container_instance_finalize().

Let's remove the first instance.

Fixes 938026053f4 ("vfio/container: Switch to QOM")
---
 hw/vfio/container.c | 1 -
 1 file changed, 1 deletion(-)
hw/vfio/container.c +0 -1
index 425db1a14c..d8b7c533af 100644
@@ -657,7 +657,6 @@ static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as,
     return true;
 listener_release_exit:
     QLIST_REMOVE(group, container_next);
-    QLIST_REMOVE(bcontainer, next);
     vfio_kvm_device_del_group(group);
     memory_listener_unregister(&bcontainer->listener);
     if (vioc->release) {
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric Auger

In vfio_connect_container's error path, the base container is removed twice form the VFIOAddressSpace QLIST: first on the listener_release_exit label and second, on free_container_exit label, through object_unref(container), which calls vfio_container_instance_finalize().

Let's remove the first instance.

Fixes 938026053f4 ("vfio/container: Switch to QOM")

Oh. Nice catch !

Thanks,

C.

Quoted 16 lines
---
  hw/vfio/container.c | 1 -
  1 file changed, 1 deletion(-)
hw/vfio/container.c +0 -1
index 425db1a14c..d8b7c533af 100644
@@ -657,7 +657,6 @@ static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as,
      return true;
  listener_release_exit:
      QLIST_REMOVE(group, container_next);
-    QLIST_REMOVE(bcontainer, next);
      vfio_kvm_device_del_group(group);
      memory_listener_unregister(&bcontainer->listener);
      if (vioc->release) {
Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Auger
Quoted 13 lines

-----Original Message-----
From: Eric Auger <[email protected]>
Subject: [PATCH] hw/vfio/container: Fix SIGSEV on
vfio_container_instance_finalize()

In vfio_connect_container's error path, the base container is removed twice form the VFIOAddressSpace QLIST: first on the listener_release_exit label and second, on free_container_exit label, through object_unref(container), which calls vfio_container_instance_finalize().

Quoted 4 lines

Let's remove the first instance.

Fixes 938026053f4 ("vfio/container: Switch to QOM")

Thanks
Zhenzhong

Quoted 19 lines

---
hw/vfio/container.c | 1 -

1 file changed, 1 deletion(-)
hw/vfio/container.c +0 -0
index 425db1a14c..d8b7c533af 100644
@@ -657,7 +657,6 @@ static bool vfio_connect_container(VFIOGroup
 *group, AddressSpace *as,
    return true;

listener_release_exit:

    QLIST_REMOVE(group, container_next);
-    QLIST_REMOVE(bcontainer, next);
    vfio_kvm_device_del_group(group);
    memory_listener_unregister(&bcontainer->listener);
    if (vioc->release) {

--
2.41.0

#3 lore raw
In reply to Eric Auger
Quoted 19 lines · Eric Auger

In vfio_connect_container's error path, the base container is removed twice form the VFIOAddressSpace QLIST: first on the listener_release_exit label and second, on free_container_exit label, through object_unref(container), which calls vfio_container_instance_finalize().

Let's remove the first instance.

Fixes 938026053f4 ("vfio/container: Switch to QOM")
---
  hw/vfio/container.c | 1 -
  1 file changed, 1 deletion(-)
hw/vfio/container.c +0 -0
index 425db1a14c..d8b7c533af 100644

hw/vfio/container.c static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as, · line 662

Quoted 7 lines
hw/vfio/container.c +0 -1
@@ -657,7 +657,6 @@ static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as,
      return true;
  listener_release_exit:
      QLIST_REMOVE(group, container_next);
-    QLIST_REMOVE(bcontainer, next);
      vfio_kvm_device_del_group(group);
      memory_listener_unregister(&bcontainer->listener);
      if (vioc->release) {

Applied to vfio-next.

Thanks,

C.