Commit Graph

1438 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult
c503343a6b Xext: Xvmc: drop XvMCScreenKey macro
Directly use the actual field instead.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 13:47:59 +01:00
Enrico Weigelt, metux IT consult
85fae9bffb dix: inline SProcAllocColor()
Now that we have untwisted Xinerama side, it's trivial to inline
the few lines for byte-swapping into the actual handlers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 13:46:37 +01:00
Enrico Weigelt, metux IT consult
fda3695872 os: move MILLI_PER_MIN and MILLI_PER_SECOND to osdep.h
Not needed in public SDK, so move them into a private header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 11:58:45 +01:00
Herman Semenov
50037a450d Xext: remove excess dobule-check pointer (IsSystemCounter already have) 2025-11-26 16:47:14 +01:00
Mike Gelfand
d7e0b9e5c2 xext: move include guards up to wrap the whole file
See: https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html
Signed-off-by: Mike Gelfand <mikedld@mikedld.com>
2025-11-21 15:20:11 +01:00
Enrico Weigelt, metux IT consult
0bfa59e601 Xext: sleepuntil: drop obsolete support for internal server reset
Not used anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:26:00 +01:00
Enrico Weigelt, metux IT consult
f0347e249c Xext: panoramiX: drop server reset support
Not needed anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:22:55 +01:00
Enrico Weigelt, metux IT consult
44077ee11c dix: unexport screenIsSaved and HasSaverWindow()
These aren't used by any external drivers, so no need to keep them public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 17:52:23 +01:00
Enrico Weigelt, metux IT consult
b0ac921156 dix: unexport GrabInProgress
Only internally within OS layer and screen saver logic,
so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 17:42:29 +01:00
Enrico Weigelt, metux IT consult
cf105bc990 dix/Xinerama: untwist X_AllocColor request handling
Instead of internally faking requests, factor out the actual logic
into separate function, which is getting everything it needs as
parameters, so no need to fiddle with request buffer anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-03 17:24:24 +01:00
Enrico Weigelt, metux IT consult
0fbb681fce treewide: use helper dixGetScreenPtr() for retrieving ScreenPtr's
Instead of directly accessing the global screenInfo.screens[] array,
let everybody go through a little inline helper. This one also checks
for array bounds - if the screen doesn't exist, return NULL.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-30 09:44:24 +01:00
stefan11111
5b8ab55702 shm: Don't mark the globally-initialized privates as uninitialized in a CloseScreen hook.
No need to mark anything, because duplicate dixRegisterPrivateKey() calls with same parameters are perfectly valid.
See: https://github.com/X11Libre/xserver/pull/1300

Fixes: https://github.com/X11Libre/xserver/commit/d220a0a9f0473c15d5001f4730613b482eb0e39

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-10-29 11:23:33 +01:00
Enrico Weigelt, metux IT consult
04d4986004 dix: split ProcCreateWindow() into upper and lower half
In order to reduce complexity of wrapped core request handlers with PanoramiX,
split the ProcCreateWindow() function into two pieces: the upper half is the
usual (non-PanoramiX) handler, while the lower one is what's called by both
the usual handler, as well as the PanoramiX' one.

We're already passing in the request parameters as separate pointers, so
follow-up commits can easily change PanoramiX handler to not tweaking the
request buffer directly anymore. Another one is letting PanoramiXCreateWindow()
be called by ProcCreateWindow explicitly (when enabled), so we don't need to
wrap the core request proc vector anymore. Once that's done, the swapping can
also be moved into ProcCreateWindow().

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-29 11:03:19 +01:00
stefan11111
d220a0a9f0 shm: Fix segfault when the last X client closes
Fixes: https://github.com/X11Libre/xserver/pull/1236

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-10-27 09:27:52 +01:00
Enrico Weigelt, metux IT consult
7a0efe7da5 xv: use embedded private instead of pointer
The private struct is pretty small and it needs to be allocated anyways,
so save an extra allocation by directly embedding it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-26 13:57:49 +01:00
Enrico Weigelt, metux IT consult
fc14d32a1a dix: replace XACE_SCREEN_ACCESS by direct callback
Replace complicated xace hook by simple and cheap callback.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-22 13:53:25 +02:00
Enrico Weigelt, metux IT consult
38eedc3de5 Xext: shm: move ShmDescRec definition into shm.c
Only used inside shm.c, not anywhere else, so no need to keep it
in a public header file.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-21 20:36:44 +02:00
Enrico Weigelt, metux IT consult
a2068d6662 Xext: shm: drop obsolete ShmScreenClose()
Since it's now doing nothing more than unhooking itself, we really
don't need it anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-21 13:53:41 +02:00
Alan Coopersmith
238c1ccf4b Xext/xtest: avoid null dereference in ProcXTestFakeInput()
Reported in https://gitlab.freedesktop.org/xorg/xserver/-/issues/1817:

