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

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