Commit Graph

1034 Commits

Author SHA1 Message Date
Enrico Weigelt d9fc870293
Merge 9ddc54918a into d403cbd25c 2025-07-04 14:51:57 -04:00
dasha_uwu 7c64a06ba4 treewide: remove "lib" prefix in static_library names (meson)
this was producing static libraries named "liblibsomething.a"

Signed-off-by: dasha_uwu <dasha@linuxping.win>
2025-07-03 12:01:52 +02:00
Enrico Weigelt, metux IT consult 4036b8c163 os: log: vpnprintf(): ignore reverse justification modifier
The only caller is libinput, and we don't really need it, just silencing
bug message.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-01 17:15:56 +02:00
Enrico Weigelt, metux IT consult 9ddc54918a os: xtrans: fix calloc overflow warning
The size of `int` is machine specific and may be 64 bits wide, which could
overflow the calloc'able size. Practically cannot happen here, since the
ListenTransCount can't go above MAX_CONNECTIONS, but compiler can't know
that and so spitting out a warning.

Using uint32_t really is sufficient here.

> ../os/connection.c: In function ‘CreateWellKnownSockets’:
> ../os/connection.c:274:22: warning: argument 1 range [18446744071562067968, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
>   274 |     ListenTransFds = calloc(ListenTransCount, sizeof(int));
>       |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:23:46 +02:00
Enrico Weigelt, metux IT consult cc39bf7745 os: log: vpnprintf(): ignore reverse justification modifier
The only caller is libinput, and we don't really need it, just silencing
bug message.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 5d0b9f4508 os: xtrans: expand TRANS() macro to _XSERVTrans
Since TRANS() now will always expand the same, it's better for
maintenance, having the function names written explicitly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 8b3ab3586c os: xtrans: drop GetReopenInfo()
Not used anywhere, so no need to keep it around anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult cbcb9718ef os: xtrans: drop ifdefs on NAMEDNODENAME
It's always defined, so no ifdefs needed.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 053f43e6ae os: xtrans: drop DEV_PTMX
Not used anywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 1d57896358 os: xtrans: drop TRANS_CLIENT code pathes
Not needed in server-only code base.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult c62c0f093f os: xtrans: drop XSERV_t and x11_t defines
These are always enablde (x11_t is defined when XSERV_t is defined),
so no need for the #ifdef's anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult f6dd15f8d4 os: xtrans: drop ifdef TRANS_REOPEN
It's always defined, so the guards aren't necessary.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 13fd772406 os: xtrans: drop ifdef TRANS_SERVER
it's always defined, no extra guards needed.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 1dbc9d03ac os: xtrans: drop NEED_UTSNAME
All our supported platforms have this utsname.h.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 00316d71a7 os: xtrans: drop _WILLWINSOCK_
Not used anywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 53de959813 os: xtrans: drop own VErrorF() and ErrorF()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 258057b085 os: xtrans: replace bzero by memset
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult baf23b30d2 os: xtrans: drop XIM_t
Not defined anywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 70981fffb0 os: xtrans: drop FS_t
Not defined anywhere, so no need to keep it around anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 6a2f1e7bdb os: xtrans: drop FONT_t
Not used anywhere, so no need to keep it around anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult be255fd059 os: xtrans: drop ICE_t
Not used anywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 12da711d7c os: xtrans: drop GetMyNetworkId()
Not used anywhere, so lets drop it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult ada655a525 os: xtrans: drop unused GetPeerNetworkId()
Not used anywhere, so let's drop it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 6f31730785 os: xtrans: drop X_NO_SYS_UN
Not defined anywhere, so no need to check for it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 6a0c1a7d9f os: use internal xtrans instead of external library
Now that we've got xtrans bundled in our source tree, use this one and
drop the external dependency.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/691
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 6080bcf5b8 os: incorporate xtrans xtrans-1.6.0
Copy over from xtrans package, tag xtrans-1.6.0

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-30 13:08:06 +02:00
Enrico Weigelt, metux IT consult 13595b1801 xfree86: export OsBlockSignals() but keep it internal
Needed by the int10 module, so has to be in the symbol table.
But still not supposed to be used by out-of-tree drivers.

Reported-by: stefan11111 <stefan11111@shitposting.expert>
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-20 18:36:29 +02:00
Enrico Weigelt, metux IT consult 905329940a xfree86: export OsReleaseSignals() but keep it internal
Needed by the int10 module, so has to be in the symbol table.
But still not supposed to be used by out-of-tree drivers.

Reported-by: stefan11111 <stefan11111@shitposting.expert>
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-20 18:36:29 +02:00
Olivier Fourdan 899afa4c10 os: Check for integer overflow on BigRequest length
Check for another possible integer overflow once we get a complete xReq
with BigRequest.

Related to CVE-2025-49176

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Suggested-by: Peter Harris <pharris2@rocketsoftware.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2028>
2025-06-18 17:51:36 +02:00
Olivier Fourdan 0d6af5a542 os: Account for bytes to ignore when sharing input buffer
When reading requests from the clients, the input buffer might be shared
and used between different clients.

If a given client sends a full request with non-zero bytes to ignore,
the bytes to ignore may still be non-zero even though the request is
full, in which case the buffer could be shared with another client who's
request will not be processed because of those bytes to ignore, leading
to a possible hang of the other client request.

To avoid the issue, make sure we have zero bytes to ignore left in the
input request when sharing the input buffer with another client.

CVE-2025-49178

This issue was discovered by Nils Emmerich <nemmerich@ernw.de> and
reported by Julian Suleder via ERNW Vulnerability Disclosure.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2024>
2025-06-17 20:01:25 +02:00
Olivier Fourdan 3151e489e4 os: Do not overflow the integer size with BigRequest
The BigRequest extension allows requests larger than the 16-bit length
limit.

It uses integers for the request length and checks for the size not to
exceed the maxBigRequestSize limit, but does so after translating the
length to integer by multiplying the given size in bytes by 4.

In doing so, it might overflow the integer size limit before actually
checking for the overflow, defeating the purpose of the test.

To avoid the issue, make sure to check that the request size does not
overflow the maxBigRequestSize limit prior to any conversion.

The caller Dispatch() function however expects the return value to be in
bytes, so we cannot just return the converted value in case of error, as
that would also overflow the integer size.

To preserve the existing API, we use a negative value for the X11 error
code BadLength as the function only return positive values, 0 or -1 and
update the caller Dispatch() function to take that case into account to
return the error code to the offending client.

CVE-2025-49176

This issue was discovered by Nils Emmerich <nemmerich@ernw.de> and
reported by Julian Suleder via ERNW Vulnerability Disclosure.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2024>
2025-06-17 20:01:25 +02:00
Hermann Semenov d042e5a667 os: fix missing NULL check for vpnprintf()
Protect from NULL parameter to %s directive.

See also: https://github.com/X11Libre/xserver/issues/36

Signed-off-by: Herman Semenov <GermanAizek@yandex.ru>
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-16 20:28:01 +02:00
dasha_uwu 45de44f092 os: export SetCriticalOutputPending for nvidia
Signed-off-by: dasha_uwu <dasha@linuxping.win>
2025-06-16 10:32:48 +02:00
dec05eba 8c3c20f3fe xnest/os: Fix incorrect power of two operator
2^16 is 2 xor 16 which equals 18, not 2 to the power of 16 which is 65536

Signed-off-by: dec05eba <dec05eba@protonmail.com>
2025-06-13 13:27:25 +02:00
Enrico Weigelt, metux IT consult 301a5bde1b os: fix missing include of Xext/xf86bigfontsrv.h
We're calling XF86BigfontCleanup() from AbortServer(), so we need
it's prototype.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult f790bae8dc Xnamespace: initial config loader
This loads the configuration (simple text file) passed via command line.
For now just supporting static configuration, that's loaded on server
startup.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult e6467895f9 dix: add dixAllocServerXID()
Adding a separate function for allocating server-client's XIDs.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult 0b9a2fc6b0 dix: rename MarkClientException() to dixMarkClientException()
DIX functions should have proper naming.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult d51814d4bd os: move xdm function vector types from osdep.h to xdmcp.h
These are only needed in xdmcp.h, so move them there.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:47 +02:00
Enrico Weigelt, metux IT consult 5c0cbd0f92 os: drop own implementation of strcasecmp() and strncasecmp()
These are POSIX standard since 2001, so shouldn't be needed anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00
Enrico Weigelt, metux IT consult 625c657a4c os: log: add syslog support
Add support for logging to syslog.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00
Enrico Weigelt, metux IT consult e8d8047fd9 os: helper for parsing an counting-flag or value-flag option
Parses an option that may either be used for setting an integer value or
given one or multiple times (without argument) to increase an value

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00
Enrico Weigelt, metux IT consult 90442a3577 os: log: drop obsolete LogSetParameter()
The variables that can be set via this function are all now being
accessed directly. Not callers left, so drop it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00
Enrico Weigelt, metux IT consult 2a32187a38 os: directly set log file sync flag, instead of using LogSetParameter()
No need for extra call to some demuxer function for nothing but setting a
simple bool variable. Setting the sync flag really is nothing more than just
writing some value into a variable, so it's trivial to just to do that, instead
of having an unncessarily complex "universal setter" for that.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00
Enrico Weigelt, metux IT consult 09a95d82de os: directly set log file verbosity level, instead of using LogSetParameter()
No need for extra call to some demuxer function for nothing but setting a
simple int variable. Setting verbosity level really is nothing more than just
writing some value into a variable, so it's trivial to just to do that, instead
of having an unncessarily complex "universal setter" for that.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00
Enrico Weigelt, metux IT consult ae7c32abf6 os: directly set console verbosity level, instead of using LogSetParameter()
No need for extra call to some demuxer function for nothing but setting a
simple int variable. Setting verbosity level really is nothing more than just
writing some value into a variable, so it's trivial to just to do that, instead
of having an unncessarily complex "universal setter" for that.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00
Enrico Weigelt, metux IT consult 7c51bcb093 os: unexport internal logging functions
Lots of logging functions, especially init and teardown aren't called
by any drivers/modules, so no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00
Enrico Weigelt, metux IT consult 9a82f5c30b drop remains of cygwin support
Cygwin support doesn't seem to be used anymore, so it can be dropped.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00
Enrico Weigelt, metux IT consult f3faa4c84d os: fix link failure on Illumos
On SunOS, the BSD socket API as well as hostname lookups isn't
implemented in libc, but separate libraries. We need to link them
explicitly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00
Enrico Weigelt, metux IT consult 1708c689a8 os: fix FTBS on Illumos due missing symbols
Several feature defines need to be set before including system headers,
otherwise build breaks:

> /usr/include/X11/Xtrans/Xtranssock.c: In function '_XSERVTransSocketRead':
> /usr/include/X11/Xtrans/Xtranssock.c:2161:14: error: 'struct msghdr' has no member named 'msg_control'
>  2161 |             .msg_control = cmsgbuf.buf,
>       |              ^~~~~~~~~~~
> /usr/include/X11/Xtrans/Xtranssock.c:2162:14: error: 'struct msghdr' has no member named 'msg_controllen'
>  2162 |             .msg_controllen = CMSG_LEN(MAX_FDS * sizeof(int))
>       |              ^~~~~~~~~~~~~~
>
> ../os/access.c:339:14: error: implicit declaration of function 'asprintf'; did you mean 'Xasprintf'? [-Werror=implicit-function-declaration]
>   339 |     length = asprintf(addr, "%s%c%s", type, delimiter, value);
>       |              ^~~~~~~~
>       |              Xasprintf

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:46 +02:00