Commit Graph

17491 Commits

Author SHA1 Message Date
Povilas Kanapickas
5322457980 xfree86/inputtest: Drop extraneous linux-specific include
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-01-06 01:48:02 +00:00
Povilas Kanapickas
3ab3083cc2 xi: Don't deliver emulated motion when there's no owner for touch end
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>
2021-01-05 02:40:52 +00:00
Adam Jackson
365cbbfc4b os, shm: fcntl()'s third argument is integer, not pointer
All of these uses were attempting to set FD_CLOEXEC, which happens to be
(1<<0). Since flags is going to be aligned in memory, its address is
never going to have the low bit set, so we were never actually setting
what we meant to.

Fixes: xorg/xserver#1114
2020-12-18 09:36:30 -05:00
Povilas Kanapickas
5e3900904d xfree86: Use different scroll increment than libinput in inputtest drv
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-12-18 04:39:07 +02:00
Povilas Kanapickas
58465a3dd9 xfree86: Add scroll axes to touch devices in inputtest driver
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-12-17 03:11:16 +02:00
Povilas Kanapickas
91a8013990 xfree86: Add support for pressure valuator axis in inputtest driver
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-12-17 03:11:08 +02:00
Povilas Kanapickas
742b87f7ee xfree86: Fix axis labels for PointerAbsolute input of inputtest driver
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-12-17 03:10:58 +02:00
Olivier Fourdan
e4a9f0bb4e xwayland: Remove unneeded variable
Just a small code cleanup, there is no need to allocate a variable only
to check the return value of eglInitialize().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
2020-12-15 15:03:47 +01:00
Olivier Fourdan
95be87db98 xwayland: Refactor glamor EGL init
Glamor requires at least big GL 2.1 or GLES2, therefore Xwayland tries
to initialize first GL and then GLES2 if that fails.

It does that all in one single function which makes the code slightly
complicated, move the initialization of big-GL and GLES2 to separate
functions to help with readability of the code.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
2020-12-15 15:03:47 +01:00
Tony Lindgren
65673b02ef xwayland: fix GL version check for GLES only devices
We currently bail out early for GLES only devices, and call
epoxy_gl_version() too early for GLES only that will make GLES only
devices return NULL for glGetString(GL_RENDERER).

Let's also add a check to see if we need to recreate the context to
avoid pointless warnings for GLES only devices as suggested by
Olivier Fourdan <ofourdan@redhat.com>.

Fixes: a506b4ec - xwayland: make context current to check GL version
Signed-off-by: Tony Lindgren <tony@atomide.com>
2020-12-14 15:57:35 +01:00
Fabrice Fontaine
5d73a8b59e meson.build: KMS support also depends on dri2
Kernel modesettings support also depends on dri2, see
./hw/xfree86/drivers/modesetting/meson.build

So update meson.build to reflect the changes made in configure.ac by
commit 9c81b8f5b5

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-12-14 11:06:09 +00:00
Povilas Kanapickas
8c0afc9eb2 xfree86: Implement a test input driver
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-12-14 01:12:10 +00:00
Olivier Fourdan
f95d81e88b xwayland: Hold window buffer until released
The window buffer mechanism would free the pixmap and its corresponding
Wayland buffer as soon as window buffers are disposed.

Typically when the X11 window is unrealized, the current window buffer
is still used by the Wayland compositor and yet Xwayland will destroy
the buffer.

As a matter of fact, Xwayland should not destroy the Wayland buffer
before the wl_buffer.release event is received.

Add a reference counter to the window buffer similar to the to pixmap
reference counter to keep the buffer around until the release callback
is received.

Increase that reference counter on the buffer which will be attached to
the surface, and drop that reference when receiving the release callback
notification.

v2: Use a specific reference counter on the buffer rather than relying
    on the pixmap refcnt (Michel Dänzer <mdaenzer@redhat.com>)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Acked-by: Martin Peres <martin.peres@mupuf.org>
2020-12-10 13:49:42 +01:00
Olivier Fourdan
85d8eac4bc xwayland: Hold cursor buffer until released
The cursor code would destroy the buffer as soon as the cursor is
unrealized on X11 side.

Yet, the Wayland compositor may still be using the buffer as long as a
released callback has not been received.