xwayland-24.1.6/redhat-linux-build/../Xext/xtest.c:383:14: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘dev’
xwayland-24.1.6/redhat-linux-build/../Xext/xtest.c:348:9: release_memory: ‘dev’ is NULL
xwayland-24.1.6/redhat-linux-build/../Xext/xtest.c:383:14: danger: dereference of NULL ‘dev’

xwayland-24.1.6/redhat-linux-build/../Xext/xtest.c:395:14: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘dev’
xwayland-24.1.6/redhat-linux-build/../Xext/xtest.c:348:9: release_memory: ‘dev’ is NULL
xwayland-24.1.6/redhat-linux-build/../Xext/xtest.c:395:14: danger: dereference of NULL ‘dev’

xwayland-24.1.6/redhat-linux-build/../Xext/xtest.c:426:14: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘dev’
xwayland-24.1.6/redhat-linux-build/../Xext
/xtest.c:348:9: release_memory: ‘dev’ is NULL
xwayland-24.1.6/redhat-linux-build/../Xext/xtest.c:426:14: danger: dereference of NULL ...
2025-10-21 13:02:04 +02:00
Alan Coopersmith
640a9cf51e Xext/xselinux: avoid memory leak in SELinuxAtomToSID()
Reported in https://gitlab.freedesktop.org/xorg/xserver/-/issues/1817:

xwayland-24.1.6/redhat-linux-build/../Xext/xselinux_label.c:142:13: warning[-Wanalyzer-malloc-leak]: leak of ‘rec’
xwayland-24.1.6/redhat-linux-build/../Xext/xselinux_label.c:133:1: enter_function: entry to ‘SELinuxAtomToSID’
xwayland-24.1.6/redhat-linux-build/../Xext/xselinux_label.c:141:15: acquire_memory: allocated here
xwayland-24.1.6/redhat-linux-build/../Xext/xselinux_label.c:69:12: branch_true: following ‘true’ branch...
xwayland-24.1.6/redhat-linux-build/../Xext/xselinux_label.c:142:13: danger: ‘rec’ leaks here; was allocated at [(2)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/1)
  140|       if (!rec) {
  141|           rec = calloc(1, sizeof(SELinuxAtomRec));
  142|->         if (!rec || !SELinuxArraySet(&arr_atoms, atom, rec))
  143|               return BadAlloc;
  144|       }

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2072>
2025-10-21 13:02:04 +02:00
Alan Coopersmith
c45edc0c51 Xext/xselinux: add fast path to ProcSELinuxListSelections()
If there's nothing to send, skip over a bunch of code to make a list
that won't be used, and hopefully make the code path clearer to both
humans and static analyzers, who raise errors as seen in https://gitlab.freedesktop.org/xorg/xserver/-/issues/1817 of
dereferencing NULL pointers when count == 0.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2072>
2025-10-21 13:02:04 +02:00
Alan Coopersmith
5a8effe1e7 Xext/sync: Avoid dereference of invalid pointer if malloc() failed
Reported incorrectly in https://gitlab.freedesktop.org/xorg/xserver/-/issues/1817 as:

xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2835:33: acquire_memory: allocated here
xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2843:12: danger: ‘priv’ leaks here; was allocated at [(30)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/29)

