xwayland: Check window pixmap in xwl_present_check_flip2

We can only flip if the window pixmap matches that of the toplevel
window. Doing so regardless could cause the toplevel window pixmap to
get destroyed while it was still referenced by the window, resulting in
use-after-free and likely a crash.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1033
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Roman Gilg <subdiff@gmail.com>
(cherry picked from commit 4c25356d6c)
This commit is contained in:
Michel Dänzer 2020-09-07 18:39:17 +02:00 committed by Michel Dänzer
parent f4006d795c
commit 51ee6e5ceb

View File

@ -421,10 +421,18 @@ xwl_present_check_flip2(RRCrtcPtr crtc,
PresentFlipReason *reason)
{
struct xwl_window *xwl_window = xwl_window_from_window(present_window);
ScreenPtr screen = pixmap->drawable.pScreen;
if (!xwl_window)
return FALSE;
/* Can't flip if the window pixmap doesn't match the xwl_window parent
* window's, e.g. because a client redirected this window or one of its
* parents.
*/
if (screen->GetWindowPixmap(xwl_window->window) != screen->GetWindowPixmap(present_window))
return FALSE;
/*
* We currently only allow flips of windows, that have the same
* dimensions as their xwl_window parent window. For the case of