xwayland: Prevent Xserver grabs with rootless

Graphics / X.Org / X.Org Server - Olivier Fourdan [redhat.com] - 13 September 2022 14:18 UTC

Because of the design of most Wayland compositors, where the compositor is both a Wayland server and an X11 window manager, any X11 client issuing a server grab (i.e. XGrabServer()) can possibly hang the whole desktop when Xwayland is running rootless.

This can happen with e.g. ImageMagick's import command with mutter.

1. "import" is launched and issues an XServerGrab(), 2. Xwayland restricts access to that "import" X11 client alone, 3. mutter continues to process events until it needs to sync with Xwayland (there's variability in time before the hang occurs), 4. When mutter does an XSync() (explicitly or implicitly through some other Xlib call), it will stop waiting for Xwayland to reply, 5. Xwayland waits for the XServerGrab() to be released by import, 6. "import" waits for a user input to release the XServerGrab(), 7. mutter is stuck waiting on Xwayland and does not process input events...

To prevent this, re-route the GrabServer/UngrabServer requests and pretend the grab works but actually does nothing at all for all clients but the X11 window manager (which can still issue X11 server grabs, at its own risks).

a77d95af6 xwayland: Prevent Xserver grabs with rootless
hw/xwayland/xwayland-screen.c | 48 +++++++++++++++++++++++++++++++++++++++++++
hw/xwayland/xwayland-screen.h | 3 +++
2 files changed, 51 insertions(+)

Upstream: cgit.freedesktop.org

  • Share