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

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