Skip to content

fix(quic,uring,congestion): wire bounds, CONNECT leftovers, and zero-RTT guards - #9353

Merged
kixelated merged 9 commits into
mainfrom
quest/m1/precut-audit/quic-uring-congestion-fixes
Nov 22, 2026
Merged

kixelated merged 9 commits into
mainfrom
quest/m1/precut-audit/quic-uring-congestion-fixes

Conversation

@kixelated

@kixelated kixelated commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m1/precut-audit/quic-uring-congestion-fixes.md and deletes it.

Summary

  • moq-quic MAX_STREAM_DATA: the announced limit is capped at VarInt::MAX. Before, raising stream_receive_window to the varint max on a live connection (Connection::set_limits, the relay-widening path Limits documents) panicked in write_var on the next MAX_STREAM_DATA. The "reader is short" check uses the same cap, so a capped limit is not resent forever.
  • moq-quic MAX_STREAMS: max_remote never grows past MAX_STREAM_COUNT (2^60). Before, with max_streams = 2^60 (which Limits::validate accepts), each freed stream pushed it past 2^60, and a peer that got that value in a MAX_STREAMS (after a loss, say) closed the connection with FRAME_ENCODING_ERROR.
  • moq-quic datagrams: Datagrams::max_size() returns None when datagram.receive_buffer is None, as its doc already said. send already refused in that case, so its separate check is gone.
  • moq-uring WebTransport: bytes that arrive in the same read as the CONNECT HEADERS frame (such as a pipelined close capsule) go to the capsule reader. Before, they were dropped, so a pipelined close was lost or the capsule framing desynced.
  • moq-congestion pacer: the window-path delay is at least 1 ns. With a microsecond RTT and a large window, the delay truncated to zero and re-armed the timer at now, which stalls on a simulated clock.
  • moq-congestion cubic: a zero smoothed RTT skips the TCP-friendly estimate. Before, t / 0 made it infinite, so one ACK banked about 2^64 bytes of cwnd_inc and the window then grew by an MSS on every ACK.

Impact

  • Public API: none.
  • Behavior: moq_quic Datagrams::max_size() returns None when datagrams are disabled locally, as documented.
  • Wire: MAX_STREAM_DATA and MAX_STREAMS values now stay within RFC 9000 bounds. No format change.

Choices for review

Taken without the maintainer (user away). A later review can undo any of them:

  1. Dropped the quest's qmux Assembler item (plan step 2). The review showed that .max(limit as usize) is the real bound: qmux::transport::Stream::poll_fill reuses a buffer grown for a large record (try_reclaim) to back later small ones, so a small slice can pin max_record_size. The quest's overflow premise doesn't hold on 64-bit, because every over-threshold insert defragments, which resets allocated to buffered. The cost it named (a copy per record) only applies under a non-default max_record_size, and nothing in-tree raises it. mux/mod.rs is unchanged from main, and no saturating arithmetic was added.
  2. MAX_STREAMS is capped where max_remote grows, not only when the frame is encoded. This keeps the local stream-limit check, retransmits, and queue_max_stream_id agreeing on one value.
  3. Zero RTT in cubic drops the TCP-friendly region instead of putting a floor under the RTT. Any floor small enough to be harmless still makes w_est effectively infinite.
  4. Pacer clamps to 1 ns instead of rounding the window-path division up. It's the smallest change that ends the re-arm, and the rate path already rounds its own shortfall up.
  5. moq-uring Request carries the leftover bytes (rest) into read_capsules. The decode step is now a pure take_connect, which is how it gets unit-tested.

Validation

  • Reproduced each bug before fixing it, with a test that failed on the unfixed code and passes with the fix:
    • max_stream_data_stays_a_varint: panicked VarIntBoundsExceeded at coding.rs:128.
    • max_streams_stays_under_the_stream_count_cap
    • datagram_disabled_locally
    • a_capsule_pipelined_with_the_connect_closes_the_session: a real io_uring server with a raw QUIC client writing CONNECT and a DATA-framed close capsule in one write. Unfixed, it timed out waiting for the close.
    • sub_nanosecond_window_refill_still_waits
    • zero_rtt_banks_no_window_credit: banked 18446744073709526415 bytes.
  • Second, independent end-to-end check (ad hoc, not committed): a client/server Pair read data, then the server called set_limits with max_streams = 2^60 and both windows at VarInt::MAX. On main's recv.rs it panicked at coding.rs:128. With the fix it sent MAX_STREAM_DATA and stayed up.
  • Second pacer check (ad hoc): drove an always-backlogged sender through the window path for 100 ns of simulated time (1 µs RTT, u32::MAX window). The fix sent 38.4 MB. Without the 1 ns clamp it stalled at one instant after 384 KB.
  • just check passes on the head: 7588 tests, plus clippy, fmt, and the other checks.

