Find a file
Olivier Fourdan 6115eb1f65 xkb: Always use MAP_LENGTH keymap size
Generating the modifier modmap, the helper function generate_modkeymap()
would check the entire range up to the MAP_LENGTH.

However, the given keymap might have less keycodes than MAP_LENGTH, in
which case we would go beyond the size of the modmap, as reported by
ASAN:

==ERROR: AddressSanitizer: heap-buffer-overflow
READ of size 1 at 0x5110001c225b thread T0
    #0 0x5e7369393873 in generate_modkeymap ../dix/inpututils.c:309
    #1 0x5e736930dcce in ProcGetModifierMapping ../dix/devices.c:1794
    #2 0x5e7369336489 in Dispatch ../dix/dispatch.c:550
    #3 0x5e736934407d in dix_main ../dix/main.c:275
    #5 0x7e46d47b2ecb in __libc_start_main
    #6 0x5e73691be324 in _start (xserver/build/hw/xwayland/Xwayland)

Address is located 0 bytes after 219-byte region
allocated by thread T0 here:
    #0 0x7e46d4cfc542 in realloc
    #1 0x5e73695aa90e in _XkbCopyClientMap ../xkb/xkbUtils.c:1142
    #2 0x5e73695aa90e in XkbCopyKeymap ../xkb/xkbUtils.c:1966
    #3 0x5e73695b1b2f in XkbDeviceApplyKeymap ../xkb/xkbUtils.c:2023
    #4 0x5e73691c6c18 in keyboard_handle_keymap ../hw/xwayland/xwayland-input.c:1194

As MAP_LENGTH is used in various code paths where the max keycode might
not be easily available, best is to always use MAP_LENGTH to allocate the
keymaps so that the code never run past the buffer size.

If the max key code is smaller than the MAP_LENGTH limit, fill-in the gap
with zeros.