Increase the reference counter on the pixmap to hold a reference on the
pixmap when attaching it to the surface and use the new pixmap release
callback mechanism to release that reference when the buffer is
released.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Martin Peres <martin.peres@mupuf.org>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-12-10 13:49:42 +01:00
Olivier Fourdan
79afbd608b xwayland: Factorize common cursor code
The seat and tablet cursor functions are very similar, factorize the
commonalities to simplify the code and reduce the copy/paste.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-12-10 13:49:42 +01:00
Prabhu Sundararaj
36e353bcf4 Remove check for useSIGIO option
Commit 6a5a4e6037 removed the option to
configure useSIGIO option. Indeed, the xfree86 SIGIO support was
reworked to use internal versions of OsBlockSIGIO and OsReleaseSIGIO.

As a result, useSIGIO is no longer needed and can dropped

Fixes: 6a5a4e60 - Remove SIGIO support for input [v5]
Closes: xorg/xserver#1107
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Prabhu Sundararaj <prabhu.sundararaj@nxp.com>
Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-12-08 11:23:31 -05:00
Mariusz Ceier
95539ab37b xwayland: Replace LogMessage with LogMessageVerb
LogMessage logs only when the XLOG_VERBOSITY is >= 1, but by default
XLOG_VERBOSITY is 0, so for example warning about deprected -listen
parameter is never shown when running "Xwayland -listen 32 -help".

Signed-off-by: Mariusz Ceier <mceier+freedesktop@gmail.com>
2020-12-08 09:16:52 +00:00
Michal Srb
74627d13c7 xkb: Fix heap overflow caused by optimized away min.
Calling strlen on char[4] that does not need to contain '\0' is wrong and X
server may end up running into uninitialized memory.

In addition GCC 8 is clever enough that it knows that strlen on char[4] can
return 0, 1, 2, 3 or cause undefined behavior. With this knowledge it can
optimize away the min(..., 4). In reality it can cause the memcpy to be called
with bigger size than 4 and overflow the destination buffer.

Fixes: 83913de25d (xkb: Silence some compiler warnings)
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/288
Signed-off-by: Matt Turner <mattst88@gmail.com>
2020-12-04 18:31:06 -05:00
Matthieu Herrb
446ff2d317 Check SetMap request length carefully.
Avoid out of bounds memory accesses on too short request.

ZDI-CAN 11572 /  CVE-2020-14360

This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2020-12-01 15:28:58 +01:00
Matthieu Herrb
87c64fc5b0 Fix XkbSetDeviceInfo() and SetDeviceIndicators() heap overflows
ZDI-CAN 11389 / CVE-2020-25712

This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2020-12-01 15:28:58 +01:00
Michel Dänzer
11652706b0 present/wnmd: Translate update region to screen space
The region as passed in is in the source pixmap's coordinate space, so
intersecting it with the clipList (which is in screen space) resulted in
disappointment.

Fixes Firefox popups such as the hamburger menu when using the EGL
backend.

v2:
* Drop vblank->x/y_off from RegionTranslate call, since they're always
  0 here (present_wnmd_check_flip rejects flips for x/y_off != 0).

Reported-by: Robert Mader <robert.mader@posteo.de>
Tested-by: Robert Mader <robert.mader@posteo.de>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Joakim Tjernlund <joakim.tjernlund@infinera.com> # v1
2020-12-01 09:16:49 +00:00
Michel Dänzer
b0530fe422 glx: Remove unused bswap_CARD64
GCC warned about it:

../../../glx/indirect_dispatch_swap.c:85:1: warning: ‘bswap_CARD64’ defined but not used [-Wunused-function]
   85 | bswap_CARD64(const void *src)
      | ^~~~~~~~~~~~
2020-11-30 16:22:26 +00:00
Olivier Fourdan
3ce05a44f3 modesetting: Fix build with DebugPresent() enabled
By default, the macro DebugPresent() is a no-op but it can be enabled
at build time for debugging purpose.

However, doing so prevents the code to build because one debug statement
tries to make use of a non-existent variable:

  present.c: In function ‘ms_present_queue_vblank’:
  present.c:147:18: error: ‘vbl’ undeclared (first use in this function)
    147 |                  vbl.request.sequence));
        |                  ^~~
  present.c:49:32: note: in definition of macro ‘DebugPresent’
    49 | #define DebugPresent(x) ErrorF x
       |                                ^

Fix the build with DebugPresent() by removing the vbl variable from the
debug message.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-26 22:06:56 +00:00
Erik Kurzinger
95b79aa907 GLX: fix context render type queries
Querying the GLX_RENDER_TYPE of a GLX context via glXQueryContext will
currently return the render type of the context's FB config, which is
a bitmask of GLX_RGBA_BIT / GLX_COLOR_INDEX_BIT / ... values. However,
this query should really return the render type that was specified
when creating the context, which is one of GLX_RGBA_TYPE /
GLX_COLOR_INDEX_TYPE / .... To enable this, save the render type when
creating a new context (defaulting to GLX_RGBA_TYPE if unspecified),
and then include this value in the context attributes sent to clients.
2020-11-26 20:07:55 +00:00
Fabrice Fontaine
9c81b8f5b5 configure.ac: KMS support also depends on dri2
Kernel modesettings support also depends on dri2, see
http://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/drivers/modesetting/Makefile.am#n46