Caused by

  • moq-dev/moq#3081: read_connect dropped its buffer past the CONNECT HEADERS (found by reviewer).
  • The MAX_STREAM_DATA sum (kept by moq-dev/moq#8794), MAX_STREAMS growth, max_size's missing local check, the pacer's truncating delay, and cubic's unguarded w_est all date from the quinn-derived code, not a single PR here.

Follow-ups

  • quest/m1/precut-audit/qmux-websocket-read-buffer.md (S): pre-existing, found while answering the review. tungstenite slices each WebSocket message zero-copy out of its 128 KiB default read buffer, but the session counts 16 KiB, so a hostile peer pins about 8x what flow control and defragmentation bound. It takes the read-buffer stopgap that quest/m9/stream-transports/codec.md planned for CPU, and that quest now points to it. No open decisions; the Plan recommends the fix and the bench to run first.

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm B)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: b443b37

  • Base: origin/main at f2965d8

  • Risk: medium, These fixes change congestion pacing, QUIC flow-control limits and datagram reporting, and WebTransport capsule handling, so regressions could disrupt transport users, but preserve public APIs and wire formats and are fully undone by a revert.

  • Classified: medium by Codex, gpt-6.1-sol, low effort, session 01a20208-83c1-7700-8b94-d10fa3a013e3

  • Reviewer: Codex, gpt-6.1-sol, high effort

  • Session: 01a201fc-52d9-77d1-ac1a-8a47c58f590c, round 2

  • Score: 10/10, The accounting regression is fixed, and the changes since the previous review introduce no new findings.

  • Rounds: 2; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0

  • Findings: none

  • The last round's findings, at f64fe81:

    • Fixed: medium, rs/moq-quic/src/connection/mux/mod.rs:672: Account for the backing allocation rather than record length; At the head, rs/moq-quic/src/connection/mux/mod.rs:676 restores size.max(MAX_FRAME_SIZE).max(limit as usize), matching the merge base and charging small slices for the potentially retained large buffer.

@kixelated kixelated changed the title Fix moq-quic varint/assembler/datagram bounds, moq-uring CONNECT leftovers, and congestion guards fix(quic,uring,congestion): wire bounds, CONNECT leftovers, and zero-RTT guards Nov 22, 2026
…the WebSocket read-buffer gap

Review showed the stream transport reuses a buffer grown for a large record
for later small ones, so max_record_size is the real bound on what a slice pins.
@kixelated
kixelated marked this pull request as ready for review November 22, 2026 06:55
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2231248f-6542-4d7a-9b51-de5db5eb9eab
Commits

Reviewing files that changed from the base of the PR and between f1b6e06 and b443b37.

Files selected for processing: 11

  • quest/m1/precut-audit/qmux-websocket-read-buffer.md
  • quest/m1/precut-audit/quic-uring-congestion-fixes.md
  • quest/m9/stream-transports/codec.md
  • rs/moq-congestion/src/cubic.rs
  • rs/moq-congestion/src/pacer.rs
  • rs/moq-quic/src/connection/datagrams.rs
  • rs/moq-quic/src/connection/streams/recv.rs
  • rs/moq-quic/src/connection/streams/state.rs
  • rs/moq-quic/src/tests/mod.rs
  • rs/moq-uring/src/quic/web.rs
  • rs/moq-uring/tests/integration/web.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@kixelated
kixelated enabled auto-merge November 22, 2026 06:55

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound. Each fix sits where the bad value is first produced: the MAX_STREAMS cap goes where max_remote grows, the varint cap where MAX_STREAM_DATA is computed, and the leftover bytes are kept at the one place the CONNECT is parsed. None of them adds a guard at the encoder.

Reviewed changes. I reviewed all 11 files at b443b37, including the accounting and callers around each fix.

  • MAX_STREAM_DATA varint cap. limit() caps both the announced value and the short check at VarInt::MAX. Once VarInt::MAX has been sent, neither diff nor short asks for a resend.
  • MAX_STREAMS 2^60 cap. Capping new_count keeps max_remote - allocated_remote_count equal to the number of closed streams. So remote_open_streams stays correct, and queue_max_stream_id stops queuing once the cap is reached.
  • Datagrams::max_size local check. It now matches the qmux Datagrams::max_size, which already returned None when datagrams are disabled locally. The extra check in send was redundant and is gone.
  • moq-uring CONNECT leftovers. take_connect splits off the headers, and Request.rest carries the remaining bytes into Capsules.frames. moq-tokio doesn't have this bug: it parses through web_transport_proto::ConnectRequest::read, which reads exactly the HEADERS frame via stream.take(size).
  • Pacer 1 ns floor. This closes the window-path re-arm at now, the same way the rate path already rounds its delay up.
  • Cubic zero RTT. With a zero RTT, w_est is skipped and only the cubic curve applies, so a single ACK can no longer bank about 2^64 bytes of cwnd_inc.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 773a9a2 Nov 22, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m1/precut-audit/quic-uring-congestion-fixes branch November 22, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant