1 |
From 94f6fe99d87cf6ba0adadd95c595158c345b7d29 Mon Sep 17 00:00:00 2001 |
2 |
From: Peter Hutterer <peter.hutterer@who-t.net> |
3 |
Date: Tue, 29 Nov 2022 14:53:07 +1000 |
4 |
Subject: [PATCH xserver 5/7] Xext: free the screen saver resource when |
5 |
replacing it |
6 |
|
7 |
This fixes a use-after-free bug: |
8 |
|
9 |
When a client first calls ScreenSaverSetAttributes(), a struct |
10 |
ScreenSaverAttrRec is allocated and added to the client's |
11 |
resources. |
12 |
|
13 |
When the same client calls ScreenSaverSetAttributes() again, a new |
14 |
struct ScreenSaverAttrRec is allocated, replacing the old struct. The |
15 |
old struct was freed but not removed from the clients resources. |
16 |
|
17 |
Later, when the client is destroyed the resource system invokes |
18 |
ScreenSaverFreeAttr and attempts to clean up the already freed struct. |
19 |
|
20 |
Fix this by letting the resource system free the old attrs instead. |
21 |
|
22 |
CVE-2022-46343, ZDI-CAN 19404 |
23 |
|
24 |
This vulnerability was discovered by: |
25 |
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative |
26 |
|
27 |
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> |
28 |
Acked-by: Olivier Fourdan <ofourdan@redhat.com> |
29 |
--- |
30 |
Xext/saver.c | 2 +- |
31 |
1 file changed, 1 insertion(+), 1 deletion(-) |
32 |
|
33 |
diff --git a/Xext/saver.c b/Xext/saver.c |
34 |
index f813ba08d1..fd6153c313 100644 |
35 |
--- a/Xext/saver.c |
36 |
+++ b/Xext/saver.c |
37 |
@@ -1051,7 +1051,7 @@ ScreenSaverSetAttributes(ClientPtr client) |
38 |
pVlist++; |
39 |
} |
40 |
if (pPriv->attr) |
41 |
- FreeScreenAttr(pPriv->attr); |
42 |
+ FreeResource(pPriv->attr->resource, AttrType); |
43 |
pPriv->attr = pAttr; |
44 |
pAttr->resource = FakeClientID(client->index); |
45 |
if (!AddResource(pAttr->resource, AttrType, (void *) pAttr)) |
46 |
-- |
47 |
2.38.1 |
48 |
|