From: Willy Tarreau Date: Tue, 17 Nov 2026 17:27:58 +0000 (+0100) Subject: BUG/MAJOR: mux-h2: fail on impossible data transfers in rcv_buf() X-Git-Tag: v3.5-dev13~24 X-Git-Url: https://git.kaiwu.me/web//%22?a=commitdiff_plain;h=3db16867932cc06fb62de2fca724959ee36ecc2f;p=haproxy.git BUG/MAJOR: mux-h2: fail on impossible data transfers in rcv_buf() When some data couldn't be transferred from the rxbuf to the channel, leaving the channel empty (e.g. due to the reserve), we must not set SE_FL_WANT_ROOM otherwise we cannot get out of this situation. There's even already a BUG_ON() for this. However it turns out that in some tricky circumstances it can be triggered. The test is thus not correct and instead we should simply report a stream error. This needs to be backported as far as 2.6. Many thanks to Adam Crawford for reporting this issue along with a repro and a candidate fix. In the end the current fix is different as it addresses the root cause (WANT_ROOM + no-data) so it should be more future-proof. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 2e18eea3f..3f9e33bc4 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -8339,8 +8339,16 @@ static size_t h2_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, in /* tell the stream layer whether there are data left or not */ if (h2s_rxbuf_cnt(h2s)) { + if (!buf->data) { + /* we have pending data and the output buf is empty, + * this is typical of too large a non-fragmentable + * data (e.g headers, trailers) combined with a + * reserve, so this will never unblock. + */ + se_fl_set(h2s->sd, SE_FL_ERROR); + goto leave; + } se_fl_set(h2s->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM); - BUG_ON_HOT(!buf->data); } else { if (!(h2c->flags & H2_CF_IS_BACK) && (h2s->flags & (H2_SF_BODY_TUNNEL|H2_SF_ES_RCVD))) { @@ -8364,6 +8372,7 @@ static size_t h2_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, in BUG_ON_HOT(!buf->data && se_fl_test(h2s->sd, SE_FL_WANT_ROOM)); + leave: TRACE_LEAVE(H2_EV_STRM_RECV, h2c->conn, h2s); return ret; }