xserver-multidpi/os
Martin Peres bbf1893cc0 os: make sure the clientsWritable fd_set is initialized before use
In WaitForSomething(), the fd_set clientsWritable may be used
unitialized when the boolean AnyClientsWriteBlocked is set in the
WakeupHandler(). This leads to a crash in FlushAllOutput() after
x11proto's commit 2c94cdb453bc641246cc8b9a876da9799bee1ce7.

The problem did not manifest before because both the XFD_SIZE and the
maximum number of clients were set to 256. As the connectionTranslation
table was initalized for the 256 clients to 0, the test on the index not
being 0 was aborting before dereferencing the client #0.

As of commit 2c94cdb453bc641246cc8b9a876da9799bee1ce7 in x11proto, the
XFD_SIZE got bumped to 512. This lead the OutputPending fd_set to have
any fd above 256 to be uninitialized which in turns lead to reading an
index after the end of the ConnectionTranslation table. This index would
then be used to find the client corresponding to the fd marked as
pending writes and would also result to an out-of-bound access which
would usually be the fatal one.

Fix this by zeroing the clientsWritable fd_set at the beginning of
WaitForSomething(). In this case, the bottom part of the loop, which
would indirectly call FlushAllOutput, will not do any work but the next
call to select will result in the execution of the right codepath. This
is exactly what we want because we need to know the writable clients
before handling them. In the end, it also makes sure that the fds above
MaxClient are initialized, preventing the crash in FlushAllOutput().

Thanks to everyone involved in tracking this one down!

Reported-by: Karol Herbst <freedesktop@karolherbst.de>
Reported-by: Tobias Klausmann <tobias.klausmann@mni.thm.de>
Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
Tested-by: Tobias Klausmann <tobias.klausmann@mni.thm.de>
Tested-by: Martin Peres <martin.peres@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91316
Cc: Ilia Mirkin  <imirkin@alum.mit.edu>
Cc: Olivier Fourdan <ofourdan@redhat.com
Cc: Adam Jackson <ajax@redhat.com>
Cc: Alan Coopersmith <alan.coopersmith@oracle.com
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2015-10-27 16:12:03 -04:00
..
.gitignore dix and os: gitignore dix.O and os.O 2011-09-23 17:14:47 -07:00
Makefile.am Trap SIGBUS to handle truncated shared memory segments 2013-11-11 15:16:07 -08:00
WaitFor.c os: make sure the clientsWritable fd_set is initialized before use 2015-10-27 16:12:03 -04:00
access.c os: support new implicit local user access mode [CVE-2015-3164 2/3] 2015-06-03 09:05:39 -04:00
auth.c os: support new implicit local user access mode [CVE-2015-3164 2/3] 2015-06-03 09:05:39 -04:00
backtrace.c backtrace.c: Fix word cast to a pointer 2015-06-03 09:05:39 -04:00
busfault.c Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
client.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
connection.c Get rid of const warnings in XSERVER_INPUT_EVENT dtrace probe calls 2015-07-29 11:16:32 -04:00
io.c Fix overflow of ConnectionOutput->size and ->count 2014-11-30 11:37:56 -08:00
log.c os: Teach vpnprintf() how to handle "%*.*s" 2015-06-03 09:05:36 -04:00
mitauth.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
oscolor.c Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
osdep.h Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
osinit.c Move RTLD_DI_SETSIGNAL code into a separate block to quiet warning 2014-12-19 18:16:15 -08:00
rpcauth.c unchecked malloc may allow unauthed client to crash Xserver [CVE-2014-8091] 2014-12-08 18:09:46 -08:00
strcasecmp.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
strcasestr.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
strlcat.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
strlcpy.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
strndup.c os: Ensure <dix-config.h> is included in strndup.c 2013-02-14 09:20:46 -08:00
utils.c Keep SIGALRM restart flag after Popen 2015-10-26 12:18:29 -04:00
xdmauth.c xdmauth: Correct miscall of abs() to instrad call labs() 2015-10-26 12:20:29 -04:00
xdmcp.c xdmcp: Declare XdmcpFatal _X_NORETURN 2015-10-26 12:20:35 -04:00
xprintf.c os/xprintf: add Xvscnprintf and Xscnprintf 2012-05-03 14:59:23 +10:00
xsha1.c os/xsha1.c: Add license and copyright attribution. 2015-01-02 13:39:52 -08:00
xstrans.c Clean up a couple of warnings in os/ 2013-10-31 16:58:12 -07:00