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