but the "leak" is really saving the pointer in an uninitalized pointer in
a structure that was already freed when the malloc of the SysCounterInfo
struct failed in SyncCreateSystemCounter(), because it returned the address
of the freed struct instead of NULL to indicate failure.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2072>
2025-10-21 13:02:04 +02:00
Alan Coopersmith
446baf6b15 Xext/sync: avoid null dereference if SysCounterGetPrivate() returns NULL
Reported in https://gitlab.freedesktop.org/xorg/xserver/-/issues/1817:

xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2664:9: danger: dereference of NULL ‘SysCounterGetPrivate(pCounter)’

xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2677:14: danger: dereference of NULL ‘SysCounterGetPrivate(pCounter)’

xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2767:14: danger: dereference of NULL ‘SysCounterGetPrivate(pCounter)’

xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2800:14: danger: dereference of NULL ‘SysCounterGetPrivate(pCounter)’

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2072>
2025-10-21 13:02:04 +02:00
Enrico Weigelt, metux IT consult
202c452b5f dix: replace XACE_SCREENSAVER_ACCESS by direct callback
Replace complicated xace hook by simple and cheap callback.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-21 10:49:08 +02:00
Enrico Weigelt, metux IT consult
8d19217b56 Xext: shm: move per-screen private structure into privates area
Instead of having a pointer to a struct just consisting of a pointer,
just move that struct directly into the privates area, so we not just
save one extra indirection, but also not having to care about an extra
chunk of malloc'ed memory anymore (thus getting rid of a potential
OOM bug)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-21 10:40:32 +02:00
Enrico Weigelt, metux IT consult
4825c4584a Xext: shm: shmint.h: drop superflous extern on function prototypes
Functions are already `extern` by default.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-21 10:23:11 +02:00
Enrico Weigelt, metux IT consult
f19e7a24a1 Xext: shm: unexport ShmSegType variable
Not used by any drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-21 10:22:47 +02:00
Enrico Weigelt, metux IT consult
be69bc3aae Xext: shm: fix missing ScreenClose hook registration
ShmScreenClose() needs to be registered as ScreenClose hook into
all screens - otherwise it won't be called and so we're missing
cleanup work.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-14 19:45:15 +02:00
Enrico Weigelt, metux IT consult
81a8619bda dix: replace XACE_CLIENT_ACCESS by direct callback
Replace complicated xace hook by simple and cheap callback.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-07 10:52:54 +02:00
Alan Coopersmith
0616df4a76 panoramix: avoid null dereference in PanoramiXMaybeAddDepth()
Reported in https://gitlab.freedesktop.org/xorg/xserver/-/issues/1817:

