mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2025-12-20 17:30:02 +01:00
Xtest: disallow GenericEvents in XTestSwapFakeInput
XTestSwapFakeInput assumes all events in this request are
sizeof(xEvent) and iterates through these in 32-byte increments.
However, a GenericEvent may be of arbitrary length longer than 32 bytes,
so any GenericEvent in this list would result in subsequent events to be
misparsed.
Additional, the swapped event is written into a stack-allocated struct
xEvent (size 32 bytes). For any GenericEvent longer than 32 bytes,
swapping the event may thus smash the stack like an avocado on toast.
Catch this case early and return BadValue for any GenericEvent.
Which is what would happen in unswapped setups anyway since XTest
doesn't support GenericEvent.
CVE-2022-46340, ZDI-CAN 19265
This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
(cherry picked from commit b320ca0ffe)
This commit is contained in:
parent
b97c7c78c5
commit
adaf080bd5
1 changed files with 3 additions and 2 deletions
|
|
@ -502,10 +502,11 @@ XTestSwapFakeInput(ClientPtr client, xReq * req)
|
||||||
|
|
||||||
nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent);
|
nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent);
|
||||||
for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) {
|
for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) {
|
||||||
|
int evtype = ev->u.u.type & 0x177;
|
||||||
/* Swap event */
|
/* Swap event */
|
||||||
proc = EventSwapVector[ev->u.u.type & 0177];
|
proc = EventSwapVector[evtype];
|
||||||
/* no swapping proc; invalid event type? */
|
/* no swapping proc; invalid event type? */
|
||||||
if (!proc || proc == NotImplemented) {
|
if (!proc || proc == NotImplemented || evtype == GenericEvent) {
|
||||||
client->errorValue = ev->u.u.type;
|
client->errorValue = ev->u.u.type;
|
||||||
return BadValue;
|
return BadValue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue