]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: quic-be: keep the source port range of a closing backend connection
authorFrederic Lecaille <flecaille@haproxy.com>
Fri, 13 Nov 2026 17:26:44 +0000 (18:26 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Tue, 17 Nov 2026 08:35:15 +0000 (09:35 +0100)
When a backend QUIC connection enters the closing state, qc_new_cc_conn()
moves its socket to a new quic_conn_closed instance. Since commit 02b768501
("MEDIUM: fd: Remove fdinfo"), the source port range used to bind that
socket is stored in qc->sport_range, but this member was not copied to the
closing connection, and the quic_conn_closed pool is not zeroed.

qc_release_fd() later installs qc->sport_range as the fd owner with
FD_OWNER_PR, so that fd_delete() gives the port back to its range. With an
uninitialized pointer, port_range_release_port() dereferences a wild address
and the process dies on a general protection fault; when the field happens
to be zero, the port is never released, so the range is exhausted after as
many connections and every new backend connection fails with
CO_ER_PORT_RANGE.

Copy the source port range to the closing connection, as is already done for
the other members it needs. It is always NULL on the frontend side.

This bug was introduced by commit 02b768501, so it only affects 3.5-dev4 and
later. No backport is needed.

src/quic_conn.c

index 1540d176e9b35cfb0c8df822958cc2be9ea11dd6..8b5d75ee9b8e27687095507de6a9d2b0153066f4 100644 (file)
@@ -725,6 +725,11 @@ static struct quic_conn_closed *qc_new_cc_conn(struct quic_conn *qc)
 
        quic_conn_mv_cids_to_cc_conn(cc_qc, qc);
 
+       /* The source port range is needed to release the port of a backend
+        * socket with qc_release_fd(). It is always NULL on frontend side.
+        */
+       cc_qc->sport_range = qc->sport_range;
+
        if (qc_is_back(qc)) {
                cc_qc->fd = qc->fd;
                fdtab[cc_qc->fd].iocb = quic_conn_closed_sock_fd_iocb;