Commit Graph

166 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult
bb5eeac791 render: consolidate byte-swapping in ProcRenderFreeGlyphSet()
No need for extra functions and call tables for the few trivial lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-24 11:40:18 +02:00
Enrico Weigelt, metux IT consult
91902cdd86 render: consolidate byte-swapping in ProcRenderCreatePicture()
No need for extra functions and call tables for the few trivial lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-24 11:40:06 +02:00
Enrico Weigelt, metux IT consult
36facd71b5 dix: move request/response related functions to new request_priv.h header
Move functions/macros dealing with request parsing or reply assembly/write
out of the big dix_priv.h into their own headers. This new header will also
get more of those function/macros soon (yet still in the pipeline).

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-24 11:32:50 +02:00
Enrico Weigelt, metux IT consult
53338710d0 render: consolidate byte-swapping in ProcRenderCreatePicture()
No need for extra functions and call tables for the few trivial lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-22 12:43:10 +02:00
Enrico Weigelt, metux IT consult
b96cffc80e render: consolidate byte-swapping in ProcRenderReferenceGlyphSet()
No need for extra functions and call tables for the few trivial lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-22 12:42:57 +02:00
Enrico Weigelt, metux IT consult
8439b00fd1 render: consolidate byte-swapping in ProcRenderComposite()
No need for extra functions and call tables for the few trivial lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-17 09:37:19 +02:00
Enrico Weigelt, metux IT consult
52ea21c7c2 render: consolidate byte-swapping in ProcRenderCreateAnimCursor()
No need for extra functions and call tables for the few trivial lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-17 09:37:01 +02:00
Enrico Weigelt, metux IT consult
141a96237f render: consolidate byte-swapping in ProcRenderQueryFilters()
No need for extra functions and call tables for the few trivial lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-17 09:36:32 +02:00
Enrico Weigelt, metux IT consult
70428787cd render: consolidate byte-swapping in ProcRenderCreateCursor()
No need for extra functions and call tables for the few trivial lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-17 09:36:18 +02:00
Enrico Weigelt, metux IT consult
24885d9019 render: consolidate byte-swapping in ProcRenderCreateGlyphSet()
No need for extra functions and call tables for the few trivial lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-17 09:36:06 +02:00
Enrico Weigelt, metux IT consult
fd4f402d12 render: consolidate byte-swapping in ProcRenderQueryPictIndexValues()
No need for extra functions and call tables for the few trivial lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-17 09:35:51 +02:00
Enrico Weigelt, metux IT consult
f503962970 render: consolidate duplicate Proc* functions
dropping lots of duplicate functions which are doing the same like others.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-12 15:30:07 +02:00
Enrico Weigelt, metux IT consult
b0ffa7b286 treewide: rename dixGetFirstScreenPtr() to dixGetMasterScreen() for correct semantics
In Xinerama/Panoramix configuration there's one screen that's having special
meaning - it's used for simulating as the frontend for all client operations:
the clients (should) only talk to that screen, while panoramix subsystem is
proxying those operations to all the other screens (with certain changed
applied, eg. coordinate transformations).

Historically, this screen happens to be the first one in the system (some of
it's proc's are hooked up in order to achieve desired behaviour). That's why it
used to be accessed via screenInfo.screens[0] - that already had been encapsulated
into a tiny helper `dixGetFirstScreen()`.

a) the correct terminus technicus for a situation where one device (or SW entity)
   entirely controlling others is a master-slave-relationship: the controlling
   device/entity is `master`, the controlled ones are `slave` (to that specific
   master).

b) the term "first screen" is inacurate and misleading here: what the caller's are
   actually interest in isn't the first entry in the screen array, but the screen
   that's controlling the others. With upcoming refactoring of the Xinerama/Panoramix
   subsystem, this might well be a different array index than 0.

c) the term `default` also wouldn't match: `default` implies there's a real practical
   choice, and such value applies when no explicit choice has been made. But in this
   case, it practically doesn't make sense (except perhaps for debugging purpose)
   for a client to use any different screen.

Therefore fixing the function name to the correct technical terminology.
(for sake of patch readability, renaming corresponding variables is left to
subsequent patches).

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-12 11:44:05 +02:00
Enrico Weigelt, metux IT consult
24d15f9b7b render: consolidate byte-swapping in ProcRenderQueryVersion()
No need for extra functions and call tables for the few trivial lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-12 09:39:53 +02:00
Enrico Weigelt, metux IT consult
6bc438ab5a treewide: use inline helper for accessing first screen
Instead of everybody directly accessing the (internal) screenInfo struct,
let those consumers only interested in first screen use a little helper.