Error: GCC_ANALYZER_WARNING (CWE-476): [#def4]
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:748:5: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘PanoramiXDepths’
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:802:1: enter_function: entry to ‘PanoramiXConsolidate’
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:813:17: branch_true: following ‘true’ branch...
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:814:9: branch_true: ...to here
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:814:9: call_function: calling ‘PanoramiXMaybeAddDepth’ from ‘PanoramiXConsolidate’
746|       PanoramiXDepths = reallocarray(PanoramiXDepths,
747|                                      PanoramiXNumDepths, sizeof(DepthRec));
748|->     PanoramiXDepths[j].depth = pDepth->depth;
749|       PanoramiXDepths[j].numVids = 0;
750|       PanoramiXDepths[j].vids = NULL;

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2065>
2025-10-02 18:46:33 +02:00
stefan11111
2ee7e9bc92 Xext/panoramix.c: #include "os/osdep.h"
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-10-02 18:46:33 +02:00
Enrico Weigelt, metux IT consult
19921fd401 dix: unexport ConnectionInfo field
Not used by any drivers, so no need to keep it in public SDK.
Since it's not used by any drivers, effectively no ABI change, so
can be safely done within ABI-25.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-01 11:42:50 +02:00
Enrico Weigelt, metux IT consult
962580a15a treewide: macros lambda-esque screen iteration
iterating over screen list via lambda-esque macros calls like this

    DIX_FOR_EACH_SCREEN({
        do_something
    });

withing the body, the iterator variables `walkScreenIdx` and `walkScreen`
are defined and can be directly used (read-only). the code inside the body
is running in a separate scope.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-01 11:40:34 +02:00
Enrico Weigelt, metux IT consult
d58de12e73 Xext: xres: inline SProc*()'s
No need to have a hole bunch of extra functions, if we can just easily
inline the few relevant lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-30 09:57:36 +02:00
Enrico Weigelt, metux IT consult
8e68c8d514 dix: replace XACE_CLIENT_ACCESS by direct callback
Move the callbacks directly into DIX, since it's actually core infrastructure.
Also simplifying the whole machinery, by just using a simpel CallbackListPtr.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-29 11:24:13 +02:00
Enrico Weigelt, metux IT consult
3851c97247 xv: drop forgotten SProcXvDispatch() prototype
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-29 11:23:48 +02:00
Enrico Weigelt, metux IT consult
8a5ac961ca Xvmc: inline SProcXvMCDispatch()
No need for an extra function for a one-liner.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-29 11:23:36 +02:00
Enrico Weigelt, metux IT consult
ca484055c7 dix: unexport screen saver parameters
Not used by any external drivers, so no need to keep them in public
SDK headers. Since they're never used by drivers, it's effectively
not an ABI change, so can safely be done within ABI-25.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-29 11:01:21 +02:00
Enrico Weigelt, metux IT consult
f333cac5c2 Xext: namespace: fix NULL derefence on client close
Removing the namespace assignment of killed clients in ClientState-hook
is too early - we still need it later. Using the new ClientDestroyCallback
instead.

Closes: https://github.com/X11Libre/xserver/issues/486
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-26 16:28:17 +02:00
Enrico Weigelt, metux IT consult
995398ecde os: rename audit.h to audit_priv.h
Our convention is naming private (non-SDK) headers w/ _priv.h suffix.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-26 15:56:47 +02:00
Enrico Weigelt, metux IT consult
7afa753652 Xext: drop PanoramiXGCKey and PanoramiXScreenKey macros
We can directly use the actual fields, no need for these extra macros.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-26 15:38:07 +02:00
Enrico Weigelt, metux IT consult
6d00346893 Xext: xv: drop XvScreenKey macro
We can easily use &XvScreenKeyRec directly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-26 15:35:25 +02:00
Enrico Weigelt, metux IT consult
6168868906 dix: replace XACE_SERVER_ACCESS by direct callback
Move the callbacks directly into DIX, since it's actually core infrastructure.
Also simplifying the whole machinery, by just using a simpel CallbackListPtr.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-25 14:27:41 +02:00
Enrico Weigelt, metux IT consult
678b025df5 include: misc.h: drop duplicate definition of CallbackListPtr
This type is already defined in `include/callback.h` - anybody who wants it
most likely needs that include file, too.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-25 09:36:53 +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
3e5bb95a82 xace: drop obsolete/unused XaceAuditRec
This struct isn't used anymore for almost a decade, just a left over from
audit hooks removal, back in 2016.

Fixes: 6cb34816af
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-23 12:14:14 +02:00
Enrico Weigelt, metux IT consult
ac0a267f1d xace: drop unused XACE_AUTH_AVAIL
Not used anymore for almost two decades, so no need to keep it.

Fixes: eafaf40fb3
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-23 11:44:14 +02:00
Enrico Weigelt, metux IT consult
96b5da5a0d dix: replace XACE_EXT_ACCESS and XACE_EXT_DISPATCH by direct callback
Move the callbacks directly into DIX, since it's actually core infrastructure.
Also simplifying the whole machinery, by just using a simpel CallbackListPtr.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-23 11:37:50 +02:00
Enrico Weigelt, metux IT consult
d82aa8308d xace: drop never used XACE_KEY_AVAIL
This hook was never used, so no need to keep around something that's
really not used anywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-23 11:26:19 +02:00
Enrico Weigelt, metux IT consult
85cf8f0be4 Xext: Xv: inline SProc*()'s
No need to have a hole bunch of extra functions, if we can just easily
inline the few relevant lines.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-22 12:55:13 +02:00