Fix use-after-free and double-free in RemoveFilament (3.24.x) - #6369
Merged
Merged
Conversation
RemoveFilament() frees `filament` (and destroys filament->items) when StringSetSize(filament->items) == 0, but had no `return` after that branch -- every other early-exit branch in this function does. Execution fell through unconditionally to `OpenDB(&db, filament->db_id)`, a use-after-free read of the just-freed filament, and at the end of the function `StringSetDestroy(filament->items)` / `free(filament)` ran again unconditionally -- a double-free of both filament and its items set on that path. Verified with a standalone AddressSanitizer repro (RemoveFilament's body extracted verbatim, stub types matching the real DBFilament/StringSet shapes): unfixed, ASan reports a real heap-use-after-free at the OpenDB(&db, filament->db_id) line; with this one-line `return;` added (matching every other early-exit branch's own pattern in this file), clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit aecc166)
larsewi
force-pushed
the
use-after-free-3.24.x
branch
from
September 24, 2026 10:11
a744617 to
2bc016d
Compare
Contributor
Author
|
@cf-bottom Jenkins please :) |
|
Sure, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/14697/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-14697/ |
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.
Backported from #6358