Commit Graph

2200 Commits

Author SHA1 Message Date
Matthieu Herrb
4979ac8f0b fix for ZDI-11426
Avoid leaking un-initalized memory to clients by zeroing the
whole pixmap on initial allocation.

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

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit a6b2cbe91793ae4967cd21a7103d889248029553)
2020-08-18 04:26:45 +00:00
Samuel Thibault
271934db9f 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>
(cherry picked from commit 364d649815)
2020-04-15 13:29:19 +02:00
Arthur Williams
3c48bd50ad dix: Check for NULL spriteInfo in GetPairedDevice
There is a race when reseting the XServer that causes spriteInfo to be
NULL in GetPairedDevice resulting a segfault and subsequent crash. The
problem was noticed when opening a connection, creating master devices,
destroying master devices and closing the connection during testing.

Signed-off-by: Arthur Williams <taaparthur@gmail.com>


(cherry picked from commit e693c9657f)
2020-03-07 21:36:04 +00:00
Aaron Plattner
2edadf26f1 os: Don't crash in AttendClient if the client is gone
If a client is in the process of being closed down, then its client->osPrivate
pointer will be set to NULL by CloseDownConnection. This can cause a crash if
freeing the client's resources results in a call to AttendClient. For example,
if the client has a pending sync fence:

 Thread 1 "X" received signal SIGSEGV, Segmentation fault.
 AttendClient (client=0x5571c4aed9a0) at ../os/connection.c:942
 (gdb) bt
 #0  AttendClient (client=0x5571c4aed9a0) at ../os/connection.c:942
 #1  0x00005571c3dbb865 in SyncAwaitTriggerFired (pTrigger=<optimized out>) at ../Xext/sync.c:694
 #2  0x00005571c3dd5749 in miSyncDestroyFence (pFence=0x5571c5063980) at ../miext/sync/misync.c:120
 #3  0x00005571c3dbbc69 in FreeFence (obj=<optimized out>, id=<optimized out>) at ../Xext/sync.c:1909
 #4  0x00005571c3d7a01d in doFreeResource (res=0x5571c506e3d0, skip=skip@entry=0) at ../dix/resource.c:880
 #5  0x00005571c3d7b1dc in FreeClientResources (client=0x5571c4aed9a0) at ../dix/resource.c:1146
 #6  FreeClientResources (client=0x5571c4aed9a0) at ../dix/resource.c:1109
 #7  0x00005571c3d5525f in CloseDownClient (client=0x5571c4aed9a0) at ../dix/dispatch.c:3473
 #8  0x00005571c3d55eeb in Dispatch () at ../dix/dispatch.c:492
 #9  0x00005571c3d59e96 in dix_main (argc=3, argv=0x7ffe7854bc28, envp=<optimized out>) at ../dix/main.c:276
 #10 0x00007fea4837cb6b in __libc_start_main (main=0x5571c3d1d060 <main>, argc=3, argv=0x7ffe7854bc28, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe7854bc18) at ../csu/libc-start.c:308
 #11 0x00005571c3d1d09a in _start () at ../Xext/sync.c:2378
 (gdb) print client->osPrivate
 $1 = (void *) 0x0

Since the client is about to be freed, its ignore count doesn't matter and
AttendClient can simply be a no-op. Check for client->clientGone in AttendClient
and remove similar checks from two callers that had them.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
(cherry picked from commit 4308f5d3d1)
2019-11-20 11:18:28 -08:00
Adam Jackson
68cfee97bc dix: Call SourceValidate before GetImage
This ensures that any prep work for the drawable we're about to read
from is already done before we call down to GetImage. This should be no
functional change as most of the callers with a non-trivial
SourceValidate are already wrapping GetImage and doing the equivalent
thing, but we'll be simplifying that shortly.

More importantly this ensures that if any of that prep work would
generate events - like automatic compositing flushing rendering to a
parent pixmap which then triggers damage - then it happens entirely
before we start writing the GetImage reply header.