Also caching the value if it's needed several times.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-10 13:45:05 +02:00
Enrico Weigelt, metux IT consult
9c6577cfcc render: drop obsolete SProc*()'s
Several of the SProcRender*() functions aren't actually needed, because
they're doing exactly the same as their ProcRender*() counterparts.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-10 13:39:42 +02:00
Enrico Weigelt, metux IT consult
87fc0a2521 render: let SProcRender*()'s directly call corresponding ProcRender*()'s.
Since Xinerama stuff doesn't tweak the call tables anymore, there's no need
to use them anymore - instead call the corresponding handlers directly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-10 13:39:42 +02:00
Enrico Weigelt, metux IT consult
e4aae06a2d render: untwist xinerama part I
In order to consolidate protocol parsing (eg. byte-swapping) and dispatch
(eg. getting rid of the ugly call tables), we first need to untwist the
horribly complicated Xinerama machinery: it's using call tables which are
dynamically tweaked (when Xinerama is switched on/off), and even more call
tables for the byte-swap functions.

Simplifying the code flow by adding trivial demux handlers, which are calling
either into classic/single-mode or xinerama handlers, depending on whether
Xinerama is active.

Follow-up commits can now move the byte-wapping into here and drop the call tables.
After that, the currently duplicated parsing can also be moved in here, and
finally split off the classic/single-mode functions into protocol handling vs.
business logic, so we can finally stop faking requests from Xinerama side into
the classic handlers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-10 13:39:23 +02:00
Enrico Weigelt, metux IT consult
eb17b34362 Xinerama: lambda-esque macro for walking Xinerama screens
Move the walking loops on Xinerama screens into lambda-esque macros:
the callers look quite like we've been using lambda functions and
closures, but actually are just fancy macro trickery.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-09 14:12:40 +02:00
Enrico Weigelt, metux IT consult
bdaa1f7a69 render: untwist Xinerama - call orig functions directly
When a xinerama-enabled handler is calling into the plain one, there's
no need to go through extra call table - we can call them directly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-08 09:56:51 +02:00
Enrico Weigelt, metux IT consult
ef46dec08d render: ProcRenderAddGlyphs(): move locally used variables into local scope
make the variable's it easier to understand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-05 08:49:15 +02:00
Enrico Weigelt, metux IT consult
fe9fcfe98f render: ProcRenderQueryPictFormats(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly and X_SEND_REPLY_WITH_RPCBUF()
for sending it all out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 09:33:41 +02:00
Enrico Weigelt, metux IT consult
60dc405def render: ProcRenderQueryPictFormats(): scope pFormat variable
instead of reusing one variable for different things, put it into local
scopes, so things can't ever get mixed up.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 09:33:41 +02:00
Enrico Weigelt, metux IT consult
8237dacffe render: ProcRenderQueryPictFormats(): don't re-use counter variables
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 09:33:41 +02:00
Enrico Weigelt, metux IT consult
638822b19e render: canonical walkScreenIdx variable on screen list iterations
When iterating screen lists, consistently use the same variable name
`walkScreenIdx` for holding current screen index everywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 09:33:29 +02:00
Enrico Weigelt, metux IT consult
56cd66d147 render: ProcRenderQueryPictIndexValues(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly and X_SEND_REPLY_WITH_RPCBUF()
for sending it all out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-02 11:09:32 +02:00
Enrico Weigelt, metux IT consult
81f93d19a0 render: ProcRenderQueryFilters(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly and X_SEND_REPLY_WITH_RPCBUF()
for sending it all out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-02 11:08:32 +02:00
Enrico Weigelt, metux IT consult
6e2d5d3ddf render: use X_SEND_REPLY_SIMPLE() for simple replies
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-31 14:26:59 +02:00
Enrico Weigelt, metux IT consult
e29c0454ce render: canonical walkScreen variable on screen list iterations
When iterating screen lists, consistently use the same variable name
`walkScreen` for holding current screen pointer everywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-18 10:52:49 +02:00
Enrico Weigelt, metux IT consult
35a43252ca treewide: replace PICT_a8r8g8b8 by PIXMAN_a8r8g8b8
Try not to use old compat macros anymore, use the real ones instead.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-11 20:23:43 +02:00
Enrico Weigelt, metux IT consult
c2c19fc7fe treewide: replace PICT_FORMAT_RGB by PIXMAN_FORMAT_RGB
Try not to use old compat macros anymore, use the real ones instead.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-07 12:45:37 +02:00
Enrico Weigelt, metux IT consult
ae1b649587 treewide: replace PICT_FORMAT_A by PIXMAN_FORMAT_A
Try not to use old compat macros anymore, use the real ones instead.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-07 12:45:37 +02:00
Enrico Weigelt, metux IT consult
c430c829d5 render: fix CVE-2025-49175
Protect against clients sending a series of zero cursors.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-17 20:01:25 +02:00
Enrico Weigelt, metux IT consult
3c028a8cc0 miext: move over extinit_priv.h from include
Since most of the extension init logic (and on/off switches for them)
is driven from miext, this seems the appropriate place for the header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00
Enrico Weigelt, metux IT consult
037a595ad7 render: replace xallocarray() by calloc()
Only key difference that calloc(), in contrast to rellocarray(),
is zero-initializing. The overhead is hard to measure on today's
machines, and it's safer programming practise to always allocate
zero-initialized, so one can't forget to do it explicitly.

Cocci rule:

    @@
    expression COUNT;
    expression LEN;
    @@
    - xallocarray(COUNT,LEN)
    + calloc(COUNT,LEN)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:43 +02:00
Enrico Weigelt, metux IT consult
c7ff7b220d render: clean up including panoramix headers
* use their actual path instead of relying this to be in compiler's
  include path list.
* no need to do it only conditionally, no #ifdef needed

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:43 +02:00
Enrico Weigelt, metux IT consult
adc27c5220 dix: move ColormapRec declaration out of public header
Not used by any external module/driver, so no need to keep it in
public header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:43 +02:00
Enrico Weigelt, metux IT consult
a2d9d2078f render: 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:40 +02:00
Enrico Weigelt, metux IT consult
c8607ca66f render: 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
356e18dcc6 os: move out extension disable flags to corresponing extensions
The OS abstraction isn't really the right place for those flags,
they are're probably better off in their corresponding extensions.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1519>
2025-02-07 12:00:53 +01:00
Enrico Weigelt, metux IT consult
00ab4ff813 render: drop swapping request length fields
The request struct's length fields aren't used anymore - we have the
client->req_len field instead, which also is bigreq-compatible.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1639>
2025-02-06 22:28:49 +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
1642adec3b dix: unexport Ones()
It's not used by any module/driver, 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/1695>
2024-10-26 16:35:57 +00:00
Enrico Weigelt, metux IT consult
a917f6a8a8 drop obsolete HAVE_DIX_CONFIG_H
The symbol controls whether to include dix-config.h, and it's always set,
thus we don't need it (and dozens of ifdef's) anymore.

This commit only removes them from our own source files, where we can
guarantee that dix-config.h is present - leaving the (potentially exported)
headers untouched.

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
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
33350ef8ff include: move private definitions out of extinit.h
Public server module API shouldn't be clobbered with private definitions,
thus move them out to extinit_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
232cad9ec3 prevent name clash on Windows w/ RT_* defines
Windows' native headers using some our RT_* define's names for other things.
Since the naming isn't very nice anyways, introducing some new ones
(X11_RESTYPE_NONE, X11_RESTYPE_FONT, X11_RESTYPE_CURSOR) and define the old
ones as an alias to them, in case some out-of-tree code still uses them.

With thins change, we don't need to be so extremely careful about include
ordering and have explicit #undef's in order to prevent name clashes on
Win32 targets.

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
Enrico Weigelt, metux IT consult
d444cd4237 dix: unexport some lookup functions
These aren't used by any drivers, 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/1380>
2024-04-15 18:11:57 -07:00
Peter Hutterer
bdca6c3d1f render: fix refcounting of glyphs during ProcRenderAddGlyphs
Previously, AllocateGlyph would return a new glyph with refcount=0 and a
re-used glyph would end up not changing the refcount at all. The
resulting glyph_new array would thus have multiple entries pointing to
the same non-refcounted glyphs.

AddGlyph may free a glyph, resulting in a UAF when the same glyph
pointer is then later used.

Fix this by returning a refcount of 1 for a new glyph and always
incrementing the refcount for a re-used glyph, followed by dropping that
refcount back down again when we're done with it.

CVE-2024-31083, ZDI-CAN-22880

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

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1463>
2024-04-02 19:19:40 -07:00