[PATCH v2] ui/dbus: fix cursor race, copy cursor data

marcandre.lureau@redhat.com posted 1 patch 3 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260904123020.3108205-1-marcandre.lureau@redhat.com
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>
ui/dbus-listener.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[PATCH v2] ui/dbus: fix cursor race, copy cursor data
Posted by marcandre.lureau@redhat.com 3 weeks, 1 day ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Eliminates the undefined behavior where virtio-gpu's memcpy() overwrites
the buffer that an in-flight gvariant still references. Fixes the data
race where the GDBus worker thread calls cursor_unref() concurrently
with main thread.

Fixes: 142ca628a733 ("ui: add a D-Bus display backend")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/dbus-listener.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c
index 2e2f6ba4183a..a916479044ea 100644
--- a/ui/dbus-listener.c
+++ b/ui/dbus-listener.c
@@ -899,13 +899,11 @@ static void dbus_cursor_define(DisplayChangeListener *dcl,
 
     ddl_discard_cursor_messages(ddl);
 
-    v_data = g_variant_new_from_data(
-        G_VARIANT_TYPE("ay"),
+    v_data = g_variant_new_fixed_array(
+        G_VARIANT_TYPE_BYTE,
         c->data,
         c->width * c->height * 4,
-        TRUE,
-        (GDestroyNotify)cursor_unref,
-        cursor_ref(c));
+        1);
 
     qemu_dbus_display1_listener_call_cursor_define(
         ddl->proxy,
-- 
2.55.0.543.g5ebe2ebe4ea8


Re: [PATCH v2] ui/dbus: fix cursor race, copy cursor data
Posted by Akihiko Odaki 3 weeks, 1 day ago
On 2026/09/04 21:30, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> Eliminates the undefined behavior where virtio-gpu's memcpy() overwrites
> the buffer that an in-flight gvariant still references. Fixes the data
> race where the GDBus worker thread calls cursor_unref() concurrently
> with main thread.
> 
> Fixes: 142ca628a733 ("ui: add a D-Bus display backend")
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>

Regards,
Akihiko Odaki