Note that we do not do the same for GetSpans, but that's okay. The only
way to get to GetSpans is through miCopyArea or miCopyPlane - where the
callers must already call SourceValidate - or miGetImage - which this
commit now protects with SourceValidate.

Fixes: xorg/xserver#902
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
(cherry picked from commit 516e75dbb6)
2019-11-18 14:23:38 -05:00
Adam Jackson
2320fd4b52 mi: Add a default no-op miSourceValidate
Slightly simplifies the callers since they don't need to check for
non-NULL anymore.

I do extremely hate the workarounds here to suppress misprite taking the
cursor down though. Surely there's a better way.

[1.20: Do not in fact simplify the callers as above, since it would
change the ABI. - ajax]

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
(cherry picked from commit ff310903f3)
2019-11-18 14:23:15 -05:00
Matt Turner
fada61e89d dix: Assert noPanoramiXExtension is false in PanoramiX code
When compiling with link time optimization, GCC thinks it's discovered
undefined behavior:

events.c: In function 'XineramaConfineCursorToWindow':
events.c:609:13: warning: iteration 2147483647 invokes undefined behavior [-Waggressive-loop-optimizations]
events.c:609:11: note: within this loop
events.c:605:49: warning: array subscript -1 is below array bounds of 'struct _Window *[16]' [-Warray-bounds]
events.c:606:31: warning: array subscript -1 is below array bounds of 'struct _Screen *[16]' [-Warray-bounds]
events.c:610:39: warning: array subscript -2 is below array bounds of 'struct _Screen *[16]' [-Warray-bounds]
events.c:617:38: warning: array subscript -2 is below array bounds of 'struct _Window *[16]' [-Warray-bounds]
events.c:619:35: warning: array subscript -2 is below array bounds of 'struct _Screen *[16]' [-Warray-bounds]

This results from

    i = PanoramiXNumScreens - 1;

    RegionCopy(&pSprite->Reg1, &pSprite->windows[i]->borderSize);
    off_x = screenInfo.screens[i]->x;
    off_y = screenInfo.screens[i]->y;

where GCC believes that PanoramiXNumScreens might be 0. Unfortunately
GCC is just smart enough to be an annoyance because this case is not
actually possible: XineramaConfineCursorToWindow() is only called when
noPanoramiXExtension is false, and if noPanoramiXExtension is false then
PanoramiXNumScreens must be >1 (see PanoramiXExtensionInit()).

So, add an assert(!noPanoramiXExtension), which to my surprise provides
GCC with information even in release builds and lets GCC understand that
the code is not doing anything that is undefined behavior.

I chose this solution instead of the proposed assert(i >= 0) because the
same pattern occurs in CheckVirtualMotion() but is inside an
'if (!noPanoramiXExtension)' and does not generate any warnings.

Fixes: xorg/xserver#590
Signed-off-by: Matt Turner <mattst88@gmail.com>
(cherry picked from commit 61aa40aeb3)
2019-10-29 15:01:20 -07:00
Peter Hutterer
240868527b dix: leave last.valuators alone on slave switch
Terms:
dev->last.valuator[] is the last value given to us by the driver
dev->valuator.axisVal[] is the last value sent to the client
dev->last.scroll[] is the abs value of the scroll axis as given by the driver,
        used for button emulation calculation (and the remainder)

This function updates the device's last.valuator state based on the current
master axis state. This way, relative motion continues fluidly when switching
between devices. Before mouse 2 comes into effect, it's valuator state is
updated to wherever the pointer currently is so the relative event applies on
top of that.

This can only work for x/y axes, all other axes aren't guaranteed to have the
same meaning and/or may not be present:
- xtest device: no valuator 2
- mouse: valuator 2 is horizontal scroll axis
- tablet: valuator 2 is pressure

Scaling the current value from the pressure range into the range for
horizontal scrolling makes no sense. And it causes scroll jumps:

- scroll down, last.valuator == axisVal == 20
- xdotool click 1, the XTest device doesn't have that valuator
- scroll up
  - updateSlaveDeviceCoords reset last.valuator to 0 (axisVal == 20)
  - DeviceClassesChangedEvent includes value 20 for the axis
  - event is processed, last.value changes from 0 to -1
  - axisVal is updated to -1, causing a jump of -21

The same applies when we switch from tablet to mouse wheel if the pressure
value is 0 on proximity out (basically guaranteed). So let's drop this code
altogether and only leave the scaling for the relative x/y motion.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit d7b1753d44)
2019-05-28 14:21:57 -04:00
Ray Strode
34553f5026 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.

(cherry picked from commit 8738ce85df)

Fixes: xorg/xserver#670
2019-03-21 10:29:04 -04:00
Dave Airlie
cc4051ad6a devices: break after finding and removing device from lists
Coverity complains about a use after free in here after the
freeing, I can't follow the linked list so well, but whot
says the device can only be on one list once, so break should
fix it.

Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit ba0f5d854f)
2018-10-04 17:26:57 +02:00
Peter Hutterer
051a0efc5c dix: check_modmap_change() returns Success, not true
Not sure what if anything calls XSetDeviceModifierMapping() but this would've
failed all the time. check_modmap_change() returns Success but we were
treating it like a boolean. Fix this.

Reported-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 4fe02b8da3)
2018-10-04 17:23:48 +02:00
Eric Anholt
e1ccd0fa0e dix: Fix a warning about GetTimeInMillis return value in XFont2.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-05-08 11:59:28 -04:00
Adam Jackson
fc25bceb51 dix: Allow an extension to disable itself
GLX registers an extension before we know if there are any screens that
can actually do it. It's inconvenient to shrink the extension list, so
instead allow the extension to simply zero out its base opcode to
indicate that it needed to panic and disable itself.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-04-24 14:36:04 -04:00
Adam Jackson
73a1cb9c92 dix: Factor out extension availability check
Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-04-24 14:36:03 -04:00
Samuel Thibault
c67f2eac56 dix: always send focus event on grab change
Focus events are useless when 'from' and 'to' are the same.  But when
this is the result of a (Un)GrabKeyboard request, we should always send
them, including when the window manager had previously used XSetInputFocus
to specify the focus on a window which happens to be now taking a grab.

This is notably needed for window manager using XI to always get keyboard
events even during grabs, so they can determine exactly when grabbing is
active.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-10 14:50:08 -04:00
Adam Jackson
6f0903ddc9 dix: Hush an almost certainly bogus warning
../dix/getevents.c: In function ‘transformAbsolute’:
../dix/getevents.c:1195:28: warning: ‘oy’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     struct pixman_f_vector p = {.v = {*x, *y, 1} };
                            ^
../dix/getevents.c🔢22: note: ‘oy’ was declared here
     double x, y, ox, oy;
                      ^~

This one is truly special. Even though both ox and oy are set and read
along the same paths, only oy is marked for this warning! Initializing
just oy = 0.0 fixes it entirely, but let's not make a weird thing
weirder.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2018-04-05 14:18:52 -04:00
Adam Jackson
ab063cf967 meson: Fix installing protocol.txt
One fix the constructed path, two actually install it.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2018-03-27 10:13:18 -04:00
Emil Velikov
85ff1cdbd3 protocol.txt: add GLX req. 35 - SetClientInfo2ARB
Noticed while skimming for the typo'd version ;-)

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-27 13:08:35 -05:00
Olivier Fourdan
9f7a9be13d dix: avoid deferencing NULL PtrCtrl
PtrCtrl really makes sense for relative pointing device only, absolute
devices such as touch devices do not have any PtrCtrl set.

In some cases, if the client issues a XGetPointerControl() immediatlely
after a ChangeMasterDeviceClasses() copied the touch device to the VCP,
a NULL pointer dereference will occur leading to a crash of Xwayland.

Check whether the PtrCtrl is not NULL in ProcGetPointerControl() and
return the default control values otherwise, to avoid the NULL pointer
dereference.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1519533
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2017-12-06 11:59:28 -05:00
Adam Jackson
2e7f790b57 dix: Remove ffs.c
Your libc has ffs, I promise.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2017-11-06 17:22:46 -05:00
Giuseppe Bilotta
2dafa1bdaf dix/window: fix typos
Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-11-06 16:46:32 -05:00
Daniel Martin
d5379b350f Use ARRAY_SIZE all over the tree
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-30 13:45:20 -04:00
Nathan Kidd
b747da5e25 Unvalidated extra length in ProcEstablishConnection (CVE-2017-12176)
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-10 23:33:44 +02:00
Michel Dänzer
8e3b26ceaa Make PixmapDirtyUpdateRec::src a DrawablePtr
This allows making the master screen's pixmap_dirty_list entries
explicitly reflect that we're now tracking the root window instead of
the screen pixmap, in order to allow Present page flipping on master
outputs while there are active slave outputs.

Define HAS_DIRTYTRACKING_DRAWABLE_SRC for drivers to check, but leave
HAS_DIRTYTRACKING_ROTATION defined as well to make things slightly
easier for drivers.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-08-15 17:01:39 +09:00
Jan Beich
abe49b0090 dix: unbreak --with-dtrace (default) on FreeBSD 11.1+
gmake[2]: Entering directory '/path/to/xserver/dix'
/usr/sbin/dtrace -G -C -o dtrace-dix.o -s ../dix/Xserver.d .libs/atom.o ...
dtrace: failed to compile script ../dix/Xserver.d: line 26: useless declaration
gmake[2]: *** [Makefile:1007: dtrace-dix.o] Error 1

Signed-off-by: Jan Beich <jbeich@FreeBSD.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2017-07-31 13:32:35 -04:00
Adam Jackson
f44e0af4da dix: Remove extension aliases
This appears to be essentially unused. The only known client-side
library for the SELinux extension is xcb, which does not look for the
name "Flask". The "SGI-GLX" alias for GLX appears to be a bit of
superstition at this point, NVIDIA's driver does not expose it and Mesa
does not check for it.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2017-06-20 16:37:24 -04:00
Michal Srb
215f894965 dix: Disallow GenericEvent in SendEvent request.
The SendEvent request holds xEvent which is exactly 32 bytes long, no more,
no less. Both ProcSendEvent and SProcSendEvent verify that the received data
exactly match the request size. However nothing stops the client from passing
in event with xEvent::type = GenericEvent and any value of
xGenericEvent::length.

In the case of ProcSendEvent, the event will be eventually passed to
WriteEventsToClient which will see that it is Generic event and copy the
arbitrary length from the receive buffer (and possibly past it) and send it to
the other client. This allows clients to copy unitialized heap memory out of X
server or to crash it.

In case of SProcSendEvent, it will attempt to swap the incoming event by
calling a swapping function from the EventSwapVector array. The swapped event
is written to target buffer, which in this case is local xEvent variable. The
xEvent variable is 32 bytes long, but the swapping functions for GenericEvents
expect that the target buffer has size matching the size of the source
GenericEvent. This allows clients to cause stack buffer overflows.

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-19 11:58:50 +10:00
Carlos Garnacho
f065721e6f dix: assume warping on the RootWindow always happens on visible coords
If the root window borderClip region is null, the PointInWindowIsVisible()
check fails if pointer warping is attempted on the root window, making
the warping operation bail out early.

Assume coordinates always lay inside the root window for this case,
the actual position will be clamped later within screen coordinates anyway.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-07 14:34:29 +10:00
Keith Packard
d9e23ea422 dix: Remove clients from input and output ready queues after closing
Delay removing the client from these two queues until all potential
I/O has completed in case we mark the client as ready for reading or
with pending output during the close operation.

Bugzilla: https://bugs.freedesktop.org/100957
Signed-off-by: Keith Packard <keithp@keithp.com>
Tested-by: Nick Sarnie <commendsarnex@gmail.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-05-12 00:21:16 -07:00
Eric Anholt
1549e30372 Add a Meson build system alongside autotools.
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>
2017-04-26 15:25:27 -07:00
Eric Anholt
ace6bfd590 dix: Remove a redundant #define
Found when the meson conversion set the symbol to defined, instead of
defined to 1.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2017-04-26 17:29:44 -04:00
Adam Jackson
3360418767 dpms: Consolidate a bunch of stuff into Xext/dpms.c
Most of this is a legacy of the old "extmod" design where you could load
_some_ extensions dynamically but only if the server had been built with
support for them in the first place.

Note that since we now only initialize the DPMS extension if at least
one screen supports it, we no longer need DPMSCapableFlag: if it would
be false, we would never read its value.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-03-27 15:59:47 -04:00
Adam Jackson
4e76c27117 dix: Remove PRIVATE_DAMAGE
None of this is actually wired up to anything, so we can also remove the
devPrivates from the DamageRec. The DamageExtRec is what would need
devPrivates for selinux labeling, in principle.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-03-21 11:20:26 -04:00
Adam Jackson
dc7ceda90f dispatch: Mark swapped dispatch as _X_COLD
This touches everything that ends up in the Xorg binary; the big missing
part is GLX since that's all generated code. Cuts about 14k from the
binary on amd64.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-03-01 10:16:20 -05:00
Adam Jackson
8e3f9ce6c0 dix: Add a callback chain for window property state change
This will be used by in-server features that need to react to property
changes. The first one will be _XWAYLAND_ALLOW_COMMITS.

Signed-off-by: Adam Jackson <ajax@redhat.com>
[Pekka: add commit message body]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-02-23 13:30:11 -05:00
Adam Jackson
50bcea8be3 dix: Pass the whole property into deliverPropertyNotifyEvent
Instead of just the atom.  No functional change.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-02-23 13:30:11 -05:00
Michel Dänzer
a6566f9e4d prime: Clear PixmapDirtyUpdateRec::damage when it's destroyed
The root window, and by extension any damage records referencing it,
may be destroyed before shared pixmaps referencing it, which resulted in
use-after-free / double-free in PixmapStopDirtyTracking.

Fixes: b5b292896f ("prime: Sync shared pixmap from root window instead of screen pixmap")
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2017-02-16 14:14:11 -05:00
Michel Dänzer
b5b292896f prime: Sync shared pixmap from root window instead of screen pixmap
The screen pixmap doesn't receive updates while there's a Present flip
window.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2017-02-08 12:08:51 -05:00
Keith Packard
785053d033 AttendClient of grab-pervious client must queue to saved_ready_clients [v2]
A client which is attended while a grab is blocking execution of its
requests needs to be placed in the saved_ready_clients list so that it
will get scheduled once the grab terminates. Otherwise, if the client
never sends another request, there is no way for it to be placed in
the ready_clients list.

v2: Wrap comment above mark_client_saved_ready.
    Remove test for OS_COMM_IGNORED which will always be true.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99333
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2017-01-11 14:31:43 -05:00
Mihail Konev
5b74e260e0 os,dix: Depend custom libs on libs, not objects
The custom os/os.O library reuses *.o files of os/libos.la.

The current rule assumes automake puts all the objects into per-target
am__*_la_OBJECTS variable.  At least with AC_REPLACE_FUNCS, this no
longer holds (as wanted objects are put into LTLIBOBJS instead).

Depend on automake's result, the *.la library instead, to express demand
of any its dependencies being built.

Should be fixing randomly occuring "undefined reference to `strlcpy'"
errors when linking Xvfb and other DDX-es that could use os.O.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Mihail Konev <k.mvc@ya.ru>
2017-01-02 12:45:28 -05:00
Adam Jackson
98caba9f56 dix: Clear graphicsExposures for scratch GCs in one place
... instead of in all the CreateScratchGC callers.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-12-12 14:09:59 -05:00
Adam Jackson
e900a00f8d dix: Rename (and retype) PixmapPerDepth[1] to defaultStipple
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-12-12 14:09:59 -05:00
Rui Matos
5611585b87 xwayland: Don't send KeyRelease events on wl_keyboard::leave
Commits 816015648f and
fee0827a9a made it so that
wl_keyboard::enter doesn't result in X clients getting KeyPress events
while still updating our internal xkb state to be in sync with the
host compositor.