That also simplifies the code slightly as we do not constantly need to
reallocate the keymap to adjust to the max key code size.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1780
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
(cherry picked from commit 92bcebfd7e)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1767>
2025-02-05 15:02:24 +01:00
.gitlab-ci ci: Install libxcvt from git 2021-08-06 11:29:29 +00:00
composite composite: Fix use-after-free of the COW 2023-03-29 14:20:26 +02:00
config config: add a quirk for Apple Silicon appledrm 2024-12-02 16:11:51 +00:00
damageext More missing version checks in SProcs 2021-08-08 12:43:01 +00:00
dbe meson: hide C API if Xorg is disabled (like autotools) 2021-03-11 00:22:36 +00:00
dix dix: limit checks to MAX_VALUATORS when generating Xi events 2025-02-05 15:02:23 +01:00
doc meson: Implement developer documentation build 2021-08-20 10:26:07 +00:00
dri3 meson: hide C API if Xorg is disabled (like autotools) 2021-03-11 00:22:36 +00:00
exa exa: rename some badly named variables 2020-07-10 06:17:40 +10:00
fb meson: hide C API if Xorg is disabled (like autotools) 2021-03-11 00:22:36 +00:00
glamor glamor: Fix possible double-free 2025-02-05 15:02:23 +01:00
glx glx: Call XACE hooks on the GLX buffer 2024-01-16 09:58:09 +01:00
hw modesetting: avoid memory leak when ms_present_check_unflip() returns FALSE 2025-02-05 15:02:23 +01:00
include dix-config.h: add HAVE_SOCKLEN_T definition 2024-10-30 17:12:06 -07:00
m4 Add ax_pthread.m4 to m4/ 2016-05-29 19:20:51 -07:00
man Allow disabling byte-swapped clients 2024-03-23 14:42:15 -07:00
mi mi: fix rounding issues around zero in miPointerSetPosition 2024-04-05 13:46:40 +10:00
miext rootless: Add additional debug logging to help triage XQuartz fb/rootless/damage crashes 2022-12-21 01:23:50 -08:00
os os: NextDPMSTimeout: mark intentional fallthroughs in switch 2025-02-05 15:02:23 +01:00
present present: Send a PresentConfigureNotify event for destroyed windows 2023-04-24 10:13:27 +02:00
pseudoramiX Unvalidated lengths 2017-10-10 23:33:34 +02:00
randr Removing the code that deletes an existing monitor in RRMonitorAdd 2024-01-03 08:42:34 +01:00
record record: Fix out of bounds access in SwapCreateRegister() 2021-12-15 10:41:18 +02:00
render render: avoid NULL pointer dereference if PictureFindVisual returns NULL 2025-02-05 15:02:23 +01:00
test tests: Fix build failure from missing micmap.c 2022-06-26 03:03:26 -07:00
Xext Xext: SProcSyncCreateFence needs to swap drawable id too 2024-03-27 19:39:19 +00:00
xfixes xfixes: Fix out of bounds access in *ProcXFixesCreatePointerBarrier() 2021-12-15 10:41:19 +02:00
Xi Xi: avoid NULL pointer dereference if GetXTestDevice returns NULL 2025-02-05 15:02:23 +01:00
xkb xkb: Always use MAP_LENGTH keymap size 2025-02-05 15:02:24 +01:00
.appveyor.yml Drop DMX DDX 2021-09-07 09:34:31 +00:00
.dir-locals.el .dir-locals.el: Add missing final newline 2019-10-01 17:05:28 +00:00
.gitignore .gitignore: Add new autotools file 'test-driver' 2014-04-21 13:41:42 -07:00
.gitlab-ci.yml ci: Install libxcvt from git 2021-08-06 11:29:29 +00:00
.travis.yml travis: Add OSX meson build to matrix 2019-05-02 15:42:58 +00:00
autogen.sh autogen: Set a default subject prefix for patches 2016-02-08 17:41:38 -05:00
configure.ac xserver 21.1.15 2024-12-17 12:39:36 -05:00
COPYING modesetting: Merge modesetting's COPYING into the xserver's. 2014-09-15 12:46:02 -07:00
devbook.am doc: Create a script to filter xmlto output 2015-01-05 14:24:06 -08:00
docbook.am docbook.am: embed css styles inside the HTML HEAD element 2011-09-21 14:07:49 -07:00
Makefile.am Makefile.am: Add missing meson build files to release tarball 2021-11-06 21:22:23 +02:00
manpages.am man: Fix automake seddery 2018-05-08 12:15:30 -04:00
meson.build xserver 21.1.15 2024-12-17 12:39:36 -05:00
meson_options.txt meson: Provide options to set CFBundleVersion and CFBundleVersionString in XQuartz 2022-06-19 23:10:48 -07:00
README.md Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
xorg-server.m4 xorg-server.m4: just all cflags instead of just sdkdir 2018-09-20 20:12:24 +01:00
xorg-server.pc.in xfree86: link modules against Xorg symbols on Cygwin 2012-04-05 21:57:07 -05:00
xserver.ent.in doc: relocate xserver.ent in the package root directory 2011-05-14 11:22:26 -07:00

X Server

The X server accepts requests from client applications to create windows, which are (normally rectangular) "virtual screens" that the client program can draw into.

Windows are then composed on the actual screen by the X server (or by a separate composite manager) as directed by the window manager, which usually communicates with the user via graphical controls such as buttons and draggable titlebars and borders.

For a comprehensive overview of X Server and X Window System, consult the following article: https://en.wikipedia.org/wiki/X_server

All questions regarding this software should be directed at the Xorg mailing list:

https://lists.freedesktop.org/mailman/listinfo/xorg

The primary development code repository can be found at:

https://gitlab.freedesktop.org/xorg/xserver

For patch submission instructions, see:

https://www.x.org/wiki/Development/Documentation/SubmittingPatches

As with other projects hosted on freedesktop.org, X.Org follows its Code of Conduct, based on the Contributor Covenant. Please conduct yourself in a respectful and civilized manner when using the above mailing lists, bug trackers, etc:

https://www.freedesktop.org/wiki/CodeOfConduct