From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: stefanha@redhat.com, "Michael S. Tsirkin" <mst@redhat.com>,
"Stefano Garzarella" <sgarzare@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [GIT PULL v2 3/9] vhost-user-gpu: fix integer overflow in buffer allocation
Date: Tue, 04 Aug 2026 23:21:50 +0400 [thread overview]
Message-ID: <20260804-fix-v2-3-70e8fe489c9e@redhat.com> (raw)
In-Reply-To: <20260804-fix-v2-0-70e8fe489c9e@redhat.com>
A malicious guest can trigger a heap buffer overflow in the
vhost-user-gpu backend by sending a VIRTIO_GPU_CMD_RESOURCE_CREATE_2D
with large width and height values (e.g. 65537x65537). The allocation
size width * height * 4 silently wraps in uint32_t arithmetic,
resulting in a much smaller allocation than expected. Subsequent
VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D writes past the heap buffer.
The in-tree virtio-gpu device (hw/display/virtio-gpu.c) already handles
this via calc_image_hostmem() with uint64_t arithmetic and an overflow
check. Apply the same approach to the vhost-user-gpu contrib backend:
- Add an overflow check in vugbm_buffer_create() rejecting dimensions
where width * height * 4 exceeds UINT32_MAX
- Promote the size arithmetic to uint64_t in mem_alloc_bo() and
udmabuf_get_size()
- Check the return value of vugbm_buffer_create() in
vg_resource_create_2d(), which was previously ignored
Fixes: CVE-2026-15264
Reported-by: "Vulnerability Report" <vr@darknavy.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3940
Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com>
Acked-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260710134720.2317856-1-marcandre.lureau@redhat.com>
---
contrib/vhost-user-gpu/vhost-user-gpu.c | 8 +++++++-
contrib/vhost-user-gpu/vugbm.c | 11 +++++++++--
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c
index bb41758e3454..ee9858c397ce 100644
--- a/contrib/vhost-user-gpu/vhost-user-gpu.c
+++ b/contrib/vhost-user-gpu/vhost-user-gpu.c
@@ -388,7 +388,13 @@ vg_resource_create_2d(VuGpu *g,
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
return;
}
- vugbm_buffer_create(&res->buffer, &g->gdev, c2d.width, c2d.height);
+ if (!vugbm_buffer_create(&res->buffer, &g->gdev, c2d.width, c2d.height)) {
+ g_critical("%s: buffer creation failed %d %d %d",
+ __func__, c2d.resource_id, c2d.width, c2d.height);
+ g_free(res);
+ cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;
+ return;
+ }
res->image = pixman_image_create_bits(pformat,
c2d.width,
c2d.height,
diff --git a/contrib/vhost-user-gpu/vugbm.c b/contrib/vhost-user-gpu/vugbm.c
index 503d0a4566f8..710d54529779 100644
--- a/contrib/vhost-user-gpu/vugbm.c
+++ b/contrib/vhost-user-gpu/vugbm.c
@@ -13,7 +13,7 @@
static bool
mem_alloc_bo(struct vugbm_buffer *buf)
{
- buf->mmap = g_malloc(buf->width * buf->height * 4);
+ buf->mmap = g_malloc((uint64_t)buf->width * buf->height * 4);
buf->stride = buf->width * 4;
return true;
}
@@ -53,7 +53,8 @@ struct udmabuf_create {
static size_t
udmabuf_get_size(struct vugbm_buffer *buf)
{
- return ROUND_UP(buf->width * buf->height * 4, qemu_real_host_page_size());
+ return ROUND_UP((uint64_t)buf->width * buf->height * 4,
+ qemu_real_host_page_size());
}
static bool
@@ -293,6 +294,12 @@ bool
vugbm_buffer_create(struct vugbm_buffer *buffer, struct vugbm_device *dev,
uint32_t width, uint32_t height)
{
+ uint64_t size = (uint64_t)width * height * 4;
+ if (size > UINT32_MAX) {
+ g_warning("buffer dimensions too large: %ux%u", width, height);
+ return false;
+ }
+
buffer->dev = dev;
buffer->width = width;
buffer->height = height;
--
2.55.0
next prev parent reply other threads:[~2026-08-04 19:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 7:18 [GIT PULL 0/9] Fixes for 11.1-rc Marc-André Lureau
2026-08-04 7:18 ` [GIT PULL 1/9] hw/display/virtio-gpu: validate blob iov size Marc-André Lureau
2026-08-04 7:18 ` [GIT PULL 2/9] hw/display/vga: fix panning_buf OOB after text/graphics switch Marc-André Lureau
2026-08-04 7:18 ` [GIT PULL 3/9] vhost-user-gpu: fix integer overflow in buffer allocation Marc-André Lureau
2026-08-04 7:18 ` [GIT PULL 4/9] hw/display/virtio-gpu: fix offset wraparound in scanout_blob_to_fb Marc-André Lureau
2026-08-04 7:18 ` [GIT PULL 5/9] hw/display/virtio-gpu: drop redundant node->value NULL checks Marc-André Lureau
2026-08-04 7:18 ` [GIT PULL 6/9] virtio-gpu: reject requests with short/truncated control headers Marc-André Lureau
2026-08-04 7:18 ` [GIT PULL 7/9] hw/display/virtio-gpu: Always reject invalid scanout bounds Marc-André Lureau
2026-08-04 7:18 ` [GIT PULL 8/9] hw/display/virtio-gpu: Unmap DMA regions on reset Marc-André Lureau
2026-08-04 7:18 ` [GIT PULL 9/9] qapi/dump: add allowed-by-guest feature to win-dmp Marc-André Lureau
2026-08-04 19:07 ` [GIT PULL 0/9] Fixes for 11.1-rc Marc-André Lureau
2026-08-04 19:21 ` [GIT PULL v2 " Marc-André Lureau
2026-08-04 19:21 ` [GIT PULL v2 1/9] hw/display/virtio-gpu: validate blob iov size Marc-André Lureau
2026-08-04 19:21 ` [GIT PULL v2 2/9] hw/display/vga: fix panning_buf OOB after text/graphics switch Marc-André Lureau
2026-08-04 19:21 ` Marc-André Lureau [this message]
2026-08-04 19:21 ` [GIT PULL v2 4/9] hw/display/virtio-gpu: fix offset wraparound in scanout_blob_to_fb Marc-André Lureau
2026-08-04 19:21 ` [GIT PULL v2 5/9] hw/display/virtio-gpu: drop redundant node->value NULL checks Marc-André Lureau
2026-08-04 19:21 ` [GIT PULL v2 6/9] virtio-gpu: reject requests with short/truncated control headers Marc-André Lureau
2026-08-04 19:21 ` [GIT PULL v2 7/9] hw/display/virtio-gpu: Always reject invalid scanout bounds Marc-André Lureau
2026-08-04 19:21 ` [GIT PULL v2 8/9] hw/display/virtio-gpu: Unmap DMA regions on reset Marc-André Lureau
2026-08-04 19:21 ` [GIT PULL v2 9/9] qapi/dump: add allowed-by-guest feature to win-dmp Marc-André Lureau
2026-08-05 0:55 ` [GIT PULL v2 0/9] Fixes for 11.1-rc Stefan Hajnoczi
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=20260804-fix-v2-3-70e8fe489c9e@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
/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.