wl_keyboard::leave needs to be handled in the same way as its
semantics from an X client POV should be the same as an X grab getting
triggered, i.e. X clients shouldn't get KeyRelease events for keys
that are still down at that point.

This patch uses LeaveNotify for these events on wl_keyboard::leave and
changes the current use of KeymapNotify to EnterNotify instead just to
keep some symmetry between both cases.

On ProcessDeviceEvent() we still need to deactivate X grabs if needed
for KeyReleases.

Signed-off-by: Rui Matos <tiagomatos@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-11-29 18:44:54 +10:00
Keith Packard
ea8efb3a99 dix: Make sure client is not in output_pending chain after closed (RH 1382444)
I think it is possible that output could get queued to a client during
CloseDownClient. After it is removed from the pending queue, active
grabs are released, the client is awoken if sleeping and any work
queue entries related to the client are processed.

To fix this, move the call removing it from the output_pending chain
until after clientGone has been set and then check clientGone in
output_pending_mark.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1382444
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-11-15 08:05:15 -08:00
Keith Packard
c85f81825e dix: Bump MAXHASHSIZE for the resource db [v2]
[This was originally a workaround for a client-side resource leak:

http://lists.freedesktop.org/archives/xorg-devel/2012-November/034555.html

Obviously that's a broken app, but the performance problem it
illustrates - that walking the linked list ends up burning all your CPU
time - is real enough. - ajax]

v2: Replace with a shorter code sequence which computes the same
    results for all but numBits == 7

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2016-10-28 09:28:32 -07:00
Peter Harris
97a8353ec1 Fix id in error when resource does not exist
Always set client->errorValue before returning an error.

Test program:

int main(int argc, char *argv[]) {
    int screen = 0;
    xcb_connection_t *c = xcb_connect(NULL, &screen);
    if (!c) {
        printf("Cannot connect\n");
        return 1;
    }

    xcb_void_cookie_t tok = xcb_free_gc_checked(c, BAD_VALUE);
    xcb_g_context_error_t *err = (xcb_g_context_error_t *)xcb_request_check(c, tok);
    if (!err) {
        printf("Unexpected request success\n");
        return 1;
    }
    if (err->bad_value != BAD_VALUE) {
        printf("Error: Got 0x%X, expected 0x%X\n", err->bad_value, BAD_VALUE);
        return 1;
    }
    printf("Success! Got expected bad value of 0x%X\n", BAD_VALUE);
    return 0;
}

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2016-10-06 14:50:42 -04:00
Jonas Ådahl
0fae3be068 dix: Add valuator_mask_set_absolute_unaccelerated
Add a valuator mask setter for setting absolute coordinate combined
with unaccelerated motion deltas. This will later be used by Xwayland
to combine a wl_pointer.motion() event with the unaccelerated delta of
a wp_relative_pointer.relative_motion() event.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-10-05 13:46:29 -04:00
Keith Packard
6c6f09aac7 xace: Don't censor window borders
GetImage is allowed to return window border contents, so don't remove
that from the returned image.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2016-09-28 15:25:07 -04:00
Jeremy Huddleston Sequoia
7d6ebf3f4e XQuartz: Adopt input_lock() and input_unlock()
This allows us to remove darwinEvents_lock() and darwinEvents_unlock()
and remove the serverRunning hack from dix

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2016-09-22 14:55:02 -07:00
Jeremy Huddleston Sequoia
2740dc1937 dix: Silence TSan warnings when checking for pending input
V2: Moves InputCheckPending() into dix.h

Bumps required version of xproto to 7.0.30

