]> dgit.raspbian.org Git - haproxy.git/commitdiff
[PATCH] BUG/MAJOR: mux-h2: properly handle short reads on PING frames
authorWilly Tarreau <w@1wt.eu>
Mon, 12 Oct 2026 12:38:34 +0000 (14:38 +0200)
committerVincent Bernat <bernat@debian.org>
Sat, 17 Oct 2026 17:17:39 +0000 (19:17 +0200)
Handling of partially received H2 frames was fixed in 2.5 with commit
b5f7b52968 ("BUG/MEDIUM: mux-h2: Handle remaining read0 cases on partial
frames"), however it turns out that the PING one was apparently missed.
However by then it was not a problem, but became one when commit 633c41c62
("MEDIUM: mux-h2: rework h2_restart_reading() to differentiate recv and
demux") was merged in 3.1 because now the mux's tasklet can properly wake
up as long as the job is not finished, which unfortunately doesn't play
well once combined with the fix above, because as long as the data are
not consumed, we continue to wake up, and we don't consume them until
the frame is complete, or the timeout http-request strikes.

Let's simply implement the check for the short read in h2c_handle_ping()
to avoid the spurious wakeup.

This needs to be backported to 3.2, maybe even 2.6 since the checks in
other functions didn't change since then.

As a workaround, setting "timeout http-request" to a low value such as
1-5s mitigates the CPU consumption.

(cherry picked from commit 7ddb55bc18744996782e9e2b50f16b9b985d766b)
Signed-off-by: Willy Tarreau <w@1wt.eu>
Gbp-Pq: Name 0001-BUG-MAJOR-mux-h2-properly-handle-short-reads-on-PING.patch

src/mux_h2.c

index 65edcaacd0cc632ef4fb47f8eb338290d8ddcad6..0a4345eb73c17331d2d7be4ed6d73570229ab080 100644 (file)
@@ -2514,6 +2514,12 @@ static int h2c_ack_settings(struct h2c *h2c)
  */
 static int h2c_handle_ping(struct h2c *h2c)
 {
+       /* process full frame only */
+       if (b_data(&h2c->dbuf) < h2c->dfl) {
+               h2c->flags |= H2_CF_DEM_SHORT_READ;
+               return 0;
+       }
+
        /* schedule a response */
        if (!(h2c->dff & H2_F_PING_ACK))
                h2c->st0 = H2_CS_FRAME_A;