Skip to content

Various virtio-gpu/dmabuf related fixes

Marc-André Lureau qemu-devel 4 versions – In review

Get series with b4
b4 am [email protected] change-id 20260825-virtio-gpu-cleanup-dfb2ba185936

Versions newest first

  1. v4 Latest24 patches 9 repliesIn review
  2. v324 patches 3 repliesSuperseded
  3. v225 patches 26 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v118 patches12 repliesSuperseded

Changes in v4 from the cover letter

- replaced "ui: make GL context current before releasing DMA-BUF
textures" with more complete "ui: make GL context current in display
backend callbacks"
- rebase, drop eof line leftover, collect rb trailer
- Link to v3: https://lore.kernel.org/qemu-devel/[email protected]

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/24virtio-gpu: disable blob scanouts on mapping cleanuphw/display/virtio-gpu.c+10 -00 replies
2/24virtio-gpu: clear res->blob on mapping cleanuphw/display/virtio-gpu-udmabuf.c hw/display/virtio-gpu.c+11 -20 replies
3/24hw/display/virtio-gpu: introduce virtio_gpu_{simple,virgl}_resource_new()hw/display/virtio-gpu-rutabaga.c hw/display/virtio-gpu-virgl.c hw/display/virtio-gpu.c +1 more+97 -490 replies
4/24virtio-gpu/virgl: free BHs and timers on renderer resethw/display/virtio-gpu-virgl.c+6 -00 replies
5/24hw/display/virtio-gpu: set share_handle for udmabuf blob resourceshw/display/virtio-gpu-udmabuf.c+3 -00 replies
6/24ui/gtk: move GL fence tracking from QemuDmaBuf to VirtualGfxConsoleinclude/ui/dmabuf.h include/ui/egl-helpers.h include/ui/gtk.h +5 more+57 -760 replies
7/24ui/gtk: move draw_submitted from QemuDmaBuf to VirtualGfxConsoleinclude/ui/dmabuf.h include/ui/gtk.h ui/dmabuf.c +3 more+13 -280 replies
8/24ui/dbus: disable scanout iff dmabuf is currentui/dbus-listener.c+48 -200 replies
9/24virtio-gpu: store the scanout DMABUF in virtio_gpu_scanouthw/display/virtio-gpu-udmabuf.c include/hw/virtio/virtio-gpu.h+25 -550 replies
10/24ui/console: disable GL scanout when dmabuf is the active oneui/console.c+3 -00 replies
11/24ui/sdl2: clear guest_fb.dmabuf on releaseui/sdl2-gl.c+5 -00 replies
12/24ui/dmabuf: own and close fds on freehw/display/vhost-user-gpu.c hw/display/virtio-gpu-udmabuf-stubs.c hw/display/virtio-gpu-udmabuf.c +6 more+20 -460 replies
13/24ui: make GL context current in display backend callbackshw/display/virtio-gpu-virgl.c include/ui/gtk.h ui/egl-headless.c +5 more+57 -96 replies
14/24virtio-gpu: release the dmabuf when a scanout is disabledhw/display/virtio-gpu.c+15 -40 replies
15/24contrib/vhost-user-gpu: drop scanout_bitmask bookkeepingcontrib/vhost-user-gpu/vhost-user-gpu.c+7 -210 replies
16/24virtio-gpu-rutabaga: fix scanout handlinghw/display/virtio-gpu-rutabaga.c+17 -30 replies
17/24virtio-gpu: drop scanout_bitmask bookkeepinghw/display/virtio-gpu.c include/hw/virtio/virtio-gpu.h+5 -220 replies
18/24virtio-gpu: release dmabuf when switching to a surfacehw/display/virtio-gpu.c+9 -40 replies
19/24virtio-gpu/virgl: release dmabuf when a texture replaces a scanouthw/display/virtio-gpu-virgl.c hw/display/virtio-gpu.c include/hw/virtio/virtio-gpu.h+6 -10 replies
20/24virtio-gpu: consolidate disabling scanouthw/display/virtio-gpu-rutabaga.c hw/display/virtio-gpu-virgl.c hw/display/virtio-gpu.c+7 -93 replies
21/24virtio-gpu: minor refactoringhw/display/virtio-gpu-virgl.c+36 -350 replies
22/24virtio-gpu/virgl: disable scanouts on resource unrefhw/display/virtio-gpu-virgl.c+8 -00 replies
23/24virtio-gpu: extract virtio_gpu_disable_scanout_for_resource helperhw/display/virtio-gpu-rutabaga.c hw/display/virtio-gpu-virgl.c hw/display/virtio-gpu.c +1 more+16 -260 replies
24/24contrib/vhost-user-gpu: disable scanouts on resource unrefcontrib/vhost-user-gpu/virgl.c+12 -00 replies

Reviews trailers per patch

All 24 patches have a Reviewed-by or Acked-by.

PatchAkihiko OdakiDaniel P. Berrangé
1/24R-b
2/24R-b
3/24R-b
4/24R-b
5/24R-b R-b
6/24R-b
7/24R-b
8/24R-b
9/24R-b
10/24R-b
11/24R-b
12/24R-b
13/24R-b
14/24R-b
15/24R-b
16/24R-b
17/24R-b
18/24R-b
19/24R-b
20/24R-b
21/24R-b
22/24R-b
23/24R-b
24/24R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 00/24] Various virtio-gpu/dmabuf related fixes

