|
|
72411e |
From 8dba686dc277d6d262ad0c77b4632a5b276697ba Mon Sep 17 00:00:00 2001
|
|
|
72411e |
From: Peter Hutterer <peter.hutterer@who-t.net>
|
|
|
72411e |
Date: Tue, 29 Nov 2022 12:55:45 +1000
|
|
|
72411e |
Subject: [PATCH xserver 1/7] Xtest: disallow GenericEvents in
|
|
|
72411e |
XTestSwapFakeInput
|
|
|
72411e |
|
|
|
72411e |
XTestSwapFakeInput assumes all events in this request are
|
|
|
72411e |
sizeof(xEvent) and iterates through these in 32-byte increments.
|
|
|
72411e |
However, a GenericEvent may be of arbitrary length longer than 32 bytes,
|
|
|
72411e |
so any GenericEvent in this list would result in subsequent events to be
|
|
|
72411e |
misparsed.
|
|
|
72411e |
|
|
|
72411e |
Additional, the swapped event is written into a stack-allocated struct
|
|
|
72411e |
xEvent (size 32 bytes). For any GenericEvent longer than 32 bytes,
|
|
|
72411e |
swapping the event may thus smash the stack like an avocado on toast.
|
|
|
72411e |
|
|
|
72411e |
Catch this case early and return BadValue for any GenericEvent.
|
|
|
72411e |
Which is what would happen in unswapped setups anyway since XTest
|
|
|
72411e |
doesn't support GenericEvent.
|
|
|
72411e |
|
|
|
72411e |
CVE-2022-46340, ZDI-CAN 19265
|
|
|
72411e |
|
|
|
72411e |
This vulnerability was discovered by:
|
|
|
72411e |
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
|
|
|
72411e |
|
|
|
72411e |
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
|
72411e |
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
|
|
|
72411e |
---
|
|
|
72411e |
Xext/xtest.c | 5 +++--
|
|
|
72411e |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
72411e |
|
|
|
72411e |
diff --git a/Xext/xtest.c b/Xext/xtest.c
|
|
|
72411e |
index bf27eb590b..2985a4ce6e 100644
|
|
|
72411e |
--- a/Xext/xtest.c
|
|
|
72411e |
+++ b/Xext/xtest.c
|
|
|
72411e |
@@ -502,10 +502,11 @@ XTestSwapFakeInput(ClientPtr client, xReq * req)
|
|
|
72411e |
|
|
|
72411e |
nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent);
|
|
|
72411e |
for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) {
|
|
|
72411e |
+ int evtype = ev->u.u.type & 0x177;
|
|
|
72411e |
/* Swap event */
|
|
|
72411e |
- proc = EventSwapVector[ev->u.u.type & 0177];
|
|
|
72411e |
+ proc = EventSwapVector[evtype];
|
|
|
72411e |
/* no swapping proc; invalid event type? */
|
|
|
72411e |
- if (!proc || proc == NotImplemented) {
|
|
|
72411e |
+ if (!proc || proc == NotImplemented || evtype == GenericEvent) {
|
|
|
72411e |
client->errorValue = ev->u.u.type;
|
|
|
72411e |
return BadValue;
|
|
|
72411e |
}
|
|
|
72411e |
--
|
|
|
72411e |
2.38.1
|