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