Hi,

While working on CVE-2026-66020 (which had a few revision on list), I kept finding several places where virtio-gpu scanout and dmabuf ownership was unclear.

The CVE comes from using a blob after RESOURCE_DETACH_BACKING has unmapped its memory. Following that path also found stale dmabuf references, duplicated scanout bookkeeping, and inconsistent cleanup between display backends.

Those changes touch a lot of area and I have done basic testing with the various backends. I would not recommend backporting them all to stable. The first 2 patches address CVE-2026-66020 in the general case and should be safe to backport.

thanks

---
Changes in v4:
- replaced "ui: make GL context current before releasing DMA-BUF
textures" with more complete "ui: make GL context current in display
backend callbacks"
- rebase, drop eof line leftover, collect rb trailer
- Link to v3: https://lore.kernel.org/qemu-devel/[email protected]

Changes in v3:
- updated "virtio-gpu: fix use-after-free on blob cursor", now "clear res->blob on mapping cleanup"
- always disable GL when clearning scanout in "virtio-gpu: consolidate disabling scanout"
- drop "vhost-user-gpu: release DMA-BUFs on scanout disable" for now
- rebased, collect rb trailers
- Link to v2: https://lore.kernel.org/qemu-devel/[email protected]

Changes in v2: addresses Akihiko review
- reorder to have CVE fix first, easily back-portable (but also more
limited fix)
- include virtio_gpu_{simple,virgl}_resource_new() patch, and other sent
separately
- move draw_submitted from QemuDmaBuf to VirtualGfxConsole
- contrib/vhost-user-gpu: disable scanouts on resource unref
- drop rfc, collect rb, adjust commit messages
- Link to v1: https://lore.kernel.org/qemu-devel/[email protected]

---
Marc-André Lureau (24):
virtio-gpu: disable blob scanouts on mapping cleanup
virtio-gpu: clear res->blob on mapping cleanup hw/display/virtio-gpu: introduce virtio_gpu_{simple,virgl}_resource_new() virtio-gpu/virgl: free BHs and timers on renderer reset hw/display/virtio-gpu: set share_handle for udmabuf blob resources ui/gtk: move GL fence tracking from QemuDmaBuf to VirtualGfxConsole ui/gtk: move draw_submitted from QemuDmaBuf to VirtualGfxConsole ui/dbus: disable scanout iff dmabuf is current
virtio-gpu: store the scanout DMABUF in virtio_gpu_scanout ui/console: disable GL scanout when dmabuf is the active one ui/sdl2: clear guest_fb.dmabuf on release
ui/dmabuf: own and close fds on free
ui: make GL context current in display backend callbacks
virtio-gpu: release the dmabuf when a scanout is disabled contrib/vhost-user-gpu: drop scanout_bitmask bookkeeping
virtio-gpu-rutabaga: fix scanout handling
virtio-gpu: drop scanout_bitmask bookkeeping
virtio-gpu: release dmabuf when switching to a surface virtio-gpu/virgl: release dmabuf when a texture replaces a scanout
virtio-gpu: consolidate disabling scanout
virtio-gpu: minor refactoring
virtio-gpu/virgl: disable scanouts on resource unref
virtio-gpu: extract virtio_gpu_disable_scanout_for_resource helper contrib/vhost-user-gpu: disable scanouts on resource unref

 contrib/vhost-user-gpu/vhost-user-gpu.c |  28 ++----
 contrib/vhost-user-gpu/virgl.c          |  12 +++
 hw/display/vhost-user-gpu.c             |   1 -
 hw/display/virtio-gpu-rutabaga.c        |  38 ++++----
 hw/display/virtio-gpu-udmabuf-stubs.c   |   2 +-
 hw/display/virtio-gpu-udmabuf.c         |  89 ++++++-------------
 hw/display/virtio-gpu-virgl.c           | 135 +++++++++++++++++-----------
 hw/display/virtio-gpu.c                 | 150 +++++++++++++++++++++-----------
 hw/vfio/display.c                       |   1 -
 include/hw/virtio/virtio-gpu.h          |  31 ++++---
 include/ui/dmabuf.h                     |   7 --
 include/ui/egl-helpers.h                |   4 +-
 include/ui/gtk.h                        |  14 ++-
 ui/console.c                            |   3 +
 ui/dbus-listener.c                      |  69 ++++++++++-----
 ui/dmabuf.c                             |  65 ++------------
 ui/egl-headless.c                       |  17 ++++
 ui/egl-helpers.c                        |  15 ++--
 ui/gtk-egl.c                            |  55 +++++++-----
 ui/gtk-gl-area.c                        |  33 ++++---
 ui/gtk.c                                |  43 +++++----
 ui/sdl2-gl.c                            |   7 ++
 ui/spice-display.c                      |   2 +
 23 files changed, 452 insertions(+), 369 deletions(-)

---
base-commit: 1df256f5968e9f7c3c4533a1383b071c044a36d6
change-id: 20260825-virtio-gpu-cleanup-dfb2ba185936

Best regards,

Signature · 1 line
Marc-André Lureau <[email protected]>