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

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