Commit Graph

21898 Commits

Author SHA1 Message Date
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
c046c7629e dix: inline SProcPolyText()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-21 10:49:37 +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
2d71f0579f xkb: inline SProcXkbGetGeometry()
No need to have whole extra functions for just a few LoC.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-21 10:26:57 +02:00
Enrico Weigelt, metux IT consult
335dd555fe xkb: inline SProcXkbSetDeviceInfo()
No need to have whole extra functions for just a few LoC.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-21 10:26:21 +02:00
Alan Coopersmith
e446fdc14a xfree86: add missing headers to build sun_init.c on Solaris/SPARC
Fixes: 0f715b4ca4 ("xfree86: os-support: move hidden Solaris-specific symbols out of public header")
Fixes: e2fa0d2ae0 ("fix including <sys/mman.h>")

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2070>

Further explanation about this commit by @alanc:

This particular set of `#ifdefs` matches the ones around the code using the fbio ioctls and mmap calls in the `xf86CloseConsole()` code later in the file:
c62cd2feaa/hw/xfree86/os-support/solaris/sun_init.c (L281)
reflecting the lack of /dev/fb style drivers on x86 systems on Solaris.
2025-10-21 10:25:32 +02:00
Alan Coopersmith
855aa4ef86 xfree86: Fix -Wdiscarded-qualifiers warnings in SPARC Sbus probe code
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2070>
2025-10-21 10:25:32 +02:00
Alan Coopersmith
c179700b99 xfree86: fix meson build on 64-bit Solaris/SPARC systems
For cpu_family(), meson returns "sparc" for 32-bit sparc,
and "sparc64" for 64-bit sparc, regardless of the OS in use.

For cpu(), meson returns values like "sun4v" on Solaris/SPARC,
and doesn't promise stability of the values, or portability across
OS'es, unlike cpu_family().

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2070>
2025-10-21 10:25: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
a641a197f4 render: consolidate byte-swapping in ProcRenderCompositeGlyphs()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-21 10:22:14 +02:00
Enrico Weigelt, metux IT consult
9370aafb36 Xi: inline SProcXUngrabDeviceButton()
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-10-21 10:21:52 +02:00
Enrico Weigelt, metux IT consult
a28cacbef2 Xi: inline SProcXIAllowEvents()
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-10-21 10:21:31 +02:00
Enrico Weigelt, metux IT consult
34d4c56432 render: consolidate byte-swapping in ProcRenderTriFan()
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-10-20 11:45:13 +02:00
Enrico Weigelt, metux IT consult
8399c4e263 dix: consolidate struct _CallbackList and struct _CallbackRec into dixutil.c
These structs are only used inside dixutils, the actual callback handling
functions. Therefore no need to keep them in public header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-20 10:30:22 +02:00
kohnish
166dec4701 Fix missing include and signature mismatch on gentoo linux 2025-10-20 10:25:28 +02:00
Enrico Weigelt, metux IT consult
437515032b Xi: inline SProcXGetDeviceMotionEvents()
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-10-20 10:01:40 +02:00
Enrico Weigelt, metux IT consult
302533aac8 Xi: inline ProcXSetDeviceFocus()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-20 10:01:19 +02:00
Enrico Weigelt, metux IT consult
5330084bd5 xkb: inline SProcXkbSetMap()
No need to have whole extra functions for just a few LoC.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-20 10:00:41 +02:00
callmetango
24a4dd4606 README.md: updated links to new packaging repository pt2
Updated remaining links to new packaging repository and the discussions
moved there.

Part-of: X11Libre/misc#406
Signed-off-by: callmetango <callmetango@users.noreply.github.com>
2025-10-17 09:46:20 -04: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
stefan11111
214d0e67de xfree86/common: Match drivers "modesetting" and "nvidia" on nvidia cards
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-10-14 10:39:22 +02:00
callmetango
9b94133f1c README.md: fixed some misspellings
Signed-off-by: callmetango <callmetango@users.noreply.github.com>
2025-10-13 11:42:14 -04:00
callmetango
163c5a495b README.md: updated links to new packaging repository
* updated links to new packaging repository and the discussions moved
  there
* removed links to the creation of DEB and RPM packages since this has
  been done

Fixes: X11Libre/misc#406
Signed-off-by: callmetango <callmetango@users.noreply.github.com>
2025-10-13 11:42:14 -04:00
stefan11111
036432980b modesetting: Initialize the cursor image with the smallest size supported by all CRTCs.
We try to find the smallest size we can use for the cursor image.

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-10-13 14:01:04 +02:00
stefan11111
702625f028 modesetting: use MAX macro in more places
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-10-13 14:01:04 +02:00
Enrico Weigelt, metux IT consult
6730fd8251 dix: fix missing includes of extinit.h
Don't rely on this file just being included indirectly by somebody else
just by accident.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-07 11:07:00 +02:00
Enrico Weigelt, metux IT consult
a56e1665a1 dix: inline SProcPoly()
Yet another step for getting rid of the unnecessarily complicated SProc*
machinery. Later, all those swap*() calls will be replaced by macros.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-07 11:06:37 +02:00
Enrico Weigelt, metux IT consult
92af1b26ff render: consolidate byte-swapping in ProcRenderTriStrip()
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-10-07 10:55:23 +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
Enrico Weigelt, metux IT consult
0f0164882f Xi: inline SProcXGetExtensionVersion()
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-10-03 17:27:58 +02:00
stefan11111
4984b12967 modesetting: Use the same cursor mask interleave as other drivers
There is no explanation for these values, but the one we are
currently using doesn't work.

Use the values from vendor-speciffic drivers, which do work.

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-10-02 18:49:40 +02:00
stefan11111
bbcf22183a modesetting: Only use the querried fallback if both querries succeed
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-10-02 18:49:40 +02:00
stefan11111
25cae34122 modesetting: add braces around an if
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-10-02 18:49:40 +02:00
stefan11111
d5162b4493 modesetting: Handle cursor images and buffers smaller than 64x64 correctly
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-10-02 18:49:40 +02:00
stefan11111
5752116343 modesetting: Clear the cursor buffer explicitly
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-10-02 18:49:40 +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
Mikhail Dmitrichenko
de025ce306 dix: avoid null ptr deref at doListFontsWithInfo
In the doListFontsWithInfo function in dixfonts.c, when a font alias is
encountered (err == FontNameAlias), the code saves the current state
and allocates memory for c->savedName.

If the malloc(namelen + 1) call fails, c->savedName remains NULL,
but c->haveSaved is still set to TRUE. Later, when a font is
successfully resolved (err == Successful), the code uses c->savedName
without checking if it is NULL, so there is potential null ptr
dereference. XNFalloc will check result of malloc and stop
program execution if allocation was failed.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1842

Signed-off-by: default avatarMikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2062>
2025-10-02 18:46:33 +02:00
Enrico Weigelt, metux IT consult
0a5815b075 render: consolidate byte-swapping in ProcRenderTriangles()
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-10-02 14:50:14 +02:00
Enrico Weigelt, metux IT consult
a41273572f xfree86: fix missing includes of extinit.h
Don't rely on this file just being included indirectly by somebody else
just by accident.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-01 14:46:26 +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
eaff5ba96c dix: ProcLookupColor(): simplify code flow
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-30 10:01:28 +02:00
Enrico Weigelt, metux IT consult
bff6f86afc render: consolidate byte-swapping in ProcRenderTrapezoids()
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-30 10:01:11 +02:00