Find a file
Olivier Fourdan d1111eb0c1 render: Avoid possible double-free in ProcRenderAddGlyphs()
ProcRenderAddGlyphs() adds the glyph to the glyphset using AddGlyph() and
then frees it using FreeGlyph() to decrease the reference count, after
AddGlyph() has increased it.

AddGlyph() however may chose to reuse an existing glyph if it's already
in the glyphSet, and free the glyph that was given, in which case the
caller function, ProcRenderAddGlyphs() will call FreeGlyph() on an
already freed glyph, as reported by ASan:

  READ of size 4 thread T0
    #0 in FreeGlyph xserver/render/glyph.c:252
    #1 in ProcRenderAddGlyphs xserver/render/render.c:1174
    #2 in Dispatch xserver/dix/dispatch.c:546
    #3 in dix_main xserver/dix/main.c:271
    #4 in main xserver/dix/stubmain.c:34
    #5 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #6 in __libc_start_main_impl ../csu/libc-start.c:360
    #7  (/usr/bin/Xwayland+0x44fe4)
  Address is located 0 bytes inside of 64-byte region
  freed by thread T0 here:
    #0 in __interceptor_free libsanitizer/asan/asan_malloc_linux.cpp:52
    #1 in _dixFreeObjectWithPrivates xserver/dix/privates.c:538
    #2 in AddGlyph xserver/render/glyph.c:295
    #3 in ProcRenderAddGlyphs xserver/render/render.c:1173
    #4 in Dispatch xserver/dix/dispatch.c:546
    #5 in dix_main xserver/dix/main.c:271
    #6 in main xserver/dix/stubmain.c:34
    #7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
  previously allocated by thread T0 here:
    #0 in __interceptor_malloc libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 in AllocateGlyph xserver/render/glyph.c:355
    #2 in ProcRenderAddGlyphs xserver/render/render.c:1085
    #3 in Dispatch xserver/dix/dispatch.c:546
    #4 in dix_main xserver/dix/main.c:271
    #5 in main xserver/dix/stubmain.c:34
    #6 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
  SUMMARY: AddressSanitizer: heap-use-after-free xserver/render/glyph.c:252 in FreeGlyph

To avoid that, make sure not to free the given glyph in AddGlyph().

v2: Simplify the test using the boolean returned from AddGlyph() (Michel)
v3: Simplify even more by not freeing the glyph in AddGlyph() (Peter)

Fixes: bdca6c3d1 - render: fix refcounting of glyphs during ProcRenderAddGlyphs
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1659
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1476>
(cherry picked from commit 337d8d48b6)
2026-01-19 12:32:25 -08:00
.gitlab-ci Update CI for Xwayland explicit sync 2026-01-19 12:32:24 -08:00
composite composite: Expose CompositeIsImplicitRedirectException 2023-07-18 09:34:39 +00:00
config config: wscons: fix warning on discarded const 2026-01-19 12:32:24 -08:00
damageext Remove autotools support 2021-10-27 13:15:40 +03:00
dbe dbe: drop obsolete NEED_DBE_PROTOCOL 2026-01-19 12:32:19 -08:00
dix dix: drop now obsolete cursorScreenDevPriv 2026-01-19 12:32:21 -08:00
doc dix: dixutils: make workQueue pointer dix-private 2026-01-19 12:32:18 -08:00
dri3 DRI3: add DRI3ImportSyncobj and DRI3FreeSyncobj 2026-01-19 12:32:24 -08:00
exa replace _X_INLINE by inline in internal static functions 2024-02-05 19:26:14 +00:00
fb fb: Fix 1bpp Xservers on "whitePixel=0, blackPixel=1" VRAMs 2024-01-03 19:43:16 +00:00
glamor glamor: drop duplicate _X_EXPORT from .c source 2026-01-19 12:32:19 -08:00
glx glx: move private definitions from vndserver.h to vndserver_priv.h 2026-01-19 12:32:18 -08:00
hw xwayland: don't scrap pending present requests 2026-01-19 12:32:24 -08:00
include xkb: drop ununsed XkbNameMatchesPattern() 2026-01-19 12:32:25 -08:00
m4 Add ax_pthread.m4 to m4/ 2016-05-29 19:20:51 -07:00
man Xserver.man: Note that -byteswappedclients is the default in this release 2026-01-19 12:32:23 -08:00
mi mi: fix rounding issues around zero in miPointerSetPosition 2026-01-19 12:32:24 -08:00
miext os: move os_move_fd() out of public API 2026-01-19 12:32:20 -08:00
os os: move SELinux enforcement state to the extension 2026-01-19 12:32:24 -08:00
present xwayland: add support for wp_linux_drm_syncobj_v1 2026-01-19 12:32:24 -08:00
pseudoramiX Remove autotools support 2021-10-27 13:15:40 +03:00
randr randr: drop duplicate _X_EXPORT from .c source 2026-01-19 12:32:19 -08:00
record record: Support architectures with sizeof(void*) > sizeof(long) 2023-12-17 19:30:52 +00:00
render render: Avoid possible double-free in ProcRenderAddGlyphs() 2026-01-19 12:32:25 -08:00
test test: fix the xi2 protocol swapping tests to actually work 2026-01-19 12:32:24 -08:00
Xext include: unpexport SELINUX_* consts from include/global.h 2026-01-19 12:32:24 -08:00
xfixes Remove "All rights reserved" from Oracle copyright notices 2023-02-25 09:40:41 -08:00
Xi Xi: ProcXIPassiveGrabDevice needs to use unswapped length to send reply 2026-01-19 12:32:24 -08:00
xkb xkb: drop ununsed XkbNameMatchesPattern() 2026-01-19 12:32:25 -08: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
.gitignore Clean up the .gitignore file 2024-01-12 00:50:24 +00:00
.gitlab-ci.yml Update CI for Xwayland explicit sync 2026-01-19 12:32:24 -08: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
meson.build xwayland: add support for wp_linux_drm_syncobj_v1 2026-01-19 12:32:24 -08:00
meson_options.txt xwayland/glamor: Drop the EGLStream backend 2026-01-19 12:32:21 -08: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