diff options
| author | Eric Auger <eric.auger@redhat.com> | 2024-07-01 10:48:54 +0200 |
|---|---|---|
| committer | Cédric Le Goater <clg@redhat.com> | 2024-07-09 11:50:37 +0200 |
| commit | 3966bca539967a05b3256549eb00f9488c2790e6 (patch) | |
| tree | cf5cf609fe193c1f277607e16efa4262f5cdd98a /hw/vfio/iommufd.c | |
| parent | 37baedf8e8a78cf799956447e40da79b967882bb (diff) | |
| download | focaccia-qemu-3966bca539967a05b3256549eb00f9488c2790e6.tar.gz focaccia-qemu-3966bca539967a05b3256549eb00f9488c2790e6.zip | |
vfio-container-base: Introduce vfio_container_get_iova_ranges() helper
Introduce vfio_container_get_iova_ranges() to retrieve the usable
IOVA regions of the base container and use it in the Host IOMMU
device implementations of get_iova_ranges() callback.
We also fix a UAF bug as the list was shallow copied while
g_list_free_full() was used both on the single call site, in
virtio_iommu_set_iommu_device() but also in
vfio_container_instance_finalize(). Instead use g_list_copy_deep.
Fixes: cf2647a76e ("virtio-iommu: Compute host reserved regions")
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Suggested-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/vfio/iommufd.c')
| -rw-r--r-- | hw/vfio/iommufd.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index c2f158e603..890d8d6a38 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -647,15 +647,9 @@ static GList * hiod_iommufd_vfio_get_iova_ranges(HostIOMMUDevice *hiod, Error **errp) { VFIODevice *vdev = hiod->agent; - GList *l = NULL; g_assert(vdev); - - if (vdev->bcontainer) { - l = g_list_copy(vdev->bcontainer->iova_ranges); - } - - return l; + return vfio_container_get_iova_ranges(vdev->bcontainer); } static void hiod_iommufd_vfio_class_init(ObjectClass *oc, void *data) |