Commit Graph

112 Commits

Author SHA1 Message Date
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
Ángel González
4583fa9a6c security: Fix reversed comment
Commit 6045506be0 changed back
the behavior to only allow the trusted extensions to the untrusted clients,
but left the 8b5d21cc1d
comment intended for Security*Un*trustedExtensions saying that
"untrusted clients shouldn't have access to these".

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Ángel González <ingenit@zoho.com>
2016-03-14 11:49:13 -04:00
Jeremy Huddleston
a7a00e4bd8 security: Silence some benign -Wformat warnings
XID may be either 'unsigned long' or 'unsigned int' depending on:

typedef unsigned long CARD64;
typedef unsigned int CARD32;
typedef unsigned long long CARD64;
typedef unsigned long CARD32;

typedef unsigned long XID;
typedef CARD32 XID;

so when building with -Wformat, we get some warnings that are benign.  This silences them.

security.c:215:52: warning: format specifies type 'int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
    SecurityAudit("revoked authorization ID %d\n", pAuth->id);
                                            ~~     ^~~~~~~~~
                                            %lu
  CC       dpmsstubs.lo
security.c:553:25: warning: format specifies type 'int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
         client->index, pAuth->id, pAuth->trustLevel, pAuth->timeout,
                        ^~~~~~~~~
security.c:553:55: warning: format specifies type 'int' but the argument has type 'CARD32' (aka 'unsigned long')
      [-Wformat,Format String Issue]
         client->index, pAuth->id, pAuth->trustLevel, pAuth->timeout,
                                                      ^~~~~~~~~~~~~~
security.c:554:10: warning: format specifies type 'int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
         pAuth->group, eventMask);
         ^~~~~~~~~~~~
security.c:554:24: warning: format specifies type 'int' but the argument has type 'Mask' (aka 'unsigned long')
      [-Wformat,Format String Issue]
         pAuth->group, eventMask);
                       ^~~~~~~~~
