From: Andrea Cocito Date: Fri, 27 Nov 2026 15:19:57 +0000 (+0100) Subject: BUG/MEDIUM: mux-h1: defer read0 while input is buffered X-Git-Url: https://git.kaiwu.me/web/%22../static/gitweb.js?a=commitdiff_plain;h=c065792c0f27880896aeb5a6d8211a174f3cd54c;p=haproxy.git BUG/MEDIUM: mux-h1: defer read0 while input is buffered On kqueue, backend EOF may be reported while the H1 mux still has response body bytes in h1c->ibuf. With a flow-controlled H2 or H3 consumer, h1_fastfwd() can forward only part of those bytes, then observe read0 while h1m->curr_len is still nonzero. It reports a truncated response and aborts the client stream even though the remaining bytes are already in memory. In the affected FreeBSD/H3 workload, 16 KiB responses reached the client as 16,066 bytes and curl reported a partial transfer. Classify read0 in this fast-forward path only after h1c->ibuf is empty. Keep fast forwarding active so a later consumer window update can drain the buffer. The existing EOS/EOI and genuine-truncation decisions then run with the correct remaining message length. A VTest reproducer holds the H2 window closed until the backend closes, then opens it in steps to force read0 with buffered H1 input. It fails on unpatched macOS and FreeBSD kqueue builds and passes with the fix. The same fix passes on the affected 3.4.7 source and current 3.4.9 maintenance source. A genuinely short Content-Length response still forwards exactly the sent bytes and resets the H2 stream. This patch should fix the issue #3612. It must be backported as far as 3.0. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index 136b850a0..582872e37 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -5635,7 +5635,8 @@ static int h1_fastfwd(struct stconn *sc, unsigned int count, unsigned int flags) } } - if (conn_xprt_read0_pending(h1c->conn)) { + /* Buffered input must be forwarded before judging the message at EOF. */ + if (!b_data(&h1c->ibuf) && conn_xprt_read0_pending(h1c->conn)) { se_fl_set(h1s->sd, SE_FL_EOS); TRACE_STATE("report EOS to SE", H1_EV_STRM_RECV, h1c->conn, h1s); if (h1m->state >= H1_MSG_DONE || !(h1m->flags & H1_MF_XFER_LEN)) {