==================
WARNING: ThreadSanitizer: data race (pid=4943)
  Read of size 4 at 0x00010c4e3854 by thread T8:
    #0 WaitForSomething WaitFor.c:237 (X11.bin+0x00010049216c)
    #1 Dispatch dispatch.c:413 (X11.bin+0x000100352ed9)
    #2 dix_main main.c:287 (X11.bin+0x00010036e894)
    #3 server_thread quartzStartup.c:66 (X11.bin+0x000100039e63)

  Previous write of size 4 at 0x00010c4e3854 by thread T12 (mutexes: write M856, write M1976):
    #0 mieqEnqueue mieq.c:263 (X11.bin+0x000100448d14)
    #1 DarwinSendDDXEvent darwinEvents.c:641 (X11.bin+0x000100033613)
    #2 DarwinProcessFDAdditionQueue_thread darwinEvents.c:338 (X11.bin+0x000100032039)

  Location is global 'miEventQueue' at 0x00010c4e3850 (X11.bin+0x0001005ab854)

  Mutex M856 (0x00010c4c8c80) created at:
    #0 pthread_mutex_lock <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000321fe)
    #1 DarwinListenOnOpenFD darwinEvents.c:300 (X11.bin+0x000100031607)
    #2 socket_handoff bundle-main.c:288 (X11.bin+0x000100002b40)
    #3 __do_request_fd_handoff_socket_block_invoke bundle-main.c:379 (X11.bin+0x0001000029ba)
    #4 __tsan::invoke_and_release_block(void*) <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x00000005d97b)
    #5 _dispatch_client_callout <null>:33 (libdispatch.dylib+0x0000000020ef)

  Mutex M1976 (0x00010c4e3d68) created at:
    #0 pthread_mutex_init <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000253c3)
    #1 input_lock inputthread.c:103 (X11.bin+0x00010049fd10)
    #2 TimerSet WaitFor.c:343 (X11.bin+0x0001004926c2)
    #3 RootlessQueueRedisplay rootlessScreen.c:594 (X11.bin+0x000100065d7f)
    #4 RootlessInstallColormap rootlessScreen.c:514 (X11.bin+0x000100069f1a)
    #5 miSpriteInstallColormap misprite.c:562 (X11.bin+0x000100467095)
    #6 miCreateDefColormap micmap.c:270 (X11.bin+0x000100440399)
    #7 DarwinScreenInit darwin.c:285 (X11.bin+0x0001000303bb)
    #8 AddScreen dispatch.c:3908 (X11.bin+0x00010036c417)
    #9 InitOutput darwin.c:671 (X11.bin+0x00010002fdeb)
    #10 dix_main main.c:197 (X11.bin+0x00010036e228)
    #11 server_thread quartzStartup.c:66 (X11.bin+0x000100039e63)

  Thread T8 (tid=4198779, running) created by main thread at:
    #0 pthread_create <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x000000024490)
    #1 create_thread quartzStartup.c:78 (X11.bin+0x000100039dad)
    #2 QuartzInitServer quartzStartup.c:95 (X11.bin+0x000100039c16)
    #3 X11ApplicationMain X11Application.m:1238 (X11.bin+0x00010001cde4)
    #4 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a642)
    #5 server_main quartzStartup.c:136 (X11.bin+0x00010003a03b)
    #6 do_start_x11_server bundle-main.c:436 (X11.bin+0x000100002eb5)
    #7 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x000100004e99)
    #8 mach_startup_server mach_startupServer.c:399 (X11.bin+0x000100005734)
    #9 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186)
    #10 start <null>:29 (libdyld.dylib+0x000000005254)

  Thread T12 (tid=4198797, running) created by thread T8 at:
    #0 pthread_create <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x000000024490)
    #1 create_thread darwinEvents.c:121 (X11.bin+0x000100031ecf)
    #2 DarwinEQInit darwinEvents.c:365 (X11.bin+0x000100031860)
    #3 InitInput darwin.c:571 (X11.bin+0x00010002ea09)
    #4 dix_main main.c:261 (X11.bin+0x00010036e7ce)
    #5 server_thread quartzStartup.c:66 (X11.bin+0x000100039e63)

