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

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