Skip to content

mux-h2: graceful_goaway clears zero.storage unconditionally, corrupting an in-flight header-block reassembly on every graceful shutdown #1398

Closed

Description

@FlorentinDUBOIS

Third instance of one bug class, and the only one that fires unconditionally.

ConnectionH2::zero is both the read-side accumulation buffer for a HEADERS+CONTINUATION field
block in progress — header_block_fragment is a (start, len) window into it that must stay valid
across however many readable() passes the block takes — and a write scratch space that several
code paths clear and reuse.

Two instances have been dealt with:

This one is the same shape and worse.

The defect

graceful_goaway (lib/src/protocol/mux/h2.rs:5011) clears self.zero.storage at h2.rs:5029 to
serialize the initial advisory GOAWAY — unconditionally, with no check for a header block in
progress.

Its own comment states the intent to keep reading in-flight streams during the drain window. That
intent is exactly what the clear breaks: a stream whose HEADERS has arrived and whose CONTINUATION
has not has its accumulated fragment destroyed.

Unlike #1397's trigger, nothing needs to coincide. Every graceful shutdown and every hot reload that
lands mid-reassembly corrupts that stream, every time.

Expected

A drain that advertises "in-flight requests are still accepted" must not destroy an in-flight
request's own header block. Either defer the GOAWAY serialization the way #1397 defers the
control-frame drains, or give the GOAWAY its own buffer.

What a fix needs

A red-then-green regression test in the shape of #1397's
a_legitimate_continuation_survives_an_unrelated_window_update_flush: send HEADERS without
END_HEADERS, trigger graceful_goaway, send the CONTINUATION, and assert the decoded field pair is
byte-for-byte what the peer encoded. Without the fix it must fail with a wrong pair, not a decode
error — that silence is the defining symptom of this class.

Worth checking in the same pass whether any other site clears zero.storage without consulting
header_block_reassembly_in_progress() (h2.rs:3887, added by #1397). Three instances found by
three separate investigations suggests the invariant wants enforcing centrally rather than
site by site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions