xserver/os
Olivier Fourdan 437a0cad0b 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>
(cherry picked from commit 03731b326a)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2026>
2025-06-17 15:07:43 +02:00
..
.gitignore dix and os: gitignore dix.O and os.O 2011-09-23 17:14:47 -07:00
access.c os: Fix NULL pointer dereference 2024-09-24 11:33:13 +02:00
alloc.c os: move alloc functions to separate source file 2024-02-29 10:09:37 +00:00
auth.c os: move mitauth prototypes to separate header 2024-02-22 23:42:52 +00:00
auth.h os: move Auth* function types to separate header 2024-02-22 23:42:53 +00:00
backtrace.c Fix missing include of <sys/wait.h> 2024-03-18 23:02:45 +00:00
busfault.c os: Fix iteration over busfaults 2017-02-23 09:20:48 +10:00
client.c Return NULL in *cmdname if the client argv or argv[0] is NULL 2024-09-24 10:47:54 +02:00
connection.c os/connection: Make sure partial is initialized 2025-02-04 09:21:13 +01:00
fmt.c os: move out Format*() functions 2024-03-09 17:34:51 +00:00
fmt.h os: move out Format*() functions 2024-03-09 17:34:51 +00:00
inputthread.c os, shm: fcntl()'s third argument is integer, not pointer 2020-12-18 09:36:30 -05:00
io.c os: Do not overflow the integer size with BigRequest 2025-06-17 15:07:43 +02:00
log.c os: move out Format*() functions 2024-03-09 17:34:51 +00:00
meson.build os: move out Format*() functions 2024-03-09 17:34:51 +00:00
mitauth.c os: move mitauth prototypes to separate header 2024-02-22 23:42:52 +00:00
mitauth.h os: move Auth* function types to separate header 2024-02-22 23:42:53 +00:00
oscolor.c os: color: fix possible buffer overflow vulnerability 2024-02-22 23:33:34 +00:00
osdep.h os: Explicitly include X11/Xmd.h for CARD32 definition to fix building on i686 2024-07-04 08:36:40 +00:00
osinit.c os: consolidate busfault handling 2024-02-23 23:15:12 +00:00
ospoll.c ospoll: Fix Solaris ports implementation to build on Solaris 11.4 2019-09-23 15:12:01 -07:00
ospoll.h os: Add ospoll interface [v2] 2016-07-21 15:04:47 -04:00
reallocarray.c Import reallocarray() from OpenBSD 2015-04-21 16:57:08 -07:00
rpcauth.c os: rpc: fix type mismatch 2024-03-21 22:57:40 +00:00
rpcauth.h os: move Auth* function types to separate header 2024-02-22 23:42:53 +00:00
strcasecmp.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
strcasestr.c os: fix mising prototype / include on WIN32 builds 2024-03-03 23:02:54 +00:00
string.c os: move string functions to separate source file 2024-02-29 10:09:37 +00:00
strlcat.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
strlcpy.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
strndup.c os: Ensure <dix-config.h> is included in strndup.c 2013-02-14 09:20:46 -08:00
timingsafe_memcmp.c timingsafe_memcmp: Fix meson build 2017-05-10 10:56:16 -04:00
utils.c os: move SELinux enforcement state to the extension 2024-03-25 19:40:04 +00:00
WaitFor.c os: NextDPMSTimeout: mark intentional fallthroughs in switch 2025-02-04 09:17:35 +01:00
xdmauth.c os: move xdmauth prototypes to separate header 2024-02-22 23:42:52 +00:00
xdmauth.h os: move Auth* function types to separate header 2024-02-22 23:42:53 +00:00
xdmcp.c os: fix missing include of <errno.h> 2024-03-21 17:32:30 +01:00
xdmcp.h Fix build with -Dxdmcp=false 2024-02-25 11:55:56 +01:00
xprintf.c Remove "All rights reserved" from Oracle copyright notices 2023-02-25 09:40:41 -08:00
xserver_poll.c os: Fix build of xserver_poll.c on MinGW 2019-05-18 14:59:38 +00:00
xsha1.c include: move xsha1.h to os/ 2024-03-03 23:11:05 +00:00
xsha1.h include: move xsha1.h to os/ 2024-03-03 23:11:05 +00:00
xstrans.c Clean up a couple of warnings in os/ 2013-10-31 16:58:12 -07:00