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

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