xserver/Xext
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Octavia Togami 950ee20ba8 Fix use-after-free caused by duplicate glyphs in one glyphset
We make two glyphsets, GS1 and GS2, both with the same format depth.
GS1 contains any glyph different from the others, let's call it U
(unique). GS2 contains two glyphs with the same content, or at least
sha1 hash. Let's call them A and B.

We first register GS1 and GS2. GS1 has no problems, but before the
fix, registering GS2 breaks accounting in `globalGlyphs`. Since there
is no check for duplicate glyphs within a single set, we make two
`GlyphNew` entries for A and B. Now in the loop at the end, we go over
each entry and call `AddGlyph` and `FreeGlyph`:
1. AddGlyph(GS2, A, idA) inserts A into `globalGlyphs`
2. FreeGlyph(A) drops A's refcnt by one, but as it's being held in
   `globalGlyphs` it's kept alive.
3. AddGlyph(GS2, B, idB) finds A in `globalGlyphs` and reuses it
   instead of inserting B
4. FreeGlyph(B) drops B's refcnt by one (to zero), and B is freed.
   Before the fix, the lookup in `globalGlyphs` finds A's entry, and
   since it isn't a DeletedGlyph, it erroneously removes the
   `gr->glyph` pointing to `A` and decrements `tableEntries`. This
   results in `tableEntries` being off-by-one as `A` is still alive.

Now, we free the glyphsets in a particular order. Freeing GS1 results
in calling FreeGlyph(U), which will decrement U's refcnt to zero, and
free U. This clears out the entry in `globalGlyphs` for U and
decrements `tableEntries`, which due to the earlier error is now zero.
When `FreeGlyphSet` sees this, it clears the `globalGlyphs` for that
format depth. Now freeing A or GS2 (which transitively frees A) will
try to check the `globalGlyphs` at that format depth, but because it
was cleared out this crashes.

The fix here is to change FreeGlyph to only free a glyph from
`globalGlyphs` that is exactly the glyph being freed, so that
FreeGlyph(B) doesn't touch `globalGlyphs` at all. This keeps a proper
count in `tableEntries` and prevents `globalGlyphs[fdepth]` from being
freed before A is freed.

Closes: #1881
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2264>
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-07 14:48:49 +02:00
..
bigreq Xext: bigreq: move it into it's own subdir 2026-06-18 13:07:15 +02:00
composite treewide: clean up includes of misc.h 2026-06-19 19:24:57 +02:00
damage Xext: move remaining panoramix headers into panoramix subdir. 2026-06-17 19:01:48 +02:00
doublebuffer treewide: clean up includes of misc.h 2026-06-19 19:24:57 +02:00
dpms treewide: clean up includes of misc.h 2026-06-19 19:24:57 +02:00
dri2 xfixes: move it under the Xext/ directory 2026-06-17 15:33:32 +02:00
dri3 Xext/dri3: Copy the DRI3 info struct instead of just the pointer 2026-09-11 14:13:42 +02:00
geext Xext: geext: move it into its own subdir 2026-06-18 14:07:18 +02:00
glx Xext/glx: exports symbols to make extension shared 2026-08-24 13:38:06 +02:00
namespace Xext: namespace: Allow using tabs as delimeters 2026-01-22 08:57:15 +01:00
panoramiX panoramiX: zero-init xAllocColorReply to avoid leaking uninitialised bytes 2026-08-24 12:32:10 +02:00
present Xext/present: Copy the present info struct instead of just the pointer 2026-09-11 14:13:42 +02:00
pseudoramiX pseudoramiX: move it under Xext/ 2026-06-17 08:38:34 +02:00
randr randr: Set the legacy RandR size range to include rotations 2026-10-07 14:36:31 +02:00
record treewide: clean up includes of misc.h 2026-06-19 19:24:57 +02:00
render Fix use-after-free caused by duplicate glyphs in one glyphset 2026-10-07 14:48:49 +02:00
saver treewide: clean up includes of misc.h 2026-06-19 19:24:57 +02:00
security Xext: security: move it into it's own subdir 2026-06-18 14:47:39 +02:00
shape treewide: clean up includes of misc.h 2026-06-19 19:24:57 +02:00
shm treewide: clean up includes of misc.h 2026-06-19 19:24:57 +02:00
sync Xext: sync: move it into it's own subdir 2026-06-18 15:32:45 +02:00
xcmisc treewide: clean up includes of misc.h 2026-06-19 19:24:57 +02:00
xf86bigfont Xext/xf86bigfont: guard the Unix-only bits for mingw (Windows) 2026-07-22 10:32:26 +02:00
xfixes treewide: clean up includes of misc.h 2026-06-19 19:24:57 +02:00
xinput Xi: Guard against NULL event pointer 2026-10-07 14:33:20 +02:00
xkeyboard xkb: Guard XkbAdjustGroup() against a keymap with no groups 2026-10-02 13:01:24 +02:00
xres treewide: clean up includes of misc.h 2026-06-19 19:24:57 +02:00
xselinux Xext: move xselinux into it's own subdir 2026-06-17 18:22:25 +02:00
xtest Xext: xtest: fix stack out-of-bounds write in ProcXTestFakeInput 2026-08-24 13:55:03 +02:00
xv Xext: xvideo: zero padding in ProcXvListImageFormats reply 2026-08-24 12:30:31 +02:00
hashtable.c treewide: clean up includes of misc.h 2026-06-19 19:24:57 +02:00
hashtable.h
meson.build Xext: move sleepuntil.c to dix 2026-06-19 09:37:22 +02:00
xace.c
xace.h treewide: don't include <region.h> anymore 2025-11-27 19:27:27 +01:00
xacestr.h