From f97b4fb02f83eafa9a794218a1e60a2ee823d7d4 Mon Sep 17 00:00:00 2001 From: Yuri Konotopov Date: Sun, 13 Sep 2020 16:10:45 +0400 Subject: [PATCH] net-misc/gnome-remote-desktop: version bump to 0.1.9 Closes: https://github.com/gentoo/gentoo/pull/17520 Signed-off-by: Yuri Konotopov Signed-off-by: Matt Turner --- net-misc/gnome-remote-desktop/Manifest | 1 + ...ome-remote-desktop-0.1.9-copy-pixels.patch | 71 ++++++++++++++++ ...remote-desktop-0.1.9-drop-vnc-frames.patch | 80 +++++++++++++++++++ .../gnome-remote-desktop-0.1.9.ebuild | 54 +++++++++++++ 4 files changed, 206 insertions(+) create mode 100644 net-misc/gnome-remote-desktop/files/gnome-remote-desktop-0.1.9-copy-pixels.patch create mode 100644 net-misc/gnome-remote-desktop/files/gnome-remote-desktop-0.1.9-drop-vnc-frames.patch create mode 100644 net-misc/gnome-remote-desktop/gnome-remote-desktop-0.1.9.ebuild diff --git a/net-misc/gnome-remote-desktop/Manifest b/net-misc/gnome-remote-desktop/Manifest index f16238544fb96..c822985316d5f 100644 --- a/net-misc/gnome-remote-desktop/Manifest +++ b/net-misc/gnome-remote-desktop/Manifest @@ -1,2 +1,3 @@ DIST gnome-remote-desktop-0.1.7.tar.xz 25636 BLAKE2B 00e389bc8887c3d43f9221a45c6c7154e4140fab560c5c568fe92f06794b736efcf2265c763d0d9d57d5343dd2f71b7a3a2c45b0466cdae608f0a609af53175d SHA512 dd20e5e6fd724ff03d8a32319c7145f1fef4331439e52921b812f087e6b83185bf318bb2fb9758fe083ec3cfea30448b601da4ed1aba85fa892ef7fbb794b9ed DIST gnome-remote-desktop-0.1.8.tar.bz2 28565 BLAKE2B 8c14200eb17503eb92c7a7db51d487f17bca7616848aa8f555d2c31a5b758b500d6bbcb78a4a75cebbe0220281079848517c58813783497b463b0a771f07229b SHA512 1e433a95c303ce82782c27412c4f4456f0ecf33eb1e63b61b11f1cde68b6113a765a0f7d7871f73af8a253f1d7b3d3d4dafd36c3e5e9fa6d6c97279747f584ab +DIST gnome-remote-desktop-0.1.9.tar.xz 38040 BLAKE2B aac99424d9c11614f1fd3c9ce1ebe913212489b4c8f3cc22fe5d44b00483cba9cebae8974d221d81a1cbe3e53e85a24f2c5053714fb8b753ada1c034d031752c SHA512 6ac2962c824634cd5322785b6d251e899ea38668010b18b1b50124497895d9c00752904abf01490e27b74e1661aeae39d83fbbd77b841329b1e0fd381c3ea440 diff --git a/net-misc/gnome-remote-desktop/files/gnome-remote-desktop-0.1.9-copy-pixels.patch b/net-misc/gnome-remote-desktop/files/gnome-remote-desktop-0.1.9-copy-pixels.patch new file mode 100644 index 0000000000000..44cecbf6ad609 --- /dev/null +++ b/net-misc/gnome-remote-desktop/files/gnome-remote-desktop-0.1.9-copy-pixels.patch @@ -0,0 +1,71 @@ +From 4d358762948dccdcac6d01f4dd7b8635e53de979 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20=C3=85dahl?= +Date: Mon, 12 Oct 2020 17:34:30 +0200 +Subject: [PATCH] vnc: Copy pixels using the right destination stride + +We're copying the pixels in a separate thread managed by PipeWire, and +in this thread, accessing the VNC framebuffer dimension and stride is +racy. Instead of fetching the dimension directly, pass the expected +width and get the stride it will eventually have. + +Already before this patch, when the copied pixel end up on the main +thread and the dimension still doesn't match up, the frame will be +dropped. +--- + src/grd-session-vnc.c | 5 +++-- + src/grd-session-vnc.h | 3 ++- + src/grd-vnc-pipewire-stream.c | 5 +++-- + 3 files changed, 8 insertions(+), 5 deletions(-) + +diff --git a/src/grd-session-vnc.c b/src/grd-session-vnc.c +index a06d34d..ba3e5ce 100644 +--- a/src/grd-session-vnc.c ++++ b/src/grd-session-vnc.c +@@ -519,9 +519,10 @@ check_rfb_password (rfbClientPtr rfb_client, + } + + int +-grd_session_vnc_get_framebuffer_stride (GrdSessionVnc *session_vnc) ++grd_session_vnc_get_stride_for_width (GrdSessionVnc *session_vnc, ++ int width) + { +- return session_vnc->rfb_screen->paddedWidthInBytes; ++ return width * BGRX_BYTES_PER_PIXEL; + } + + static void +diff --git a/src/grd-session-vnc.h b/src/grd-session-vnc.h +index 07678c8..ee1f986 100644 +--- a/src/grd-session-vnc.h ++++ b/src/grd-session-vnc.h +@@ -55,7 +55,8 @@ void grd_session_vnc_move_cursor (GrdSessionVnc *session_vnc, + int x, + int y); + +-int grd_session_vnc_get_framebuffer_stride (GrdSessionVnc *session_vnc); ++int grd_session_vnc_get_stride_for_width (GrdSessionVnc *session_vnc, ++ int width); + + gboolean grd_session_vnc_is_client_gone (GrdSessionVnc *session_vnc); + +diff --git a/src/grd-vnc-pipewire-stream.c b/src/grd-vnc-pipewire-stream.c +index 96dd7c9..82ceb9b 100644 +--- a/src/grd-vnc-pipewire-stream.c ++++ b/src/grd-vnc-pipewire-stream.c +@@ -326,10 +326,11 @@ process_buffer (GrdVncPipeWireStream *stream, + int height; + int y; + +- src_stride = buffer->datas[0].chunk->stride; +- dst_stride = grd_session_vnc_get_framebuffer_stride (stream->session); + height = stream->spa_format.size.height; + width = stream->spa_format.size.width; ++ src_stride = buffer->datas[0].chunk->stride; ++ dst_stride = grd_session_vnc_get_stride_for_width (stream->session, ++ width); + + frame->data = g_malloc (height * dst_stride); + for (y = 0; y < height; y++) +-- +GitLab + diff --git a/net-misc/gnome-remote-desktop/files/gnome-remote-desktop-0.1.9-drop-vnc-frames.patch b/net-misc/gnome-remote-desktop/files/gnome-remote-desktop-0.1.9-drop-vnc-frames.patch new file mode 100644 index 0000000000000..56ea75ff466d4 --- /dev/null +++ b/net-misc/gnome-remote-desktop/files/gnome-remote-desktop-0.1.9-drop-vnc-frames.patch @@ -0,0 +1,80 @@ +From ab97841629f5f3f4fab9993b6255b6ae04828b9c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20=C3=85dahl?= +Date: Wed, 9 Sep 2020 10:14:20 +0200 +Subject: [PATCH] vnc: Drop frames if client is gone + +Frames from PipeWire are posted asynchronously from a I/O thread to the +main thread where they are turned into VNC frame updates and cursor +movements. On the other hand, sessions are closed asynchronously when +the VNC client disappears. If a frame ended up on the main thread after +a client disappeared but before the session and stream was closed, we'd +try to turn the new frames into VNC updates without a client being +available, causing use after free. + +Fix this by dropping frames that happens during this time frame. + +Closes: https://gitlab.gnome.org/GNOME/gnome-remote-desktop/-/issues/43 +--- + src/grd-session-vnc.c | 7 +++++++ + src/grd-session-vnc.h | 2 ++ + src/grd-vnc-pipewire-stream.c | 8 ++++++++ + 3 files changed, 17 insertions(+) + +diff --git a/src/grd-session-vnc.c b/src/grd-session-vnc.c +index 813838a..a06d34d 100644 +--- a/src/grd-session-vnc.c ++++ b/src/grd-session-vnc.c +@@ -209,6 +209,12 @@ maybe_queue_close_session_idle (GrdSessionVnc *session_vnc) + g_idle_add (close_session_idle, session_vnc); + } + ++gboolean ++grd_session_vnc_is_client_gone (GrdSessionVnc *session_vnc) ++{ ++ return !session_vnc->rfb_client; ++} ++ + static void + handle_client_gone (rfbClientPtr rfb_client) + { +@@ -218,6 +224,7 @@ handle_client_gone (rfbClientPtr rfb_client) + + grd_session_vnc_detach_source (session_vnc); + maybe_queue_close_session_idle (session_vnc); ++ session_vnc->rfb_client = NULL; + } + + static void +diff --git a/src/grd-session-vnc.h b/src/grd-session-vnc.h +index 579a12a..07678c8 100644 +--- a/src/grd-session-vnc.h ++++ b/src/grd-session-vnc.h +@@ -57,4 +57,6 @@ void grd_session_vnc_move_cursor (GrdSessionVnc *session_vnc, + + int grd_session_vnc_get_framebuffer_stride (GrdSessionVnc *session_vnc); + ++gboolean grd_session_vnc_is_client_gone (GrdSessionVnc *session_vnc); ++ + #endif /* GRD_SESSION_VNC_H */ +diff --git a/src/grd-vnc-pipewire-stream.c b/src/grd-vnc-pipewire-stream.c +index 78793c4..96dd7c9 100644 +--- a/src/grd-vnc-pipewire-stream.c ++++ b/src/grd-vnc-pipewire-stream.c +@@ -234,6 +234,14 @@ do_render (struct spa_loop *loop, + if (!frame) + return 0; + ++ if (grd_session_vnc_is_client_gone (stream->session)) ++ { ++ g_free (frame->data); ++ g_clear_pointer (&frame->rfb_cursor, rfbFreeCursor); ++ g_free (frame); ++ return 0; ++ } ++ + if (frame->rfb_cursor) + grd_session_vnc_set_cursor (stream->session, frame->rfb_cursor); + +-- +GitLab + diff --git a/net-misc/gnome-remote-desktop/gnome-remote-desktop-0.1.9.ebuild b/net-misc/gnome-remote-desktop/gnome-remote-desktop-0.1.9.ebuild new file mode 100644 index 0000000000000..622bb9d2a09cb --- /dev/null +++ b/net-misc/gnome-remote-desktop/gnome-remote-desktop-0.1.9.ebuild @@ -0,0 +1,54 @@ +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit gnome.org gnome2-utils meson systemd xdg + +DESCRIPTION="Remote desktop daemon for GNOME using pipewire" +HOMEPAGE="https://gitlab.gnome.org/jadahl/gnome-remote-desktop" + +LICENSE="GPL-2+" +SLOT="0" +KEYWORDS="~amd64" + +IUSE="" + +DEPEND=" + dev-libs/glib:2 + media-video/pipewire:0/0.3 + sys-apps/systemd + net-libs/libvncserver + app-crypt/libsecret + x11-libs/libnotify +" +RDEPEND="${DEPEND} + x11-wm/mutter[screencast] +" +BDEPEND=" + dev-util/gdbus-codegen + dev-util/glib-utils + virtual/pkgconfig +" + +PATCHES=( + "${FILESDIR}/${P}-drop-vnc-frames.patch" + "${FILESDIR}/${P}-copy-pixels.patch" +) + +src_configure() { + local emesonargs=( + -Dsystemd_user_unit_dir="$(systemd_get_userunitdir)" + ) + meson_src_configure +} + +pkg_postinst() { + xdg_pkg_postinst + gnome2_schemas_update +} + +pkg_postrm() { + xdg_pkg_postrm + gnome2_schemas_update +}