Blame SOURCES/0005-Xext-free-the-screen-saver-resource-when-replacing-i.patch

26c1df
From 6b59bdddf30dde413c4e0391cf84f3b94d4b4e31 Mon Sep 17 00:00:00 2001
26c1df
From: Peter Hutterer <peter.hutterer@who-t.net>
26c1df
Date: Tue, 29 Nov 2022 14:53:07 +1000
26c1df
Subject: [PATCH xserver 5/7] Xext: free the screen saver resource when
26c1df
 replacing it
26c1df
26c1df
This fixes a use-after-free bug:
26c1df
26c1df
When a client first calls ScreenSaverSetAttributes(), a struct
26c1df
ScreenSaverAttrRec is allocated and added to the client's
26c1df
resources.
26c1df
26c1df
When the same client calls ScreenSaverSetAttributes() again, a new
26c1df
struct ScreenSaverAttrRec is allocated, replacing the old struct. The
26c1df
old struct was freed but not removed from the clients resources.
26c1df
26c1df
Later, when the client is destroyed the resource system invokes
26c1df
ScreenSaverFreeAttr and attempts to clean up the already freed struct.
26c1df
26c1df
Fix this by letting the resource system free the old attrs instead.
26c1df
26c1df
CVE-2022-46343, ZDI-CAN 19404
26c1df
26c1df
This vulnerability was discovered by:
26c1df
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
26c1df
26c1df
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
26c1df
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
26c1df
---
26c1df
 Xext/saver.c | 2 +-
26c1df
 1 file changed, 1 insertion(+), 1 deletion(-)
26c1df
26c1df
diff --git a/Xext/saver.c b/Xext/saver.c
26c1df
index f813ba08d1..fd6153c313 100644
26c1df
--- a/Xext/saver.c
26c1df
+++ b/Xext/saver.c
26c1df
@@ -1051,7 +1051,7 @@ ScreenSaverSetAttributes(ClientPtr client)
26c1df
         pVlist++;
26c1df
     }
26c1df
     if (pPriv->attr)
26c1df
-        FreeScreenAttr(pPriv->attr);
26c1df
+        FreeResource(pPriv->attr->resource, AttrType);
26c1df
     pPriv->attr = pAttr;
26c1df
     pAttr->resource = FakeClientID(client->index);
26c1df
     if (!AddResource(pAttr->resource, AttrType, (void *) pAttr))
26c1df
-- 
26c1df
2.38.1
26c1df