Fix #479

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
[Patch retrieved (with a small update of commit message) from:
https://git.buildroot.net/buildroot/tree/package/x11r7/xserver_xorg-server/1.20.6/0001-modesettings-needs-dri2.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-11-25 06:41:28 +00:00
Böszörményi Zoltán
682167475c Introduce and use BUS_USB
With !155, the device bus ID received via udev is constructed
properly with the "usb:" prefix. But, it is not enough to
make the following line to work in Section "Device":

    BusID  "usb:0:1.2:1.0"

Introduce BUS_USB, so the prefix can be distinguished from BUS_PCI
and check the supplied BusID value against device->attribs->busid
in xf86PlatformDeviceCheckBusID().

Signed-off-by: Böszörményi Zoltán <zboszor@pr.hu>
2020-11-25 04:39:14 +00:00
Reza Arbab
c0dcadad6c linux: Fix udev ID_PATH parsing for udl devices
The ID_PATH for a udl device looks like this:

  $ udevadm info /dev/dri/card2 | grep -w ID_PATH
  E: ID_PATH=pci-0000:00:14.0-usb-0:9.1:1.0

The parsing added in 0816e8fca6 ("linux: Make platform device probe
less fragile"), sets OdevAttributes::busid to "pci:0000:00:14.0", where
drmGetBusid() would have returned "3-9.1:1.0".

Identifying this as a "pci:*" device eventually causes the vendor/device
id check in probeSingleDevice() to fail, because a USB controller isn't
a supported device:

  $ udevadm info --path=/devices/pci0000:00/0000:00:14.0 | grep -e VENDOR -e ID_PCI_CLASS
  E: ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
  E: ID_VENDOR_FROM_DATABASE=Intel Corporation

Instead of parsing out "pci:0000:00:14.0" in this case, use
"usb:0:9.1:1.0" so the device probe will succeed.

Fixes: 0816e8fca6 ("linux: Make platform device probe less fragile")
Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
2020-11-25 04:39:14 +00:00
Aaron Plattner
af4622d3f9 modesetting: Add missing copyright notices
I forgot to add these in commits 4fefe73fe, b6985d6b3, 245b9db03, and 4e670f128.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
2020-11-25 04:28:42 +00:00
Povilas Kanapickas
07e6935030 test/xi2: Fix mask size in XISelectEvents test
XI2LASTEVENT identifies the bit number, not the mask size in bits. The
mask size in bits is XI2LASTEVENT + 1 and the mask size in bytes is
(XI2LASTEVENT + 8) / 8 or XI2MASKSIZE.
2020-11-25 04:20:22 +00:00
Povilas Kanapickas
f5220117e9 dix: Extract FreezeThisEventIfNeededForSyncGrab() 2020-11-25 04:20:22 +00:00
Povilas Kanapickas
36f8dacc06 dix: Extract ActivateGrabNoDeliver() 2020-11-25 04:20:22 +00:00
Povilas Kanapickas
23a8b62d34 dix: Store replayed event into GrabInfoRec struct as InternalEvent* 2020-11-25 04:20:22 +00:00
Povilas Kanapickas
8bd8b3af19 dix: Rename LISTENER_* to TOUCH_LISTENER_* 2020-11-25 04:20:22 +00:00
Povilas Kanapickas
f6e0bf6833 Xi: Make check_for_touch_selection_conflicts() more generic 2020-11-25 04:20:22 +00:00
Povilas Kanapickas
56d7205921 dix: Extract DeliverDeviceClassesChangedEvent() utility function 2020-11-25 04:20:21 +00:00
Povilas Kanapickas
5b0c5344b7 dix: Extract CopySprite() utility 2020-11-25 04:20:21 +00:00
Povilas Kanapickas
acd819ac07 dix: Extract FixUpXI2DeviceEventFromWindow() 2020-11-25 04:20:21 +00:00
Jon Turney
bb7aab6afe hw/xwin: Fix building with -fno-common
Provide an actual definition of noDriExtension where used, rather than a
tentative definition in a header, to fix compilation with -fno-common
(the default with gcc 10).
2020-11-24 14:55:28 +00:00
Olivier Fourdan
d18dcecbe0 xwayland: Clean up pending eglstream on pixmap destroy
EGLStream implementation in Xwayland keeps a list of pending streams for
a window.

If the windows's pixmap is destroyed while there is a pending stream,
the pending stream will point to freed memory once the callback is
triggered.

Make sure to cancel the pending stream if there's one when the pixmap is
destroyed.

v2:
 * Use xorg_list_for_each_entry() instead of the safe variant (Michel
   Dänzer <mdaenzer@redhat.com>)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Karol Szuster <karolsz9898@gmail.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Closes https://gitlab.freedesktop.org/xorg/xserver/-/issues/1096
2020-11-23 15:11:47 +01:00
Olivier Fourdan
662b2bcb84 xwayland: Use the pixmap release callback with EGLStream
Commit 77658741 - "xwayland: Add buffer release callback" added an API
to deal with Wayland buffer release callbacks.

The EGLstream implementation has its own wl_buffer callback, move that
to the buffer release API instead so we don't have to deal with Wayland
buffers directly and match the other Xwayland pixmap backend
implementations.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Tested-by: Erik Kurzinger <ekurzinger@nvidia.com>
2020-11-19 09:33:01 +00:00
Alan Coopersmith
e538601128 int10: wrap entire V_ADDR_R* macros in parens for safer expansion
Resolves warnings from Oracle Parfait static analyser:

Error: Misleading macro
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '|' operator has higher precedence than ternary '?:' operator inside macro body at line 431
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 431
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 431
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 431
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 442
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 442
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 443
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 443
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '|' operator has higher precedence than ternary '?:' operator inside macro body at line 443
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 441
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 443
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 443

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-11-17 18:43:39 -08:00
Alan Coopersmith
a6574033f4 xkb: always set *mask_rtrn in XkbVirtualModsToReal
Resolves warning from Oracle Parfait static analyser:

Error: Uninitialised memory
   Uninitialised memory variable [uninitialised-mem-var] (CWE 457):
      Possible access to uninitialised memory referenced by variable 'mask'
        at line 721 of xkb/XKBMisc.c in function 'XkbUpdateKeyTypeVirtualMods'.
        Path in callee avoiding write at line 720
          mask allocated at line 718

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-11-17 18:43:39 -08:00
Alan Coopersmith
034e792662 dmx: example code should set a good example
Resolves warning from Oracle Parfait static analyser:

Error: Unchecked result
   Unchecked result [unchecked-result-call-X]:
      Unchecked return value from call to XOpenDisplay. Value display must be ch
ecked to ensure this function was successful.
        at line 73 of hw/dmx/examples/xbell.c in function 'main'.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-11-17 18:43:39 -08:00
Alan Coopersmith
d00594ebc7 AddInputDevice: only need to check once if we failed to calloc dev
Resolves warning from Oracle Parfait static analyser:

Warning: Impossible or redundant condition
   Impossible or redundant condition [impossible-redundant-condition]:
      Condition 'dev != NULL' of branch is determined by previous branch
        at line 270 of dix/devices.c in function 'AddInputDevice'.
          Condition 'dev != NULL' from this branch implies following branch is always true at line 262

Fixes: commit 493ad83323
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-11-17 18:43:39 -08:00
Michel Dänzer
250db8708a xwayland: Add and hook up test script
It runs XTS via piglit on (non-rootless) Xwayland on weston using the
headless backend.

Xwayland might use glamor if enabled in the build, but we're making sure
it uses software rendering.

v2:
* Use weston-info to wait for weston to be ready, instead of just a
  fixed sleep. (Martin Peres)
v3:
* Build wayland 1.18 & weston 9.0 locally, since the packages in Debian
  buster are too old for current Xwayland.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-17 18:21:37 +01:00
Michel Dänzer
821399a9c9 ci: Base docker image on Debian buster instead of testing
By its nature, testing incurs a risk of breaking something every time
we bump the image.

This requires building wayland-protocols locally, since the package in
buster is too old for current Xwayland.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-17 18:20:52 +01:00
Michel Dänzer
ab73c16930 ci: Update to the latest templates
They now ensure the image is up to date in forked projects, and we no
longer need to reconstruct the image name.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-17 18:20:19 +01:00
Michel Dänzer
852d6d4910 ci: Explicitly list packages needed to build xserver
Instead of relying on apt-get build-dep.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-17 18:19:17 +01:00
Michel Dänzer
8469935fe2 ci: Use a variable for ephemeral packages
So that they only need to be listed once.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-17 18:18:20 +01:00
Michel Dänzer
996ba1b99a ci: Remove rendercheck Git tree
Noticed this was missing while making changes in this area.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-17 18:18:05 +01:00