All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vhost: Reject oversized inflight migration buffers
@ 2026-07-27 12:45 김승중
  2026-07-27 12:48 ` Michael S. Tsirkin
  0 siblings, 1 reply; 4+ messages in thread
From: 김승중 @ 2026-07-27 12:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Stefano Garzarella, Daniel P. Berrangé,
	Mauro Matteo Cascella

The inflight buffer size is migrated as a uint64_t, but vmstate_size()
reads VMS_VBUFFER sizes as int32_t. Values above INT32_MAX therefore
become negative and are converted to a very large size_t while loading
the buffer, allowing writes beyond the smaller memfd-backed mapping.

Reject sizes that cannot be represented by vmstate_size() before
allocating the destination buffer.

Fixes: CVE-2026-6426
Reported-by: Seungjung Kim <seungjung0711@gmail.com>
Signed-off-by: Seungjung Kim <seungjung0711@gmail.com>

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index af41841b52..82eb9407ae 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -2022,11 +2022,18 @@ void vhost_get_features_ex(struct vhost_dev *hdev,
 static bool vhost_inflight_buffer_pre_load(void *opaque, Error **errp)
 {
     struct vhost_inflight *inflight = opaque;
-
     int fd = -1;
-    void *addr = qemu_memfd_alloc("vhost-inflight", inflight->size,
-                                  F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL,
-                                  &fd, errp);
+    void *addr;
+
+    if (inflight->size > INT32_MAX) {
+        error_setg(errp, "inflight buffer size %" PRIu64
+                   " exceeds maximum %d", inflight->size, INT32_MAX);
+        return false;
+    }
+
+    addr = qemu_memfd_alloc("vhost-inflight", inflight->size,
+                            F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL,
+                            &fd, errp);
     if (!addr) {
         return false;
     }
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-27 13:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27 12:45 [PATCH] vhost: Reject oversized inflight migration buffers 김승중
2026-07-27 12:48 ` Michael S. Tsirkin
2026-07-27 13:02   ` 김승중
2026-07-27 13:16     ` Michael S. Tsirkin

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.