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

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