All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Guo <guobin@linux.alibaba.com>
To: qemu-devel@nongnu.org
Cc: Eric Auger <eric.auger@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	qemu-stable@nongnu.org
Subject: [PATCH] hw/virtio/virtio-iommu: Reject inverted MAP range
Date: Mon,  3 Aug 2026 17:43:02 +0800	[thread overview]
Message-ID: <20260803094302.95228-1-guobin@linux.alibaba.com> (raw)

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
Cc: qemu-stable@nongnu.org
Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
---
 hw/virtio/virtio-iommu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index 533bd5073f..cc863e90d2 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -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;
-- 
2.50.1 (Apple Git-155)



             reply	other threads:[~2026-08-03  9:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03  9:43 Bin Guo [this message]
2026-08-03 10:25 ` [PATCH] hw/virtio/virtio-iommu: Reject inverted MAP range Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260803094302.95228-1-guobin@linux.alibaba.com \
    --to=guobin@linux.alibaba.com \
    --cc=eric.auger@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.