healthchecks: reference count status file data - #13432
Merged
Merged
Conversation
bneradt
force-pushed
the
healthchecks-use-after-free
branch
from
July 27, 2026 16:33
79b3c22 to
5429a3b
Compare
moonchen
previously approved these changes
Jul 27, 2026
moonchen
left a comment
Contributor
There was a problem hiding this comment.
Thanks for fixing this.
bneradt
force-pushed
the
healthchecks-use-after-free
branch
from
July 29, 2026 18:56
5429a3b to
25460a7
Compare
Replaced file data was retired onto a freelist and freed after a timeout, but its deadline came from a timestamp taken before a blocking inotify read. That stale deadline let transactions retain references to data that was already freed. Files exactly 16 KiB long were also reported as empty because a final zero-byte read overwrote the saved length. This holds each immutable snapshot in an atomic shared_ptr. Every transaction pins its snapshot, so data lives exactly as long as it is referenced, without a freelist or request-path mutex. This also preserves the last successful file-read length and adds AuTest coverage for concurrent replacement and the 16 KiB boundary. Fixes: apache#8735 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
bneradt
force-pushed
the
healthchecks-use-after-free
branch
from
July 29, 2026 20:38
25460a7 to
6e41874
Compare
moonchen
approved these changes
Jul 31, 2026
cmcfarlen
pushed a commit
that referenced
this pull request
Aug 4, 2026
Replaced file data was retired onto a freelist and freed after a timeout, but its deadline came from a timestamp taken before a blocking inotify read. That stale deadline let transactions retain references to data that was already freed. Files exactly 16 KiB long were also reported as empty because a final zero-byte read overwrote the saved length. This holds each immutable snapshot in an atomic shared_ptr. Every transaction pins its snapshot, so data lives exactly as long as it is referenced, without a freelist or request-path mutex. This also preserves the last successful file-read length and adds AuTest coverage for concurrent replacement and the 16 KiB boundary. Fixes: #8735 (cherry picked from commit 16bd59a)
Contributor
|
Cherry-picked to the 10.2.x branch as f1b771c for the 10.2.0 release. |
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.
Replaced file data was retired onto a freelist and freed after a
timeout, but the deadline was computed from a timestamp taken before
the blocking inotify read. That timestamp is stale by however long the
watcher waited for an event, so the deadline was routinely already in
the past and the data was freed while transactions still referenced it.
The patch addresses this issue by holding the data in a shared_ptr and
letting each transaction pin its own snapshot. The data now lives
exactly as long as it is referenced, which removes both the freelist
and the guess about how long a transaction can last.
Fixes: #8735