(release/25.0) render: fix glyph Picture/Pixmap leak on ProcRenderAddGlyphs bail path - #3620
Open
metux wants to merge 1 commit into
Open
(release/25.0) render: fix glyph Picture/Pixmap leak on ProcRenderAddGlyphs bail path#3620metux wants to merge 1 commit into
metux wants to merge 1 commit into
Conversation
Contributor
Author
metux
force-pushed
the
tmp-pr/release/25.0
branch
from
August 25, 2026 10:07
01b6792 to
d32081d
Compare
The bail: path freed a newly-realized (!found) glyph with a raw '--refcnt; free(glyph)' instead of FreeGlyph(), skipping FreeGlyphPicture()'s release of the glyph's per-screen Picture/Pixmap (created earlier in the same function via CreatePicture()/CreatePixmap(), attached via SetGlyphPicture()). Trigger: send X_RenderAddGlyphs with >= 2 glyphs where an earlier glyph is well-formed (gets fully realized) and a later one is malformed (e.g. declares more bitmap bytes than present, hitting the BadLength/goto bail above) -- the earlier glyph's Picture/Pixmap leaks every such request, repeatable unbounded-leak DoS. No OOM needed. Fix: call FreeGlyph() instead, for both found and !found glyphs -- it already does the right thing for each: a bare refcnt-- for a found glyph (matching the old behavior), and the full teardown (hash removal if present, FreeGlyphPicture(), free the struct) for a !found one. Safe to call on a glyph never added to the global hash yet (AddGlyph() only runs on the success path below): the hash lookup keys off this glyph's own sha1 and simply finds an empty slot to not remove. Found via a fleet-directed alloc-fail/UAF sweep of Xext/, not from a live crash report. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
metux
force-pushed
the
tmp-pr/release/25.0
branch
from
August 25, 2026 10:10
d32081d to
b63f872
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #3267 (master).
The bail: path freed a newly-realized (!found) glyph with a raw
'--refcnt; free(glyph)' instead of FreeGlyph(), skipping
FreeGlyphPicture()'s release of the glyph's per-screen Picture/Pixmap
(created earlier in the same function via CreatePicture()/CreatePixmap(),
attached via SetGlyphPicture()).
Trigger: send X_RenderAddGlyphs with >= 2 glyphs where an earlier glyph is
well-formed (gets fully realized) and a later one is malformed (e.g.
declares more bitmap bytes than present, hitting the BadLength/goto bail
above) -- the earlier glyph's Picture/Pixmap leaks every such request,
repeatable unbounded-leak DoS. No OOM needed.
Fix: call FreeGlyph() instead, for both found and !found glyphs -- it
already does the right thing for each: a bare refcnt-- for a found glyph
(matching the old behavior), and the full teardown (hash removal if
present, FreeGlyphPicture(), free the struct) for a !found one. Safe to
call on a glyph never added to the global hash yet (AddGlyph() only runs on
the success path below): the hash lookup keys off this glyph's own sha1 and
simply finds an empty slot to not remove.
Found via a fleet-directed alloc-fail/UAF sweep of Xext/, not from a live
crash report.
Signed-off-by: Enrico Weigelt, metux IT consult info@metux.net