hw/virtio/virtio-iommu: Reject inverted MAP range
PATCH 1/1 hw/virtio/virtio-iommu: Reject inverted MAP range
virtio_iommu_map() did not check that virt_end >= virt_start. An inverted range corrupts the GTree comparator contract (interval_cmp returns non-zero for a key compared with itself), causing an infinite loop in virtio_iommu_unmap() while holding s->mutex.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4104
Signed-off-by Bin Guo <[email protected]>
--- hw/virtio/virtio-iommu.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/virtio/virtio-iommu.c +4 -0
@@ -807,6 +807,10 @@ static int virtio_iommu_map(VirtIOIOMMU *s,return VIRTIO_IOMMU_S_INVAL ; } +if (virt_end < virt_start) { +return VIRTIO_IOMMU_S_INVAL ; + } + domain =g_tree_lookup (s->domains,GUINT_TO_POINTER (domain_id));if (!domain) {return VIRTIO_IOMMU_S_NOENT ;
Signature · 1 line
2.50.1 (Apple Git-155)
Quoted 8 lines · Bin Guo
virtio_iommu_map()did not check thatvirt_end>=virt_start. An inverted range corrupts the GTree comparator contract (interval_cmpreturns non-zero for a key compared with itself), causing an infinite loop invirtio_iommu_unmap()while holdings->mutex.Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4104
Signed-off-by Bin Guo <[email protected]>
Same as [email protected] ?
Quoted 21 lines
--- hw/virtio/virtio-iommu.c | 4 ++++ 1 file changed, 4 insertions(+)hw/virtio/virtio-iommu.c +4
-0@@ -807,6 +807,10 @@ static int virtio_iommu_map(VirtIOIOMMU *s,return VIRTIO_IOMMU_S_INVAL ; } +if (virt_end < virt_start) { +return VIRTIO_IOMMU_S_INVAL ; + } + domain =g_tree_lookup (s->domains,GUINT_TO_POINTER (domain_id));if (!domain) {return VIRTIO_IOMMU_S_NOENT ;Signature · 1 line
2.50.1 (Apple Git-155)