Avoid stale H2 writes after 100 Continue - #13504
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the HTTP/2 stream write path against a use-after-free that can occur after an informational (e.g., 100 Continue) response completes and releases its write buffer, but the connection later delivers a write-ready event that re-enters stream write processing.
Changes:
- Add an early exit in
Http2Stream::update_write_request()when the write VIO is already complete (ntodo() <= 0), preventing examination of a potentially stale reader. - Simplify the reader-availability guard by relying on the early
ntodo()check and then checking availability unconditionally for pending writes.
bneradt
marked this pull request as draft
August 5, 2026 23:40
HttpSM owns the write buffer attached to an HTTP/2 stream. After WRITE_COMPLETE it may release the buffer while a connection-level write-ready event can restart the stream through the non-owning _send_reader alias. This leaves restart_sending vulnerable to a use-after-free. Clear _send_reader before delivering WRITE_COMPLETE to HttpSM, and check completed write VIOs before inspecting the reader during connection restarts. This preserves zero-byte completion processing, including END_STREAM.
bneradt
force-pushed
the
fix-h2-expect-continue-uaf
branch
from
August 6, 2026 00:33
66a68dc to
6ff78d3
Compare
bneradt
marked this pull request as ready for review
August 6, 2026 16:15
cmcfarlen
self-requested a review
August 6, 2026 21:17
cmcfarlen
approved these changes
Aug 7, 2026
cmcfarlen
pushed a commit
that referenced
this pull request
Aug 9, 2026
HttpSM owns the write buffer attached to an HTTP/2 stream. After WRITE_COMPLETE it may release the buffer while a connection-level write-ready event can restart the stream through the non-owning _send_reader alias. This leaves restart_sending vulnerable to a use-after-free. Clear _send_reader before delivering WRITE_COMPLETE to HttpSM, and check completed write VIOs before inspecting the reader during connection restarts. This preserves zero-byte completion processing, including END_STREAM. Co-authored-by: bneradt <bneradt@yahooinc.com> (cherry picked from commit c0351de)
Contributor
|
Cherry-picked to the 10.2.x branch as 7bf5d4b 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.
HttpSM owns the write buffer attached to an HTTP/2 stream. After WRITE_COMPLETE it may release the buffer while a connection-level write-ready event can restart the stream through the non-owning _send_reader alias. This leaves restart_sending vulnerable to a use-after-free.
Clear _send_reader before delivering WRITE_COMPLETE to HttpSM, and check completed write VIOs before inspecting the reader during connection restarts. This preserves zero-byte completion processing, including END_STREAM.
Testing: