Blame SOURCES/xorg-x11-server-composite-Fix-use-after-free-of-the-COW.patch

29d6d4
From 947bd1b3f4a23565bf10879ec41ba06ebe1e1c76 Mon Sep 17 00:00:00 2001
29d6d4
From: Olivier Fourdan <ofourdan@redhat.com>
29d6d4
Date: Mon, 13 Mar 2023 11:08:47 +0100
29d6d4
Subject: [PATCH xserver] composite: Fix use-after-free of the COW
29d6d4
29d6d4
ZDI-CAN-19866/CVE-2023-1393
29d6d4
29d6d4
If a client explicitly destroys the compositor overlay window (aka COW),
29d6d4
we would leave a dangling pointer to that window in the CompScreen
29d6d4
structure, which will trigger a use-after-free later.
29d6d4
29d6d4
Make sure to clear the CompScreen pointer to the COW when the latter gets
29d6d4
destroyed explicitly by the client.
29d6d4
29d6d4
This vulnerability was discovered by:
29d6d4
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
29d6d4
29d6d4
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
29d6d4
Reviewed-by: Adam Jackson <ajax@redhat.com>
29d6d4
---
29d6d4
 composite/compwindow.c | 5 +++++
29d6d4
 1 file changed, 5 insertions(+)
29d6d4
29d6d4
diff --git a/composite/compwindow.c b/composite/compwindow.c
29d6d4
index 4e2494b86..b30da589e 100644
29d6d4
--- a/composite/compwindow.c
29d6d4
+++ b/composite/compwindow.c
29d6d4
@@ -620,6 +620,11 @@ compDestroyWindow(WindowPtr pWin)
29d6d4
     ret = (*pScreen->DestroyWindow) (pWin);
29d6d4
     cs->DestroyWindow = pScreen->DestroyWindow;
29d6d4
     pScreen->DestroyWindow = compDestroyWindow;
29d6d4
+
29d6d4
+    /* Did we just destroy the overlay window? */
29d6d4
+    if (pWin == cs->pOverlayWin)
29d6d4
+        cs->pOverlayWin = NULL;
29d6d4
+
29d6d4
 /*    compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/
29d6d4
     return ret;
29d6d4
 }
29d6d4
-- 
29d6d4
2.40.0
29d6d4