Commit Graph

324 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult 6e657b2ca5 dix: write out X_AllocColorPlanes reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:42 +02:00
Enrico Weigelt, metux IT consult 3a233ac98a dix: write out X-AllocColorCells reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:42 +02:00
Enrico Weigelt, metux IT consult df44f063a0 dix: write out X_AllocNamedColor reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:42 +02:00
Enrico Weigelt, metux IT consult f062333422 dix: write out X_AllocColor reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:42 +02:00
Enrico Weigelt, metux IT consult 725bb2d20d dix: write out X_ListInstalledColormaps reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:42 +02:00
Enrico Weigelt, metux IT consult 1f2cf6fe4b dix: write out X_QueryTextExtents reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:42 +02:00
Enrico Weigelt, metux IT consult 83569a31c8 dix: write out X_QueryFont reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:42 +02:00
Enrico Weigelt, metux IT consult 9136207164 dix: write out X_GetAtomName reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:42 +02:00
Enrico Weigelt, metux IT consult 56f1c26056 dix: write out X_InternAtom reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:42 +02:00
Enrico Weigelt, metux IT consult 9541233f8d dix: write out X_QueryTree reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:42 +02:00
Enrico Weigelt, metux IT consult f59ffc7c93 dix: write out X_GetWindowAttributes reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:33 +02:00
Enrico Weigelt, metux IT consult 0812c4953a dix: write out X_GetImage reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:54:52 +02:00
Enrico Weigelt, metux IT consult df63401d6d dix: write out X_TranslateCoords reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:54:49 +02:00
Enrico Weigelt, metux IT consult b06fc7e68c dix: write out X_GetGeometry reply directly
No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:54:45 +02:00
Enrico Weigelt, metux IT consult 923de1a7a4 dix: consolidate ProcGetGeometry()
No need to have it split into two functions one just wrapping
another, so move it all into one.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:54:42 +02:00
Enrico Weigelt, metux IT consult bd29dc5adf dix: make RESOURCE_CLIENT_MASK macro private
Not used in any external modules, so no need to keep it public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:53:53 +02:00
Enrico Weigelt, metux IT consult 46eeeec810 fix name clash on 'GC' between Xlib and Xserver
Both xlib as well as the Xserver use the same identifier "GC" for
different types. While on xlib it's just the numerical ID of a GC,
the xserver defines a struct for it by the same name. This is this
ugly and needs ridiculous hacks for Xserver code that needs xlib.

Easy to solve by just renaming the GC typedef to GCRec (consistent
with how we're naming other structs) and replacing GC* by GCPtr.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:52:25 +02:00
Enrico Weigelt, metux IT consult 38d62bcc08 dix: CreateColormap() pass in ClientPtr instead of client index
The function actually operates on ClientRec, so we can pass it in
directly, so it doesn't need to fetch it from clients[] array itself.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:52:22 +02:00
Enrico Weigelt, metux IT consult 1c8ef6d44d dix: colormap: let AllocColorCells() operate on ClientPtr instead of index
It's only caller already has a pointer to client struct, so no need to
let this function look it up again in the global clients array.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:52:19 +02:00
Enrico Weigelt, metux IT consult 7501ca09b9 dix: rename dixLookupClient() to dixLookupResourceOwner()
Choose a bit more precise / descriptive name for that function.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:52:07 +02:00
Enrico Weigelt, metux IT consult 0127d6ef13 dix: use calloc() instead of malloc()
Using calloc() instead of malloc() as preventive measure, so there
never can be any hidden bugs or leaks due uninitialized memory.

The extra cost of using this compiler intrinsic should be practically
impossible to measure - in many cases a good compiler can even deduce
if certain areas really don't need to be zero'd (because they're written
to right after allocation) and create more efficient machine code.

The code pathes in question are pretty cold anyways, so it's probably
not worth even thinking about potential extra runtime costs.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:49:43 +02:00
Enrico Weigelt, metux IT consult d708b28adc treewide: drop COMPOSITE symbol
It's always enabled for very long time now (at least since meson transition),
there doesn't seem to be any need to ever disable it again. So we can reduce
code complexity by removing all the ifdef's.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:47:01 +02:00
Enrico Weigelt, metux IT consult befc3d22cf dix: add per-screen pixmap destructor mechanism
Right now, extension specific pixmap destruction procedures are implemented
by wrapping the ScreenRec's DestroyPixmap() proc pointer: the extensions are
storing the original pointer in their private data and putting in their own one.
On each call, their proc restores the original one, calls it, and switches back
again. When multiple extensions doing so, they're forming a kind of daisy chain.
(the same is done for lots of other procs)

While that approach is looking nice and elegant on the drawing board, it's
complicated, dangerous like a chainsaw and makes debugging hard, leading to
pretty blurred API borders.

It's even getting worse: the proc also has to do ref counting, and only destroy
the pixmap if refconter reaching zero - that's all done in the individual screen
drivers. Therefore, all extensions must check for refcnt == 1, in order to know
when to really act.

This commit introduces a simple approach for letting extension hook into the
pixmap destruction safely, w/o having to care much about side effects with
the call chain. Extensions now can simply register their destructor proc
(and an opaque pointer) and get called back - w/o ever having to mess with
the ScreenRec's internal structures.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:46:30 +02:00
Enrico Weigelt, metux IT consult 38e8cc47f5 dix: drop unused SetVendorRelease()
Not used anywhere, so no need to keep it around any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:20:19 +02:00
Enrico Weigelt, metux IT consult 9d78e139a0 dix: unexport SetInputCheck() and make it inline
Not used by any drivers, so no need to keep it exported.
It's also so simple (and rarely called) that easily can be inlined.

Also unexport HWEventQueueType and HWEventQueuePtr, since they're
not used by any drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:20:09 +02:00
Enrico Weigelt, metux IT consult a58fd6f511 (!2007) dix: unexport SendGraphicsExpose() and fix parameter types
* not used by any drivers, so no need to keep it exported
* fix parameter types to matching the protocol types

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:18:08 +02:00
Enrico Weigelt, metux IT consult a94e906084 dix: unexport SendErrorToClient() and fix parameter types
* not used by any drivers, so no need to keep it exported
* fix parameter types to matching the protocol types

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:18:05 +02:00
Enrico Weigelt, metux IT consult b528301f97 dix: unexport and document ClientSignal()
Not used by any external drivers, so no need to keep it exported.

Also renamed to dixClientSignal(), since there's a conflicting prototype
in fontsproto.h.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:17:49 +02:00
Olivier Fourdan 01642f263f Cursor: Refuse to free the root cursor
If a cursor reference count drops to 0, the cursor is freed.

The root cursor however is referenced with a specific global variable,
and when the root cursor is freed, the global variable may still point
to freed memory.

Make sure to prevent the rootCursor from being explicitly freed by a
client.

CVE-2025-26594, ZDI-CAN-25544

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

v2: Explicitly forbid XFreeCursor() on the root cursor (Peter Hutterer
<peter.hutterer@who-t.net>)
v3: Return BadCursor instead of BadValue (Michel Dänzer
<michel@daenzer.net>)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Suggested-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25 11:43:01 +01:00
Enrico Weigelt, metux IT consult 5b541780c1 dix: use dixDestroyPixmap() instead of direct driver call
Direct calls to ScreenRec->DestroyPixmap() blocks cleaning up the wrapping
jungle, so use the proper dix function instead.

See: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1754

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1711>
2025-02-12 17:48:30 +01:00
Enrico Weigelt, metux IT consult 24d693c5ae dix: make dixDestroyPixmap() NULL-proof
Make dixDestroyPixmap() check for NULL pointer, so callers don't need to
do it anymore. Returning TRUE on NULL pointer - but most callers won't
even look at the retval anyways.

Together with subsequent commits, which will make use of that function,
instead of calling raw ScreenRec->DestroyPixmap vectors, this gives us some
more freedom for architectural changes, eg. get rid of the extremely
complicated and fragile wrapping chains.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1709>
2025-02-06 23:02:06 +00:00
Enrico Weigelt, metux IT consult fb696a7d7b rename old symbol PANORAMIX to XINERAMA
PANORAMIX was the original working title of the extension, before it became
official standard. Just nobody cared about fixing the symbols to the official
naming.

For backwards compatibility with drivers, the old PANORAMIX symbol will
still be set.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1258>
2025-02-06 15:51:27 +00:00
Enrico Weigelt, metux IT consult 7ac7a2d6de os: split off internal definitions from client.h
The client.h file is part of the public module API, but it also contains
definitions that aren't useful for being used in modules. Splitting them
out into their own client_priv.h file, which isn't part of the API.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-10-10 13:45:29 +00:00
Enrico Weigelt, metux IT consult 4cac1ee46d dix: drop unnecessary check on HAVE_DIX_CONFIG_H
The dix-config.h include file is always present, so no need for
an extra check and conditional include.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-10-10 13:38:31 +00:00
Enrico Weigelt, metux IT consult 24f3c4a508 dix: unexport cursor allocation functions
These functions aren't used by external modules, so no need to export them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1345>
2024-09-02 16:43:29 +00:00
Enrico Weigelt, metux IT consult 1bfa4876f6 dix: move colormap flags into colormap_priv.h and rename them
These aren't used by any drivers/modules, so no need to keep them exported.
As already touching them, give them a proper name prefix for clarity.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1581>
2024-09-01 22:06:50 +00:00
Enrico Weigelt, metux IT consult 7ce67a99bc dix: unexport CreateColormap()
Not used by any driver/module, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1581>
2024-09-01 22:06:49 +00:00
Enrico Weigelt, metux IT consult 811977228b os: unexport screen saver timer functions
These functions aren't supposed to be used by drivers, so move them
out of the public API.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1583>
2024-09-01 20:23:10 +00:00
Enrico Weigelt, metux IT consult 2cec3cfbf1 include: move private definitions out of input.h
It's not good having the public server api headers clobbered with private
definitions, so cleaning them up.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1354>
2024-09-01 17:59:23 +00:00
Enrico Weigelt, metux IT consult 34662f15af os: unexport fields from opaque.h not used by modules / drivers
There're lots of field that aren't used by any modules or drivers,
thus no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1351>
2024-06-23 21:19:27 +00:00
Enrico Weigelt, metux IT consult 305f2d59d8 xace: typesafe hook function for XACE_SCREENSAVER_ACCESS
he generic XaceHook() call isn't typesafe (und unnecessarily slow).
Better add an explicit function, just like we already have for others.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1556>
2024-06-23 21:07:48 +00:00
Enrico Weigelt, metux IT consult 51d8bcfc0d xace: typesafe hook function for XACE_SCREEN_ACCESS
he generic XaceHook() call isn't typesafe (und unnecessarily slow).
Better add an explicit function, just like we already have for others.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1556>
2024-06-23 21:07:48 +00:00
Enrico Weigelt, metux IT consult 47d6c3ad75 xace: typesafe hook function for XACE_SERVER_ACCESS
he generic XaceHook() call isn't typesafe (und unnecessarily slow).
Better add an explicit function, just like we already have for others.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1556>
2024-06-23 21:07:48 +00:00
Enrico Weigelt, metux IT consult 922b7685dc xace: typesafe hook function for XACE_CLIENT_ACCESS
The generic XaceHook() call isn't typesafe (und unnecessarily slow).
Better add an explicit function, just like we already have for others.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1556>
2024-06-23 21:07:48 +00:00
Enrico Weigelt, metux IT consult ae3c573337 xace: typesafe hook function for XACE_RESOURCE_ACCESS
The generic XaceHook() call isn't typesafe (und unnecessarily slow).
Better add an explicit function, just like we already have for others.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1556>
2024-06-23 21:07:48 +00:00
Enrico Weigelt, metux IT consult e5c8b664d3 os: unexport ddx callbacks
The DDX callbacks (where core/DIX calls into DDX) aren't supposed to be
called by drivers directly, so unexport them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1332>
2024-05-08 09:37:35 +02:00
Enrico Weigelt, metux IT consult bae6cbc8ca include: move private defs to dixstruct_priv.h
Public server module API shouldn't be clobbered with private definitions,
thus move them out to dixstruct_priv.h

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1289>
2024-04-30 00:47:38 +00:00
Enrico Weigelt, metux IT consult d18ef33099 os: unexport OnlyListenToOneClient()
Not used by any drivers, so no need to export it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1385>
2024-04-16 18:13:11 -07:00
Enrico Weigelt, metux IT consult 85d4bd0dba rename remaining RT_* defines to X11_RESTYPE_*
Since we already had to rename some of them, in order to fix name clashes
on win32, it's now time to rename all the remaining ones.

The old ones are still present as define's to the new ones, just for
backwards compatibility.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1355>
2024-04-15 19:00:47 -07:00
Enrico Weigelt, metux IT consult 1ca48d0a48 dix: workaround for win32 name clash on CreateWindow()
The problem is, ming32 headers unconditionally define CreateWindow() to
alias CreateWindowA() in winuser.h, which is included by windows.h, which
is included by *a lot* common headers. So it highly depends on the exact
include order, whether it works. (also weird things could happen, e.g.
the Xserver's CreateWindow() ending up renamed to CreateWindowA(), ...)

Until we've found a really clean solution to this problem (which might
involve fixing mingw32 first), just add a little workaround by undef'ing
CreateWindow symbol whereever necessary.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1355>
2024-04-15 18:59:23 -07:00