summaryrefslogtreecommitdiff
path: root/Xi
AgeCommit message (Collapse)AuthorFilesLines
2024-04-03Xi: ProcXIPassiveGrabDevice needs to use unswapped length to send replyAlan Coopersmith1-1/+4
CVE-2024-31081 Fixes: d220d6907 ("Xi: add GrabButton and GrabKeysym code.") Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1463> (cherry picked from commit 3e77295f888c67fc7645db5d0c00926a29ffecee)
2024-04-03Xi: ProcXIGetSelectedEvents needs to use unswapped length to send replyAlan Coopersmith1-1/+4
CVE-2024-31080 Reported-by: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69762 Fixes: 53e821ab4 ("Xi: add request processing for XIGetSelectedEvents.") Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1463> (cherry picked from commit 96798fc1967491c80a4d0c8d9e0a80586cb2152b)
2024-01-16Xi: flush hierarchy events after adding/removing master devicesPeter Hutterer1-5/+22
The `XISendDeviceHierarchyEvent()` function allocates space to store up to `MAXDEVICES` (256) `xXIHierarchyInfo` structures in `info`. If a device with a given ID was removed and a new device with the same ID added both in the same operation, the single device ID will lead to two info structures being written to `info`. Since this case can occur for every device ID at once, a total of two times `MAXDEVICES` info structures might be written to the allocation. To avoid it, once one add/remove master is processed, send out the device hierarchy event for the current state and continue. That event thus only ever has exactly one of either added/removed in it (and optionally slave attached/detached). CVE-2024-21885, ZDI-CAN-22744 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative (cherry picked from commit 4a5e9b1895627d40d26045bd0b7ef3dce503cbd1)
2024-01-16Xi: when creating a new ButtonClass, set the number of buttonsPeter Hutterer1-0/+1
There's a racy sequence where a master device may copy the button class from the slave, without ever initializing numButtons. This leads to a device with zero buttons but a button class which is invalid. Let's copy the numButtons value from the source - by definition if we don't have a button class yet we do not have any other slave devices with more than this number of buttons anyway. CVE-2024-0229, ZDI-CAN-22678 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative (cherry picked from commit df3c65706eb169d5938df0052059f3e0d5981b74)
2024-01-16dix: allocate enough space for logical button mapsPeter Hutterer1-2/+1
Both DeviceFocusEvent and the XIQueryPointer reply contain a bit for each logical button currently down. Since buttons can be arbitrarily mapped to anything up to 255 make sure we have enough bits for the maximum mapping. CVE-2023-6816, ZDI-CAN-22664, ZDI-CAN-22665 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative (cherry picked from commit 9e2ecb2af8302dedc49cb6a63ebe063c58a9e7e3)
2023-12-13Xi: allocate enough XkbActions for our buttonsPeter Hutterer1-6/+6
button->xkb_acts is supposed to be an array sufficiently large for all our buttons, not just a single XkbActions struct. Allocating insufficient memory here means when we memcpy() later in XkbSetDeviceInfo we write into memory that wasn't ours to begin with, leading to the usual security ooopsiedaisies. CVE-2023-6377, ZDI-CAN-22412, ZDI-CAN-22413 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative (cherry picked from commit 0c1a93d319558fe3ab2d94f51d174b4f93810afd)
2023-10-25Xi/randr: fix handling of PropModeAppend/PrependPeter Hutterer1-2/+2
The handling of appending/prepending properties was incorrect, with at least two bugs: the property length was set to the length of the new part only, i.e. appending or prepending N elements to a property with P existing elements always resulted in the property having N elements instead of N + P. Second, when pre-pending a value to a property, the offset for the old values was incorrect, leaving the new property with potentially uninitalized values and/or resulting in OOB memory writes. For example, prepending a 3 element value to a 5 element property would result in this 8 value array: [N, N, N, ?, ?, P, P, P ] P, P ^OOB write The XI2 code is a copy/paste of the RandR code, so the bug exists in both. CVE-2023-5367, ZDI-CAN-22153 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> (cherry picked from commit 541ab2ecd41d4d8689e71855d93e492bc554719a)
2023-02-07Xi: fix potential use-after-free in DeepCopyPointerClassesPeter Hutterer1-1/+3
CVE-2023-0494, ZDI-CAN-19596 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> (cherry picked from commit 0ba6d8c37071131a49790243cdac55392ecf71ec)
2022-12-14Xi: avoid integer truncation in length check of ProcXIChangePropertyPeter Hutterer1-2/+2
This fixes an OOB read and the resulting information disclosure. Length calculation for the request was clipped to a 32-bit integer. With the correct stuff->num_items value the expected request size was truncated, passing the REQUEST_FIXED_SIZE check. The server then proceeded with reading at least stuff->num_items bytes (depending on stuff->format) from the request and stuffing whatever it finds into the property. In the process it would also allocate at least stuff->num_items bytes, i.e. 4GB. The same bug exists in ProcChangeProperty and ProcXChangeDeviceProperty, so let's fix that too. CVE-2022-46344, ZDI-CAN 19405 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 8f454b793e1f13c99872c15f0eed1d7f3b823fe8)
2022-12-14Xi: return an error from XI property changes if verification failedPeter Hutterer1-0/+5
Both ProcXChangeDeviceProperty and ProcXIChangeProperty checked the property for validity but didn't actually return the potential error. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Olivier Fourdan <ofourdan@redhat.com> (cherry picked from commit b8a84cb0f2807b07ab70ca9915fcdee21301b8ca)
2022-12-14Xi: disallow passive grabs with a detail > 255Peter Hutterer1-8/+14
The XKB protocol effectively prevents us from ever using keycodes above 255. For buttons it's theoretically possible but realistically too niche to worry about. For all other passive grabs, the detail must be zero anyway. This fixes an OOB write: ProcXIPassiveUngrabDevice() calls DeletePassiveGrabFromList with a temporary grab struct which contains tempGrab->detail.exact = stuff->detail. For matching existing grabs, DeleteDetailFromMask is called with the stuff->detail value. This function creates a new mask with the one bit representing stuff->detail cleared. However, the array size for the new mask is 8 * sizeof(CARD32) bits, thus any detail above 255 results in an OOB array write. CVE-2022-46341, ZDI-CAN 19381 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 51eb63b0ee1509c6c6b8922b0e4aa037faa6f78b)
2022-07-01dix: Correctly save replayed event into GrabInfoRecPovilas Kanapickas1-1/+1
When processing events we operate on InternalEvent pointers. They may actually refer to a an instance of DeviceEvent, GestureEvent or any other event that comprises the InternalEvent union. This works well in practice because we always look into event type before doing anything, except in the case of copying the event. *dst_event = *src_event would copy whole InternalEvent event and would cause out of bounds read in case the pointed to event was not InternalEvent but e.g. DeviceEvent. This regression has been introduced in 23a8b62d34344575f9df9d057fb74bfefa94a77b. Fixes https://gitlab.freedesktop.org/xorg/xserver/-/issues/1261 Signed-off-by: Povilas Kanapickas <povilas@radix.lt> (cherry picked from commit 6ef5c05728f8b18170fbc8415d7502495a08670b)
2021-12-19Convert more funcs to use InternalEvent.Matthieu Herrb1-2/+2
This fixes a crash when a DeviceEvent struct converted to InteralEvent was beeing copied as InternalEvent (and thus causing out of bounds reads) in ActivateGrabNoDelivery() in events.c: 3876 *grabinfo->sync.event = *real_event; Possible fix for https://gitlab.freedesktop.org/xorg/xserver/-/issues/1253 Signed-off-by: Matthieu Herrb <matthieu@herrb.eu> (cherry picked from commit 5b8817a019845e1066c373022133985a0e2d718f)
2021-08-17xinput: Silence a warning from gcc 11Adam Jackson1-1/+1
[45/388] Compiling C object Xi/liblibxserver_xi.a.p/xichangehierarchy.c.o ../Xi/xichangehierarchy.c:61:32: warning: argument 1 of type ‘int[256]’ with mismatched bound [-Warray-parameter=] 61 | XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) | ~~~~^~~~~~~~~~~~~~~~~ In file included from ../Xi/xichangehierarchy.c:54: ../Xi/xichangehierarchy.h:42:37: note: previously declared as ‘int[]’ 42 | void XISendDeviceHierarchyEvent(int flags[]); | ~~~~^~~~~~~
2021-05-30Xi: Work around broken libxcb that doesn't ignore unknown device classesPovilas Kanapickas1-1/+20
libxcb 14.1 and older are not forwards-compatible with new device classes as it does not properly ignore unknown device classes. Since breaking libxcb would break quite a lot of applications, we instead report Gesture device class only if the client advertised support for XI 2.4. Clients may still not work in cases when a client advertises XI 2.4 support and then a completely separate module within the client uses broken libxcb to call XIQueryDevice. Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-05-30Xi: Implement gesture support for XIQueryDevicePovilas Kanapickas1-1/+37
2021-05-30Xi: Include gestures among events that may freeze devicePovilas Kanapickas1-1/+6
2021-05-30Implement gesture processing logicPovilas Kanapickas1-0/+174
2021-05-30dix: Implement internal gesture state handlingPovilas Kanapickas1-0/+19
2021-05-30xi: Implement conversions from internal to Xi2 gesture event structsPovilas Kanapickas1-0/+80
2021-05-30xi: Implement selection logic for gesture event typesPovilas Kanapickas1-2/+51
2021-05-30xi: Implement grab support for new gesture event typesPovilas Kanapickas2-7/+28
2021-05-30dix: Add new internal event enums for gesture eventsPovilas Kanapickas1-0/+44
2021-04-13Fix XChangeFeedbackControl() request underflowMatthieu Herrb1-1/+4
CVE-2021-3472 / ZDI-CAN-1259 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2021-02-15Xi: Deliver pointer emulated touch events to grabbing clientPovilas Kanapickas1-10/+10
Delivery of emulated events usually happens only to the owning client. If there are grabs, only the grabbing client may receive these events. This logic does not work during the touch event replay in DeactivatePointerGrab(), as the previous grab is no longer in the listener queue of the touch, so the next owner gets whole emulated event sequence. This may trigger implicit grabs. After replay, DeactivatePointerGrab() will update the global grab without regard to this new implicit grab, which leads to issues down the line. This change is effectively the same as 35e5a76cc1 except that the change is limited to only emulated pointer events. Otherwise, in the case of a device grab we end up not sending any touch events to clients that selected XI_TouchOwnership event and should get touch events before they get ownership of touch sequence. Fixes #7 https://bugs.freedesktop.org/show_bug.cgi?id=96536
2021-02-15Revert "Xi: Use current device active grab to deliver touch events if any"Povilas Kanapickas1-8/+12
This reverts commit 98e3db2ac43d4a3f13475cb160c8ce0155ac7d61.
2021-01-05xi: Don't deliver emulated motion when there's no owner for touch endPovilas Kanapickas1-1/+8
Pointer-emulated touch events should only be delivered to the client that owns the sequence even if it's a core client that became the effective owner of the sequency by selecting for pointer press and movement. Currently the emulated events are delivered like this already (see TouchResourceIsOwner() check in DeliverEmulatedMotionEvent()), except in the case of TouchEnd, in which case the generated motion event is still delivered to some client that's not necessarily the owner of the touch sequence. We already know whether a touch sequence that is about to emulate a pointer event has an owner, we just need to check that. This further allows to simplify DeliverEmulatedMotionEvent() as it won't ever be called for non-owned touch events. https://bugs.freedesktop.org/show_bug.cgi?id=60394 Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-11-25dix: Store replayed event into GrabInfoRec struct as InternalEvent*Povilas Kanapickas1-1/+1
2020-11-25dix: Rename LISTENER_* to TOUCH_LISTENER_*Povilas Kanapickas1-48/+48
2020-11-25Xi: Make check_for_touch_selection_conflicts() more genericPovilas Kanapickas1-5/+8
2020-08-25Fix XIChangeHierarchy() integer underflowMatthieu Herrb1-1/+1
CVE-2020-14346 / ZDI-CAN-11429 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2020-07-05Fix spelling/wording issuesAlan Coopersmith4-7/+7
Most (but not all) of these were found by using codespell --builtin clear,rare,usage,informal,code,names but not everything reported by that was fixed. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-03-30xinput: Remove PropagateMaskAdam Jackson3-40/+14
Initialized to a constant value, never modified, never varied by device. Signed-off-by: Adam Jackson <ajax@redhat.com>
2020-03-30xinput: Remove ExtExclusiveMasksAdam Jackson2-23/+1
Initialized to a constant value, never modified, never varied by device. Signed-off-by: Adam Jackson <ajax@redhat.com>
2019-06-12Xi: return AlreadyGrabbed for key grabs > 255Peter Hutterer1-2/+8
We can't have high keycodes because everything in XKB relies on 8 bits. XI2's API allows for 32-bit keycodes so we have to take those but nothing in the server is really ready for this. The effect of this right now is that any high keycode grab is clipped to 255 and thus ends up grabbing a different key instead. https://bugzilla.redhat.com/show_bug.cgi?id=1697804 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-14Xi: lock the input thread for any pointer barrier list manipulationPeter Hutterer1-0/+10
The input thread checks the barriers for pointer positioning, swapping the list out from underneath is considered impolite. Reported-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2018-11-12Xi: Use current device active grab to deliver touch events if anyMarco Trevisan (Treviño)1-13/+8
When Retrieving touch delivery data we need to check if we have an active grab on such device, and in that case use it to delivery events. If we don't do this, when rejecting the touch events in DeactivatePointerGrab, we will end-up in creating an implicit grab that will change the device deviceGrab's state, causing a recursion during TouchEndTouch. Fixes #7 https://bugs.freedesktop.org/show_bug.cgi?id=96536
2018-11-10Remove obsolete B16 & B32 tags in struct definitionsAlan Coopersmith1-2/+2
They were defined as empty macros on all platforms except for the long unsupported Cray systems which needed to use bitfields to define types smaller than 64-bits. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-09-12xi: free modifiers_failed on error path. (v2)Dave Airlie1-2/+2
Pointed out by coverity. v2: set modifies_failed to NULL at start (whot) Signed-off-by: Dave Airlie <airlied@redhat.com>
2018-06-08Xi: add forgotten byte-swaps for Valuator fieldsRoman Kapl1-0/+3
This has caused nonsensical values in xinput output. Signed-off-by: Roman Kapl <code@rkapl.cz> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-08Xi: fix byte-swapping of button labelsRoman Kapl1-6/+20
The byte-swapping code forgot that the xXIButtonInfo is followed by a button mask, not directly by the button labels. This resulted in client crashes in cross-endian setups, for example in `xinput list --long`, since the client got an invalid atom. A new function was introduced to get the right positions for the label and mask data. Signed-off-by: Roman Kapl <code@rkapl.cz> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-30Use ARRAY_SIZE all over the treeDaniel Martin1-4/+2
Roundhouse kick replacing the various (sizeof(foo)/sizeof(foo[0])) with the ARRAY_SIZE macro from dix.h when possible. A semantic patch for coccinelle has been used first. Additionally, a few macros have been inlined as they had only one or two users. Signed-off-by: Daniel Martin <consume.noise@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-10-10Xi: fix wrong extra length check in ProcXIChangeHierarchy (CVE-2017-12178)Nathan Kidd1-1/+1
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Nathan Kidd <nkidd@opentext.com> Signed-off-by: Julien Cristau <jcristau@debian.org>
2017-10-10Xi: integer overflow and unvalidated length in (S)ProcXIBarrierReleasePointerNathan Kidd1-0/+5
[jcristau: originally this patch fixed the same issue as commit 211e05ac85 "Xi: Test exact size of XIBarrierReleasePointer", with the addition of these checks] This addresses CVE-2017-12179 Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> Signed-off-by: Nathan Kidd <nkidd@opentext.com> Signed-off-by: Julien Cristau <jcristau@debian.org>
2017-07-11Xi: Test exact size of XIBarrierReleasePointerMichal Srb1-3/+6
Otherwise a client can send any value of num_barriers and cause reading or swapping of values on heap behind the receive buffer. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-19Xi: Do not try to swap GenericEvent.Michal Srb1-1/+9
The SProcXSendExtensionEvent must not attempt to swap GenericEvent because it is assuming that the event has fixed size and gives the swapping function xEvent-sized buffer. A GenericEvent would be later rejected by ProcXSendExtensionEvent anyway. Signed-off-by: Michal Srb <msrb@suse.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-19Xi: Verify all events in ProcXSendExtensionEvent.Michal Srb1-5/+7
The requirement is that events have type in range EXTENSION_EVENT_BASE..lastEvent, but it was tested only for first event of all. Signed-off-by: Michal Srb <msrb@suse.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-19Xi: Zero target buffer in SProcXSendExtensionEvent.Michal Srb1-1/+1
Make sure that the xEvent eventT is initialized with zeros, the same way as in SProcSendEvent. Some event swapping functions do not overwrite all 32 bytes of xEvent structure, for example XSecurityAuthorizationRevoked. Two cooperating clients, one swapped and the other not, can send XSecurityAuthorizationRevoked event to each other to retrieve old stack data from X server. This can be potentialy misused to go around ASLR or stack-protector. Signed-off-by: Michal Srb <msrb@suse.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-07Xi: Use WarpPointerProc hook on XI pointer warping implementationCarlos Garnacho1-0/+4
Just like we do with XWarpPointer's. Signed-off-by: Carlos Garnacho <carlosg@gnome.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-26Add a Meson build system alongside autotools.Eric Anholt1-0/+67
This is a work in progress that builds Xvfb, Xephyr, Xwayland, Xnest, and Xdmx so far. The outline of Xquartz/Xwin support is in tree, but hasn't been built yet. The unit tests are also not done. The intent is to build this as a complete replacement for the autotools system, then eventually replace autotools. meson is faster to generate the build, faster to run the bulid, shorter to write the build files in, and less error-prone than autotools. v2: Fix indentation nits, move version declaration to project(), use existing meson_options for version-config.h's vendor name/web. Signed-off-by: Eric Anholt <eric@anholt.net> Acked-by: Keith Packard <keithp@keithp.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>