SUMMARY: ThreadSanitizer: data race WaitFor.c:237 in WaitForSomething
==================
==================
WARNING: ThreadSanitizer: data race (pid=22841)
  Write of size 4 at 0x000105bbd864 by main thread (mutexes: write M1945):
    #0 mieqEnqueue mieq.c:263 (X11.bin+0x000100448cf4)
    #1 DarwinSendDDXEvent darwinEvents.c:642 (X11.bin+0x000100033693)
    #2 -[X11Controller set_window_menu:] X11Controller.m:275 (X11.bin+0x0001000222fd)
    #3 -[X11Application set_window_menu:] X11Application.m:486 (X11.bin+0x000100018b44)
    #4 -[X11Application handleMachMessage:] X11Application.m:177 (X11.bin+0x000100016678)
    #5 __NSFireMachPort <null>:69 (Foundation+0x00000009b62b)
    #6 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a5f2)
    #7 server_main quartzStartup.c:136 (X11.bin+0x000100039ffb)
    #8 do_start_x11_server bundle-main.c:436 (X11.bin+0x000100002e65)
    #9 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x000100004e49)
    #10 mach_startup_server mach_startupServer.c:399 (X11.bin+0x0001000056e4)
    #11 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186)
    #12 start <null>:29 (libdyld.dylib+0x000000005254)

  Previous read of size 4 at 0x000105bbd864 by thread T7:
    #0 Dispatch dispatch.c:434 (X11.bin+0x000100352fc8)
    #1 dix_main main.c:287 (X11.bin+0x00010036e874)
    #2 server_thread quartzStartup.c:66 (X11.bin+0x000100039e23)

  Location is global 'miEventQueue' at 0x000105bbd860 (X11.bin+0x0001005ab864)

  Mutex M1945 (0x000105bbdd78) created at:
    #0 pthread_mutex_init <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000253c3)
    #1 input_lock inputthread.c:103 (X11.bin+0x00010049fd10)
    #2 TimerSet WaitFor.c:348 (X11.bin+0x0001004926c2)
    #3 RootlessQueueRedisplay rootlessScreen.c:594 (X11.bin+0x000100065d3f)
    #4 RootlessInstallColormap rootlessScreen.c:514 (X11.bin+0x000100069eda)
    #5 miSpriteInstallColormap misprite.c:562 (X11.bin+0x000100467075)
    #6 miCreateDefColormap micmap.c:270 (X11.bin+0x000100440379)
    #7 DarwinScreenInit darwin.c:285 (X11.bin+0x00010003036b)
    #8 AddScreen dispatch.c:3914 (X11.bin+0x00010036c3f7)
    #9 InitOutput darwin.c:671 (X11.bin+0x00010002fd9b)
    #10 dix_main main.c:197 (X11.bin+0x00010036e208)
    #11 server_thread quartzStartup.c:66 (X11.bin+0x000100039e23)

  Thread T7 (tid=4257217, running) created by main thread at:
    #0 pthread_create <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x000000024490)
    #1 create_thread quartzStartup.c:78 (X11.bin+0x000100039d6d)
    #2 QuartzInitServer quartzStartup.c:95 (X11.bin+0x000100039bd6)
    #3 X11ApplicationMain X11Application.m:1238 (X11.bin+0x00010001cd94)
    #4 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a5f2)
    #5 server_main quartzStartup.c:136 (X11.bin+0x000100039ffb)
    #6 do_start_x11_server bundle-main.c:436 (X11.bin+0x000100002e65)
    #7 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x000100004e49)
    #8 mach_startup_server mach_startupServer.c:399 (X11.bin+0x0001000056e4)
    #9 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186)
    #10 start <null>:29 (libdyld.dylib+0x000000005254)

SUMMARY: ThreadSanitizer: data race mieq.c:263 in mieqEnqueue
==================

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-09-22 14:55:01 -07:00