Commit Graph

16841 Commits

Author SHA1 Message Date
Michel Dänzer
ed44f9cd6a Drop Travis Linux build in favour of GitLab CI
Fold build-travis-deps.sh into .gitlab-ci.yml.

Preparation for the next change, which would break the Travis Linux
build.

Reviewed-by: Eric Anholt <eric@anholt.net>
2018-12-17 15:40:52 +01:00
Jon Turney
0e541b1093 meson: Add misc unit tests
v2:
has_link_argument requires meson 0.46.0
2018-12-14 11:32:31 +00:00
Peter Hutterer
fde27b9b48 test: fix failing tests
Broken since 69d8ea4a49 because our fake screen
didn't have a root window and writing the XKB rules prop would happily
segfault. Fix this by setting up the required bits.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Michel Dänzer michel.daenzer@amd.com
2018-12-14 10:49:23 +10:00
Michel Daenzer
a7472da941 Make artifacts of piglit results if job fails
Can be useful for figuring out what caused the failure.
2018-12-12 18:41:54 +01:00
Michel Daenzer
c1bb392b1d travis: Use a single meson invocation
The prefix setting didn't take for some reason.
2018-12-12 12:55:57 +01:00
Olivier Fourdan
c731165402 dix: cache ResourceClientBits() value
The `LimitClient` is set once and for all at startup, whereas the
function `ResourceClientBits()` which returns the client field offset
within the XID based on the value of `LimitClient` can be called
repeatedly.

Small optimization, cache the result of `ilog2()`, that saves running
the same loop over and over each time `ResourceClientBits()` is called.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2018-12-11 18:41:33 +00:00
Ilia Mirkin
48b1af2718 modesetting: fix conn_id termination and potential overrun by 1 byte
Noticed when porting this logic to xf86-video-nouveau, and valgrind
complained about conditional jump based on uninitialized data.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2018-12-11 13:34:56 -05:00
Adam Jackson
899d260701 ci: Work around broken python UTF8 handling in the CI docker image
Gitlab very kindly exposes the details of the git commit message (among
much else) in the environment. Unfortunately, piglit tries to handle the
environment in non-UTF8-safe ways, which means if the top-of-tree commit
mentions non-ASCII characters (say, in the author's name) then all the
tests fail and so does the pipeline.

Fortunately none of those variables are things our piglit invocation
needs. Since I've failed to rebuild the docker image as yet, just clear
the likely variables from the environment before running piglit.

This-makes-me: ☹
2018-12-11 12:41:26 -05:00
Adam Jackson
82ed89c0f8 automake: Distribute meson's configure header templates
Fixes: xorg/xserver#17
2018-11-29 14:48:11 -05:00
Lionel Landwerlin
a425eee6dc present: fix compile warning with debug traces
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
2018-11-29 16:54:45 +00:00
Lyude Paul
7a44e8d400 modesetting: Actually disable CRTCs in legacy mode
Believe it or not, somehow we've never done this in legacy mode! We
currently simply change the DPMS property on the CRTC's output's
respective DRM connector, but this means that we're just setting the
CRTC as inactive-not disabled. From the perspective of the kernel, this
means that any shared resources used by the CRTC are still in use.

This can cause problems for drivers that are not yet fully atomic,
despite using the atomic helpers internally. For instance: if CRTC-1 and
CRTC-2 are still enabled and use shared resources within the kernel (an
MST topology, for example), and then userspace tries to go enable CRTC-3
on the same topology this might suddenly fail if CRTC-3 needs the shared
resources CRTC-1 and CRTC-2 are using. While I don't know of any
situations in the mainline kernel that actually trigger this, future
plans for reworking the atomic check of MST drivers are absolutely
going to make this into a real issue (they already are in my WIP
branches for the kernel).

So: actually do the right thing here and disable CRTCs when they're not
going to be used anymore, even in legacy mode.

Signed-off-by: Lyude Paul <lyude@redhat.com>
2018-11-29 16:21:26 +00:00
Alan Coopersmith
17a22ad948 Update configure.ac bug URL for gitlab migration
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-11-25 12:59:41 -08:00
Alan Coopersmith
5d097c2a20 Update README for gitlab migration
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-11-25 20:55:11 +00:00
Michel Dänzer
e6cd1c9bde xwayland: Don't take buffer release queue into account for frame timer
The buffer release queue has two kinds of entries:

* Pending async flips.
* Completed flips waiting for their buffer to be released by the Wayland
  compositor.

xwl_present_timer_callback neither completes async flips nor releases
buffers, so the timer isn't needed for the buffer release queue.
2018-11-19 20:57:15 +00:00
Michel Dänzer
f541615342 xwayland: Don't need xwl_window anymore in xwl_present_queue_vblank
Fixes issue #12. Presumably the problem was that Present operations on
unmapped windows were executed immediately instead of only when reaching
the target MSC.
2018-11-19 20:57:15 +00:00
Michel Dänzer
8c9538573c xwayland: Add xwl_present_unrealize_window
When a window is unrealized, a pending frame callback may never be
called, which could result in repeatedly freezing until the frame timer
fires after a second.

Fixes these symptoms when switching from fullscreen to windowed mode in
sauerbraten.
2018-11-19 20:57:15 +00:00
Michel Dänzer
6b016d58d2 xwayland: Replace xwl_window::present_window with ::present_flipped
There's no need to keep track of the window which last performed a
Present flip. This fixes crashes due to the assertion in
xwl_present_flips_stop failing. Fixes issue #10.

The damage generated by a flip only needs to be ignored once, then
xwl_window::present_flipped can be cleared. This may fix freezing in
the (hypothetical) scenario where Present flips are performed on a
window, followed by other drawing requests using the window as the
destination, but nothing triggering xwl_present_flips_stop. The damage
from the latter drawing requests would continue being ignored.
2018-11-19 20:57:15 +00:00
Ray Strode
8738ce85df dix: ensure work queues are cleared on reset
If the server resets, most client workqueues are cleaned up as the
clients are killed.

The one exception is the server's client, which is exempt from
the killing spree.

If that client has a queued work procedure active, it won't get
cleared on reset.

This commit ensures it gets cleared too.
2018-11-19 19:37:10 +00:00
Samuel Thibault
364d649815 dix: do not send focus event when grab actually does not change
c67f2eac56 ("dix: always send focus event on grab change") made dix
always sent events when it's a NotifyGrab or NotifyUngrab, even if
from == to, because 'from' can just come from a previous XSetInputFocus
call.

However, when an application calls XGrabKeyboard several times on
the same window, we are now sending spurious FocusOut+FocusIn with
NotifyGrab, even if the grab does not actually change. This makes screen
readers for blind people spuriously emit activity events which disturb
screen reading workflow when e.g. switching between menus.

This commit avoids calling DoFocusEvents in that precise case, i.e. when
oldWin is a previous grab and the new grab is the same window.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-11-19 13:56:51 -05:00
Manoj Gupta
82f8cf8990 config/udev: Include header <sys/sysmacros.h> to use major/minor
glibc 2.25 has dropped sys/sysmacros.h from sys/types.h, so add
it explicitly in config/udev.c.

This is similar to the commit 84e3b96b53

Signed-off-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-11-14 10:26:48 -05:00
Michal Srb
fbdd4d679a dix/window: Use ConfigureWindow instead of MoveWindow
The screensaver can regularly move its window to random offsets. It should
use the ConfigureWindow function instead of calling the Screen's MoveWindow
directly. Some MoveWindow implementations, such as compMoveWindow, rely on
Screen's ConfigNotify being called first as it happens in ConfigureWindow.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-11-13 11:02:41 -05:00
Adam Jackson
23752b3ef8 os: Establish new connections synchronously not on the work queue
This contortion made a bit more sense before we got SetNotifyFd and
friends, but now there's no need for it.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-11-13 10:36:40 -05:00
Adam Jackson
69d8ea4a49 xkb: Write the _XKB_RULES_NAMES window property synchronously
I can't think of a good reason why this would need to be deferred to the
work queue. When we get to this point we're never in the middle of
request processing, so we can't corrupt the event/reply stream.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-11-13 10:36:18 -05:00
Adam Jackson
0a95a8ae62 xwayland: Move command line fd initialization to InitOutput
Again, as this is DDX state not screen state, run it from DDX setup not
screen setup.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-11-13 10:06:03 -05:00
Adam Jackson
08843efc59 xwayland: Move wm_fd and listen_fds out of xwl_screen
There are logically server state not screen state. Not that multiple
screens works, at the moment, but that's no excuse to be sloppy.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-11-13 10:06:03 -05:00
Marco Trevisan (Treviño)
2118e4471b dix/events: reuse grab pointer value 2018-11-12 02:57:10 +00:00
Marco Trevisan (Treviño)
35e5a76cc1 Xi: Use current device active grab to deliver touch events if any
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-12 02:57:10 +00:00
Alan Coopersmith
700505144f Remove obsolete B16 & B32 tags in struct definitions
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-11-10 15:00:31 -08:00
Michel Dänzer
6ef025a872 Revert "dix: Work around non-premultiplied ARGB cursor data harder"
This reverts commit b45c74f0f2.

It broke the cursor in other games. Apparently those use cursor data
with premultiplied alpha, but with some pixels having r/g/b values
larger than the alpha value (which corresponds to original r/g/b
values > 1.0), triggering the workaround.

Seems the cure turned out worse than the disease, so revert.

Bugzilla: https://bugs.freedesktop.org/108650
2018-11-06 11:33:19 +01:00
Adam Jackson
c901adc327 modesetting: Hush an unimportant log message
Verbosity level 0 is "always print", just make it a normal message.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-10-31 11:43:33 -04:00
Adam Jackson
52451f1f89 dix: De-ugly the prototype for Add{GPU,}Screen 2018-10-30 12:21:41 -04:00
Eric Anholt
e50c85f4eb Fix segfault on probing a non-PCI platform device on a system with PCI.
Some Broadcom set-top-box boards have PCI busses, but the GPU is still
probed through DT.  We would dereference a null busid here in that
case.

Signed-off-by: Eric Anholt <eric@anholt.net>
2018-10-29 15:51:44 +00:00
Adam Jackson
3297a1c871 include: Remove ___CLIENTSIGNALALL_DEFINED___ copypasta
___CLIENTSIGNAL_DEFINED___ is a hack to work around the declaration of
ClientSignal both in our own headers and in <X11/include/fontproto.h>,
the latter of which is properly part of libXfont (1, only) but packaged
in xorgproto because we have made some mistakes. ClientSignalAll needs
no such workaround.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2018-10-25 12:32:48 -04:00
Adam Jackson
06f448d4af include: Stop including <X11/fonts/fontproto.h>
Despite being packaged in xorgproto (formerly fontsproto), fontproto.h
is actually a list of the ABI libXfont version 1 expected of the X
server. We switched to libXfont2 three years ago, this is unnecessary.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2018-10-25 12:32:48 -04:00
Michel Dänzer
ace551d8a2 xwayland: Complete "synchronous" Present flips from xwl_present_msc_bump
Completing them from xwl_present_sync_callback had at least two issues:

* It was before the MSC was incremented in xwl_present_frame_callback,
  so the MSC value in the completion event could be lower than the
  target specified by the client. This could cause hangs with the Mesa
  Vulkan drivers.
* It allowed clients to run at a frame-rate higher than the Wayland
  compositor's frame-rate, wasting energy on generating frames which
  were never displayed. This isn't expected to happen unless the client
  specified PresentOptionAsync (in which case flips are still completed
  from xwl_present_sync_callback, allowing higher frame-rates).

v2:
* Make xwl_present_has_events return true when there's a pending
  "synchronous" flip, so those complete after at most ~1 second even if
  the Wayland server doesn't send a frame event.

Bugzilla: https://bugs.freedesktop.org/106713
2018-10-25 15:35:30 +00:00
Michel Dänzer
2bfc46d414 xwayland: Rename xwl_present_events_notify to xwl_present_msc_bump
And consolidate more code from xwl_present_timer_callback and
xwl_present_frame_callback in it.
2018-10-25 15:35:30 +00:00
Michel Dänzer
5e8b9a3a56 xwayland: Use xwl_present_reset_timer in xwl_present_timer_callback
Apart from simplifying the code, this should also prevent a condition
(which might only be possible with the following fix) reported in
https://gitlab.freedesktop.org/wayland/weston/issues/115#note_52467:

1. xwl_present_timer_callback indirectly calls xwl_present_reset_timer
   -> xwl_present_free_timer
2. xwl_present_timer_callback then returns a non-0 value, so DoTimer
   calls TimerSet with the old xwl_present_window->frame_timer pointer
   which was freed in step 1 => use after free

Calling xwl_present_reset_timer explicitly passes NULL to TimerSet if
step 1 freed xwl_present_window->frame_timer, and it will allocate a new
one.
2018-10-25 15:35:30 +00:00
Olivier Fourdan
036794bebc xwayland: do not crash if gbm_bo_create() fails
The function `xwl_glamor_gbm_create_pixmap()` first creates a buffer
objects and then creates the xwl_pixmap from it.

However, `xwl_glamor_gbm_create_pixmap_for_bo()` is not called if the
buffer object creation fails, and `xwl_glamor_gbm_create_pixmap()`
simply returns `glamor_create_pixmap()`.

The problem with this is that if `xwl_glamor_gbm_create_pixmap_for_bo()`
is not called then neither is `xwl_pixmap_set_private()` and further
calls to `xwl_pixmap_get()` will return NULL and cause a NULL pointer
dereference if the return value is not checked:

  #0  xwl_glamor_gbm_get_wl_buffer_for_pixmap ()
      at hw/xwayland/xwayland-glamor-gbm.c:248
  #1  xwl_window_post_damage () at hw/xwayland/xwayland.c:697
  #2  xwl_display_post_damage () at hw/xwayland/xwayland.c:759
  #3  block_handler () at hw/xwayland/xwayland.c:890
  #4  BlockHandler () at dix/dixutils.c:388
  #5  WaitForSomething () at os/WaitFor.c:201
  #6  Dispatch () at dix/dispatch.c:421
  #7  dix_main () at dix/main.c:276
  #8  __libc_start_main () at ../csu/libc-start.c:308
  #9  _start ()

  (gdb) print xwl_pixmap
  $1 = (struct xwl_pixmap *) 0x0

Make sure we check for `xwl_pixmap_get()` returned value where relevant
and fail gracefully if this is the case.

See also: https://gitlab.gnome.org/GNOME/mutter/issues/340

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Marco Trevisan <mail@3v1n0.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-25 15:32:34 +00:00
Olivier Fourdan
32abc22288 present: Remove present_event_abandon()
This has never been actually implemented, do not tempt people to use it.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Daenzer <michel.daenzer@amd.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-25 15:05:12 +00:00
Olivier Fourdan
b768b7d6ce present/wnmd: Fix use after free on CRTC removal
Xwayland will add and remove CRTCs as Wayland outputs are added or
removed.

If there is a pending flip when this occurs, the
`xwl_present_sync_callback()` will be triggered after the Xwayland
output's RRCtrcPtr has been destroyed, hence causing a crash in Xwayland
while trying to use freed memory:

  #1  abort ()
  #2  OsAbort () at utils.c:1350
  #3  AbortServer () at log.c:877
  #4  FatalError () at log.c:1015
  #5  OsSigHandler () at osinit.c:156
  #6  <signal handler called>
  #7  dixGetPrivate () at ../include/privates.h:122
  #8  dixLookupPrivate () at ../include/privates.h:166
  #9  present_screen_priv () at present_priv.h:198
  #10 present_wnmd_flip () at present_wnmd.c:358
  #11 present_wnmd_execute () at present_wnmd.c:466
  #12 present_wnmd_re_execute () at present_wnmd.c:80
  #13 xwl_present_sync_callback () at xwayland-present.c:287
  #14 ffi_call_unix64 () from /lib64/libffi.so.6
  #15 ffi_call () from /lib64/libffi.so.6
  #16 wl_closure_invoke () at src/connection.c:1006
  #17 dispatch_event () at src/wayland-client.c:1427
  #18 dispatch_queue () at src/wayland-client.c:1573
  #19 wl_display_dispatch_queue_pending () at src/wayland-client.c:1815
  #20 wl_display_dispatch_pending () at src/wayland-client.c:1878
  #21 xwl_read_events () at xwayland.c:814
  #22 ospoll_wait () at ospoll.c:651
  #23 WaitForSomething () at WaitFor.c:208
  #24 Dispatch () at ../include/list.h:220
  #25 dix_main () at main.c:276

To avoid the issue, get the `ScreenPtr` from the window instead of the
CRTC that might have been just freed, `xwl_present_flip()` has no use
for the CRTC anyway.

Bugzilla: https://bugs.freedesktop.org/108249
Suggested-by: Michel Daenzer <michel.daenzer@amd.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Daenzer <michel.daenzer@amd.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-25 15:05:12 +00:00
Adam Jackson
8d048a1fd3 os: Factor out CHECK_FOR_REQUIRED_ARGUMENTS
Lifted from vfb. xfree86 had almost the same thing but unparameterized,
port it to the vfb style.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-10-25 14:46:44 +00:00
Michel Dänzer
b45c74f0f2 dix: Work around non-premultiplied ARGB cursor data harder
Turns out some apps (e.g. the Civilization VI game) use
non-premultiplied cursor data which doesn't have any pixels with 0 alpha
but non-0 non-alpha, but can still result in visual artifacts.

This uses the method suggested by Kamil in
https://bugs.freedesktop.org/92309#c19: check for pixels where any
colour component value is larger than the alpha value, which isn't
possible with premultiplied alpha.

There can still be non-premultiplied data which won't be caught by this,
but that should result in slightly incorrect colours and/or blending at
the worst, not wildly incorrect colours such as shown in the bug report
below.

Bugzilla: https://bugs.freedesktop.org/108355
Suggested-by: Kamil Paral <kamil.paral@gmail.com>
2018-10-25 14:33:09 +00:00
Matthieu Herrb
248d164eae LogFilePrep: add a comment to the unsafe format string.
CVE-2018-14665 also made it possible to exploit this to access
memory. With -logfile forbidden when running with elevated privileges
this is no longer an issue.

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-10-25 09:17:11 -04:00
Matthieu Herrb
50c0cf885a Disable -logfile and -modulepath when running with elevated privileges
Could cause privilege elevation and/or arbitrary files overwrite, when
the X server is running with elevated privileges (ie when Xorg is
installed with the setuid bit set and started by a non-root user).

CVE-2018-14665

Issue reported by Narendra Shinde and Red Hat.

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-10-25 09:17:05 -04:00
Andreas Fett
08ff37d05a os/xdmcp: Fix binding of ipv6 source address
Choose the socket fd of the correct address family based
on the address family of the argument to the -from option.

Fixes: xorg/xserver#4
2018-10-24 19:29:29 +00:00
Adam Jackson
96e00730e7 xfree86: bump video ABI version to 25.0
Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-10-24 15:11:54 -04:00
Michel Dänzer
cb0de153bf xwayland: Plug leaks in xwl_present_sync_callback
xwl_present_window->sync_callback was leaked.

The event memory was leaked if the corresponding buffer had already been
released.
2018-10-24 09:53:36 +00:00
Adam Jackson
53d32c94f3 dix: Remove the magic WhenMapped backing store hack
Automatic compositing exists, if that's what you want then use it.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-10-23 18:37:46 +00:00
Michel Dänzer
382c26dade glamor: Add support for exporting depth 15/8 pixmaps
This allows X to run with glamor at these depths.
2018-10-23 17:00:50 +00:00
Olivier Fourdan
a2d188c7db xwayland: keep xwl_present_timer_callback() private
`xwl_present_timer_callback()` is initially marked a private and later
implemented as public.

Let's keep that private, shall we.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2018-10-18 17:59:08 +00:00