wok-current view xorg-server/stuff/CVE-2024-21885.patch @ rev 25701

Fix dep for libglamoregl.so (libepoxy), and miss file for amdgpu (thanks alanyih)
author Stanislas Leduc <shann@slitaz.org>
date Fri Apr 19 12:48:51 2024 +0000 (7 months ago)
parents
children
line source
1 From 4a5e9b1895627d40d26045bd0b7ef3dce503cbd1 Mon Sep 17 00:00:00 2001
2 From: Peter Hutterer <peter.hutterer@who-t.net>
3 Date: Thu, 4 Jan 2024 10:01:24 +1000
4 Subject: [PATCH] Xi: flush hierarchy events after adding/removing master
5 devices
7 The `XISendDeviceHierarchyEvent()` function allocates space to store up
8 to `MAXDEVICES` (256) `xXIHierarchyInfo` structures in `info`.
10 If a device with a given ID was removed and a new device with the same
11 ID added both in the same operation, the single device ID will lead to
12 two info structures being written to `info`.
14 Since this case can occur for every device ID at once, a total of two
15 times `MAXDEVICES` info structures might be written to the allocation.
17 To avoid it, once one add/remove master is processed, send out the
18 device hierarchy event for the current state and continue. That event
19 thus only ever has exactly one of either added/removed in it (and
20 optionally slave attached/detached).
22 CVE-2024-21885, ZDI-CAN-22744
24 This vulnerability was discovered by:
25 Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
26 ---
27 Xi/xichangehierarchy.c | 27 ++++++++++++++++++++++-----
28 1 file changed, 22 insertions(+), 5 deletions(-)
30 diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
31 index d2d985848d..72d00451e3 100644
32 --- a/Xi/xichangehierarchy.c
33 +++ b/Xi/xichangehierarchy.c
34 @@ -416,6 +416,11 @@ ProcXIChangeHierarchy(ClientPtr client)
35 size_t len; /* length of data remaining in request */
36 int rc = Success;
37 int flags[MAXDEVICES] = { 0 };
38 + enum {
39 + NO_CHANGE,
40 + FLUSH,
41 + CHANGED,
42 + } changes = NO_CHANGE;
44 REQUEST(xXIChangeHierarchyReq);
45 REQUEST_AT_LEAST_SIZE(xXIChangeHierarchyReq);
46 @@ -465,8 +470,9 @@ ProcXIChangeHierarchy(ClientPtr client)
47 rc = add_master(client, c, flags);
48 if (rc != Success)
49 goto unwind;
50 - }
51 + changes = FLUSH;
52 break;
53 + }
54 case XIRemoveMaster:
55 {
56 xXIRemoveMasterInfo *r = (xXIRemoveMasterInfo *) any;
57 @@ -475,8 +481,9 @@ ProcXIChangeHierarchy(ClientPtr client)
58 rc = remove_master(client, r, flags);
59 if (rc != Success)
60 goto unwind;
61 - }
62 + changes = FLUSH;
63 break;
64 + }
65 case XIDetachSlave:
66 {
67 xXIDetachSlaveInfo *c = (xXIDetachSlaveInfo *) any;
68 @@ -485,8 +492,9 @@ ProcXIChangeHierarchy(ClientPtr client)
69 rc = detach_slave(client, c, flags);
70 if (rc != Success)
71 goto unwind;
72 - }
73 + changes = CHANGED;
74 break;
75 + }
76 case XIAttachSlave:
77 {
78 xXIAttachSlaveInfo *c = (xXIAttachSlaveInfo *) any;
79 @@ -495,16 +503,25 @@ ProcXIChangeHierarchy(ClientPtr client)
80 rc = attach_slave(client, c, flags);
81 if (rc != Success)
82 goto unwind;
83 + changes = CHANGED;
84 + break;
85 }
86 + default:
87 break;
88 }
90 + if (changes == FLUSH) {
91 + XISendDeviceHierarchyEvent(flags);
92 + memset(flags, 0, sizeof(flags));
93 + changes = NO_CHANGE;
94 + }
95 +
96 len -= any->length * 4;
97 any = (xXIAnyHierarchyChangeInfo *) ((char *) any + any->length * 4);
98 }
100 unwind:
101 -
102 - XISendDeviceHierarchyEvent(flags);
103 + if (changes != NO_CHANGE)
104 + XISendDeviceHierarchyEvent(flags);
105 return rc;
106 }
107 --
108 GitLab