XLibre Xserver
Go to file
Olivier Fourdan 92bcebfd7e 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>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1762>
2025-01-13 11:44:11 +01:00
.gitlab-ci ci: Install wayland-protocols 1.38 2024-12-02 08:55:34 +00:00
Xext dix: unexport Ones() 2024-10-26 16:35:57 +00:00
Xi Xi: avoid NULL pointer dereference if GetXTestDevice returns NULL 2024-10-28 05:38:25 +00:00
composite dix: unexport Ones() 2024-10-26 16:35:57 +00:00
config drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
damageext drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
dbe drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
dix dix: limit checks to MAX_VALUATORS when generating Xi events 2024-10-28 05:38:25 +00:00
doc dix: move colormap flags into colormap_priv.h and rename them 2024-09-01 22:06:50 +00:00
dri3 treewide: replace xnfalloc() calls to XNFalloc() 2024-07-26 23:41:33 +00:00
exa drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
fb Revert "fb: Declare wfbFinishScreenInit, wfbScreenInit for !FB_ACCESS_WRAPPER" 2024-11-08 17:42:09 +00:00
glamor drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
glx drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
hw xwayland: Do not keep the cursor's pixmap around 2024-12-20 09:29:03 +01:00
include dix-config.h: add HAVE_SOCKLEN_T definition 2024-10-30 12:26:58 -07:00
man Xserver.man: Note that -byteswappedclients is the default in this release 2024-03-23 10:27:03 -07:00
mi mi: misprite.h: drop unnecessary extern on functions 2024-10-10 14:44:52 +00:00
miext drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
os dix: Use __builtin_popcountl if available to replace Ones() 2024-10-26 10:04:13 -07:00
present build: Move epoll dependency check 2024-09-02 11:52:26 +00:00
pseudoramiX pseudoramix: replace PseudoramiXTrace & PseudoramiXDebug by LogMessageVerb 2024-10-10 18:59:40 +00:00
randr randr: fix wrong call to RRGetScreenResources() in swapped case 2024-10-10 20:59:35 +00:00
record drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
render render: avoid NULL pointer dereference if PictureFindVisual returns NULL 2024-10-28 05:38:25 +00:00
test dix: unexport non-public functions from dixgrabs.h and document prototypes 2024-10-10 13:50:57 +00:00
xfixes drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
xkb xkb: Always use MAP_LENGTH keymap size 2025-01-13 11:44:11 +01:00
.appveyor.yml appveyor: Add libxcvt build dep 2021-11-04 13:03:25 +00:00
.dir-locals.el .dir-locals.el: Add missing final newline 2019-10-01 17:05:28 +00:00
.git-blame-ignore-revs Ignore the coding style change commit during git blame 2024-12-06 09:55:53 +10:00
.gitignore Clean up the .gitignore file 2024-01-12 00:50:24 +00:00
.gitlab-ci.yml ci: Install wayland-protocols 1.38 2024-12-02 08:55:34 +00:00
.mailmap Add a .mailmap file to canonicalize author names and emails 2023-03-15 18:10:51 +00:00
.travis.yml travis: Add OSX meson build to matrix 2019-05-02 15:42:58 +00:00
COPYING modesetting: Merge modesetting's COPYING into the xserver's. 2014-09-15 12:46:02 -07:00
README.md Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
meson.build build: Bump wayland-protocols requirement to 1.38 2024-12-02 08:55:34 +00:00
meson_options.txt os: drop SUN-DES-1 authentication 2024-06-18 00:52:11 +00: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