security.c:781:19: warning: format specifies type 'unsigned int' but the argument has type 'Mask' (aka 'unsigned
long')
      [-Wformat,Format String Issue]
                  requested, rec->id, cid,
                  ^~~~~~~~~
security.c:781:30: warning: format specifies type 'unsigned int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
                  requested, rec->id, cid,
                             ^~~~~~~
security.c:863:23: warning: format specifies type 'unsigned int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
                      rec->pWin->drawable.id, wClient(rec->pWin)->index,
                      ^~~~~~~~~~~~~~~~~~~~~~
security.c:893:31: warning: format specifies type 'unsigned int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
                              rec->pWin->drawable.id,
                              ^~~~~~~~~~~~~~~~~~~~~~
security.c:915:39: warning: format specifies type 'unsigned int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
                  rec->client->index, rec->pWin->drawable.id,
                                      ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2015-10-19 11:49:54 -04:00
Peter Hutterer
732fd7e571 Drop trailing whitespaces
sed -i "s/[ ]\+$//g" **/*.(c|h)

happy reviewing...
git diff -w is an empty diff.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-12 10:25:00 +10:00
Daniel Martin
2aeb9d8f8b security: Remove XpExtension from SecurityTrustedExtensions
There's no XPrint extension (anymore).

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-10-02 10:16:45 -07:00
Keith Packard
60014a4a98 Replace 'pointer' type with 'void *'
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer'
is used throughout the X server for other things, and having duplicate
names generates compiler warnings.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-12 10:24:11 -08:00
Peter Harris
132507eba9 security: Don't count RetainPermanent clients twice
If a RetainPermanent client is subsequently killed by a KillClient
request, the reference count is decremented twice. This can cause the
server to prematurely kill other clients using the same Authorization.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2013-09-10 13:26:25 -04:00
Daniel Stone
a1d41e311c Move extension initialisation prototypes into extinit.h
Create extinit.h (and xf86Extensions.h, for Xorg-specific extensions) to
hold all our extension initialisation prototypes, rather than
duplicating them everywhere.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09 23:06:41 -07:00
Tomas Carnecky
5079db78ae Replace INITARGS with void
INITARGS was a hardcoded define to void.  Since knowing the function
signature for your extensions is kinda useful, just replace it with a
hardcoded void, but leave the define there for API compatibility.

Signed-off-by: Tomas Carnecky <tom@dbservice.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Cyril Brulebois <kibi@debian.org>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09 23:06:41 -07:00
Alan Coopersmith
9805cedf7b Use C99 designated initializers in extension Events
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 22:52:30 -07:00
Alan Coopersmith
6a721e3af5 Use C99 designated initializers in Xext Replies
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 19:58:30 -07:00
Alan Coopersmith
789d64e19a Remove unneccesary casts from WriteToClient calls
Casting return to (void) was used to tell lint that you intended
to ignore the return value, so it didn't warn you about it.

Casting the third argument to (char *) was used as the most generic
pointer type in the days before compilers supported C89 (void *)
(except for a couple places it's used for byte-sized pointer math).

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 19:12:56 -07:00
Keith Packard
9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Alan Coopersmith
7801b3dcd6 Add some printf format attributes suggested by gcc
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:12 -08:00
Alan Coopersmith
9999819601 Constify string for authorization protocol names
gcc was warning from storing string constants in a char *name field:
auth.c:64:1: warning: initialization discards qualifiers from pointer target type
auth.c:72:1: warning: initialization discards qualifiers from pointer target type
auth.c:81:1: warning: initialization discards qualifiers from pointer target type

Making the field const requires changing AuthorizationFromID to take
a const char ** pointer for the name argument which it sets to point
to the matching name entry.

Changing that argument requires changing its sole caller in the security
extension to pass the address of a const char * variable to it, which it
can do, since the only thing it does with the returned name is to pass
it back to the RemoveAuthorization function that already expects a const
char *name.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:10 -08:00
Keith Packard
fb22a408c6 Save major/minor opcodes in ClientRec for RecordAReply
The record extension needs the major and minor opcodes in the reply
hook, but the request buffer may have been freed by the time the hook
is invoked. Saving the request major and minor codes as the request is
executed avoids fetching from the defunct request buffer.

This patch also eliminates the public MinorOpcodeOfRequest function,
inlining it into Dispatch. Usages of that function have been replaced
with direct access to the new ClientRec field.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2011-12-01 15:11:20 +00:00
Alan Coopersmith
05f589d464 Fix gcc -Wwrite-strings warnings in various extensions
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:07 -08:00
Matt Turner
2c7c520cfe Use internal temp variable for swap macros
Also, fix whitespace, mainly around
	swaps(&rep.sequenceNumber)

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2011-09-21 17:12:04 -04:00
Daniel Stone
f7d8ade3c5 Resources: Move rClient to resource.h
The definition of rClient was duplicated across three source files, so
move it to resource.h.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-12-31 12:36:44 +00:00
Sam Lau
1c08a37e0e SecurityResource should not segfault when client owning resource has exited
Fixes OpenSolaris bug 6949754:
  Xorg crashes when the magnifier is enabled at gdm login greeter window.
  http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6949754

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
2010-06-10 18:58:54 -07:00
Mikhail Gusarov
7287ef9e6c Remove unnecessary parentheses around return values in functions
This patch was generated by the following Perl code:

perl -i -pe 's/([^_])return\s*\(\s*([^(]+?)\s*\)s*;(\s+(\n))?/$1return $2;$4/g;'

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-10 06:42:42 -07:00
Mikhail Gusarov
0a4d8cbdcd Remove more superfluous if(p) checks around free(p)
This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@

-if(E) { free(E); }
+free(E);

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-06 20:27:18 +07:00
Keith Packard
faeebead7b Change the devPrivates API to require dixRegisterPrivateKey
This patch only changes the API, not the implementation of the
devPrivates infrastructure. This will permit a new devPrivates
implementation to be layed into the server without requiring
simultaneous changes in every devPrivates user.

Signed-off-by: Keith Packard <keithp@keithp.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com>
2010-06-05 19:23:03 -07:00
Jamey Sharp
c38552d115 Add typed resource-lookup errors for non-core resource types.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-19 12:32:48 -07:00
Jamey Sharp
8033fb6c97 Set event sequence number in WriteEventsToClient instead of at callers.
TryClientEvents already did this; this commit just moves the assignment
one level down so that no event source has to worry about sequence
numbers.

...No event source, that is, except XKB, which inexplicably calls
WriteToClient directly for several events.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-19 12:32:34 -07:00
Jamey Sharp
4b9600a416 Make WriteEventsToClient/WriteToClient no-op on fake or dead clients.
This matches the test in TryClientEvents, and is a superset of tests
done by the callers of these functions. The consequence of forgetting
these tests is a server crash, so they're always desirable. In my
opinion, it's better to not require the callers to remember to do these
checks.

For callers that don't do very much work before calling WriteToClient or
WriteEventsToClient, I've removed the redundant checks.

hw/xquartz/xpr/appledri.c has an interesting case: While its check for
"client == NULL" appears redundant with the test in WriteEventsToClient,
it dereferences client to get the sequence number.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=27497
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-19 12:32:34 -07:00
Jamey Sharp
92ed75ac59 Eliminate boilerplate around client->noClientException.
Just let Dispatch() check for a noClientException, rather than making
every single dispatch procedure take care of it.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-05-13 17:14:07 -07:00
Mikhail Gusarov
3f3ff971ec Replace X-allocation functions with their C89 counterparts
The only remaining X-functions used in server are XNF*, the rest is converted to
plain alloc/calloc/realloc/free/strdup.

X* functions are still exported from server and x* macros are still defined in
header file, so both ABI and API are not affected by this change.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-13 00:22:37 +07:00
Alan Coopersmith
895f40792a Add type name argument to CreateNewResourceType
Convert all calls of CreateNewResourceType to pass name argument

Breaks DIX ABI.

ABI versions bumped:

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-12-18 17:44:12 -08:00
Peter Hutterer
55747d256d input: define server-supported protocol versions in one single file.
include/protocol-versions.h specifies each extension version as supported by
the server and sent back on the wire to the client.

This fixes up several issues with the server potentially reporting a higher
version of the protocol if recompiled against a newer version of the
protocol.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Rémi Cardona <remi@gentoo.org>
Acked-by: Julien Cristau <jcristau@debian.org>
2009-09-21 21:47:35 +10:00
Peter Hutterer
4db8950b1d Xext: include securproto.h instead of securstr.h
Reported-by: Byeong-ryeol Kim
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-17 14:40:54 +10:00
Peter Hutterer
7b9e84e320 Xext: switch to byte counting functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-14 10:14:01 +10:00
Eamon Walsh
57aff88c7d Fix most remaining deprecated resource lookups.
Callsites updated to use dixLookupResourceBy{Type,Class}.
TODO: Audit access modes to make sure they reflect the usage.
2009-04-29 01:04:37 -04:00
Eamon Walsh
4559d2ace6 security: Grant untrusted windows remove access on all windows.
This allows untrusted clients to destroy their own windows when they
have been reparented by a trusted window manager.
2009-04-16 23:46:01 -04:00
Eamon Walsh
3481b32ab9 security: Fix a crash caused by wrong ordering of format arguments. 2009-04-16 23:46:01 -04:00
Eamon Walsh
6045506be0 security: Revert behavior of extension access for compatibility.
Previously, three extensions were defined as "trusted" by the extension:
BIG-REQUESTS, XC-MISC, and XPrint.  No other extensions were permitted
to be used by untrusted clients.

In commit 8b5d21cc1d this was changed for
some reason.  Return to the old, compatible behavior.
2009-04-16 23:46:00 -04:00
Keith Packard
f8dd80d13b Replace dixLookupResource by dixLookupResourceBy{Type,Class}
dixLookupResource attempted to automatically detect whether the caller
wanted a lookup by-type or by-class, unfortunately, it guessed wrong for
RT_NONE. Instead of trying to make the guess better, this patch just reverts
the unification and creates separate functions for each operation.
2009-03-09 13:08:09 -07:00
Adam Jackson
132b464d73 Remove a bunch of useless casts.
We've had void * for twenty years now people let's try to act like we
know how it works.
2009-01-22 02:11:16 -05:00
Tomas Carnecky
ebea78cdba Prepare for array-index based devPrivates.
TODO: static indices can be made just an int; some indices
can be combined.
2008-08-28 18:05:40 -04:00
Matthieu Herrb
95d162c438 CVE-2008-1377 - RECORD and Security extensions memory corruption
Lack of validation of the parameters of the
SProcSecurityGenerateAuthorization SProcRecordCreateContext
functions makes it possible for a specially crafted request to trigger
the swapping of bytes outside the parameter of these requests, causing
memory corruption.
2008-06-11 08:06:09 -06:00
Peter Hutterer
8190ef8754 Merge branch 'master' into mpx
Conflicts:

	Xext/EVI.c
	Xext/appgroup.c
	Xext/cup.c
	Xext/mitmisc.c
	Xext/sampleEVI.c
	dix/window.c
2008-04-22 18:04:05 +09:30
Adam Jackson
eafaf40fb3 Death to APPGROUP. 2008-04-18 18:50:05 -04:00
Peter Hutterer
fd06e8f8c1 Merge branch 'master' into dcdc_rework
Conflicts:

	Xext/xevie.c
	dix/dispatch.c
2008-04-07 07:56:41 +09:30
Peter Hutterer
4f2cd0ed96 Merge branch 'master' into mpx
This merge reverts Magnus' device coorindate scaling changes. MPX core event
generation is very different, so we can't scale in GetPointerEvents.

Conflicts:

	Xi/opendev.c
	dix/devices.c
	dix/dixfonts.c
	dix/getevents.c
	dix/resource.c
	dix/window.c
	hw/xfree86/common/xf86Xinput.c
	mi/mipointer.c
	xkb/ddxBeep.c
	xkb/ddxCtrls.c
	xkb/ddxKeyClick.c
	xkb/ddxList.c
	xkb/ddxLoad.c
	xkb/xkb.c
	xkb/xkbAccessX.c
	xkb/xkbEvents.c
	xkb/xkbInit.c
	xkb/xkbPrKeyEv.c
	xkb/xkbUtils.c
2008-03-04 18:11:10 +10:30
Eamon Walsh
cc76ea6e3a XACE: Add generic support for property and selection polyinstantiation. 2008-02-29 18:01:37 -05:00
Eamon Walsh
c8e979b3b8 security: Register resource names in the server-side name registry. 2008-02-26 21:36:46 -05:00
Eamon Walsh
f343265a28 XACE: Make the default window background state configurable per-window.
To recap: the original XC-SECURITY extension disallowed background "None" if
the window was untrusted.  XACE 1.0 preserved this check as a hook function.
XACE pre-2.0 removed the hook and first abolished background "None entirely,
then restored it as a global on/off switch in response to Bug #13683.
Now it's back to being per-window, via a flag instead of a hook function.
2008-02-20 15:59:40 -05:00
Eamon Walsh
4573cb2ce4 security: Revise set of permissions granted to untrusted clients.
Bug #14480: untrusted access broken on 7.3.
2008-02-13 20:20:49 -05:00
Eamon Walsh
5c30327275 XACE: Push the dix "structure" includes down to the security modules. 2008-02-05 21:06:05 -05:00
Peter Hutterer
8da83836b6 Merge branch 'master' into mpx
Conflicts:

	XTrap/xtrapddmi.c
	Xext/security.c
	Xext/xprint.c
	Xext/xtest.c
	Xext/xvdisp.c
	Xi/exevents.c
	Xi/grabdevb.c
	Xi/grabdevk.c
	Xi/opendev.c
	Xi/ungrdev.c
	Xi/ungrdevb.c
	Xi/ungrdevk.c
	dix/cursor.c
	dix/devices.c
	dix/dixutils.c
	dix/events.c
	dix/getevents.c
	dix/main.c
	dix/window.c
	hw/xfree86/ramdac/xf86Cursor.c
	include/dix.h
	include/input.h
	include/inputstr.h
	mi/midispcur.c
	mi/miinitext.c
	mi/misprite.c
	render/animcur.c
	xfixes/cursor.c
	xkb/xkbAccessX.c
2008-01-03 17:04:54 +10:30