]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: mux-quic: fix crash with double qcc_set_error() on QCS free quic-interop
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 27 Nov 2026 16:14:38 +0000 (17:14 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 Nov 2026 10:03:43 +0000 (11:03 +0100)
The following patch adjusts connection flow-control when a QCS is
released early with unconsumed data. While it is still incomplete in
some situations, it may prevent desync between client and server
flow-control levels.

  9d2af5174bc8b01e3c4b7b7604d75873ff4bc0e3
  BUG/MINOR: mux_quic: account data in conn fctl on early detach

However, this can cause a crash if qcs_destroy() has been called while
the connection is already flagged on error. Indeed, in case of frame
allocation failure in qcc_account_for_conn_fctl(), qcc_set_error() is
called a second time, which is forbidden and enforced by a BUG_ON()
statement.

Fix this by skipping the qcc_account_for_conn_fctl() call if the
connection is already on error. This is also the case if a failure
occurs during qcc_release_remote_stream() as it sometimes also perform
faillible frame allocation. Both fixes are valid as we do not care about
flow-control accounting anymore as the connection will be released soon.

This must be backported up to 2.8.

src/mux_quic.c

index ce7ba7d384fb28b0e69056638c08e559e99bced1..2c917992899d3f4c9d7216aa4668d22a1983db31 100644 (file)
@@ -2617,6 +2617,8 @@ int qcc_recv_stop_sending(struct qcc *qcc, uint64_t id, uint64_t err)
 
 /* Signal the closing of remote stream with id <id>. Flow-control for new
  * streams may be allocated for the peer if needed.
+ *
+ * Returns 0 on success or non zero in case of a fatal connection error.
  */
 static int qcc_release_remote_stream(struct qcc *qcc, uint64_t id)
 {
@@ -2716,6 +2718,7 @@ static void qcs_destroy(struct qcs *qcs)
        struct qcc *qcc = qcs->qcc;
        struct connection *conn = qcc->conn;
        const uint64_t id = qcs->id;
+       int ret = 0;
 
        TRACE_ENTER(QMUX_EV_QCS_END, conn, qcs);
 
@@ -2726,20 +2729,20 @@ static void qcs_destroy(struct qcs *qcs)
                BUG_ON(qcs->tx.fc.off_soft != qcs->tx.fc.off_real);
 
                if (quic_stream_is_remote(qcc, id))
-                       qcc_release_remote_stream(qcc, id);
-       }
+                       ret = qcc_release_remote_stream(qcc, id);
 
-       /* If some data are not yet consumed, account them in conn flow
-        * control. On frontend, this may happen when FE stream is released
-        * prior to request completion.
-        *
-        * TODO QCS should not be released if not closed remotely to guarantee
-        * the connection flow control consistency
-        */
-       if (!qcs_is_close_remote(qcs) && qcs->rx.offset_max > qcs->rx.offset) {
-               COUNT("QCS is released while not remotely closed. "
-                           "This may cause miscalculation in conn flow control.");
-               qcc_account_for_conn_fctl(qcc, qcs->rx.offset_max - qcs->rx.offset);
+               /* If some data are not yet consumed, account them in conn flow
+                * control. On frontend, this may happen when FE stream is
+                * released prior to request completion.
+                *
+                * TODO QCS should not be released if not closed remotely to
+                * guarantee the connection flow control consistency
+                */
+               if (!ret && !qcs_is_close_remote(qcs) && qcs->rx.offset_max > qcs->rx.offset) {
+                       COUNT("QCS is released while not remotely closed. "
+                                   "This may cause miscalculation in conn flow control.");
+                       qcc_account_for_conn_fctl(qcc, qcs->rx.offset_max - qcs->rx.offset);
+               }
        }
 
        qcs_free(qcs);