]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: quic: do not keep 0-RTT packets which cannot be decrypted
authorFrederic Lecaille <flecaille@haproxy.com>
Fri, 13 Nov 2026 16:31:10 +0000 (17:31 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Tue, 17 Nov 2026 08:35:15 +0000 (09:35 +0100)
On a listener with "allow-0rtt", a 0-RTT packet whose header protection
cannot be removed is queued in the 0-RTT encryption level pqpkts list and
its content is copied into the connection Rx buffer. That buffer is
reclaimed in order by quic_rx_pkts_del(), which stops at the first
referenced packet, so a queued 0-RTT packet pins all the data behind it.

Commit bba6baff3 ("BUG/MEDIUM: quic: prevent conn freeze on 0RTT
undeciphered content") addressed this by releasing these packets at
handshake completion, unconditionally. Commit b1af5dabf ("BUG/MEDIUM:
quic: avoid freezing 0RTT connections") then restricted that release to
the case where an address validation token was received: without a token,
the peer address is only validated by the handshake completion itself, so
the 0-RTT data are to be processed once the handshake is done.

That reasoning holds only if 0-RTT keys exist. When none were installed,
because the early data were rejected by the TLS stack or because the TLS
library does not support 0-RTT, the packets can never be decrypted, so
nothing releases them before the connection is freed. A 0-RTT packet
received after handshake completion is queued the same way, with even
less chance of ever being decrypted.

The Rx buffer then fills up and every packet of the connection is dropped
until the idle timeout, accounted as dropped_pkt_bufoverrun and shown as
dropbuff= in "show quic full". Since the buffer is reclaimed in order,
the whole connection stalls, not only the 0-RTT traffic.

Release the pending 0-RTT packets at handshake completion when there is
no 0-RTT RX secret, and drop 0-RTT packets received after handshake
completion without 0-RTT keys instead of queueing them.

This is a regression from b1af5dabf, so it must be backported to 2.9 and
above only.

src/quic_conn.c
src/quic_rx.c

index 12d6060637d0fcffb11dbe69ec2379a4a1724c78..1540d176e9b35cfb0c8df822958cc2be9ea11dd6 100644 (file)
@@ -881,8 +881,14 @@ struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state)
                 * packets are considered unneeded after handshake completion.
                 * They will be freed later from Rx buf via quic_rx_pkts_del().
                 */
+               /* Also release them when no 0-RTT RX secret exists: such
+                * packets can never be decrypted and would stay referenced
+                * forever, preventing the Rx buffer space from being reclaimed.
+                * This happens when the early data were rejected by the TLS
+                * stack, or when the TLS library does not support 0-RTT.
+                */
                if (qc->eel && !LIST_ISEMPTY(&qc->eel->rx.pqpkts) &&
-                   !(qc->flags & QUIC_FL_CONN_NO_TOKEN_RCVD)) {
+                   (!(qc->flags & QUIC_FL_CONN_NO_TOKEN_RCVD) || !quic_tls_has_rx_sec(qc->eel))) {
                        struct quic_rx_packet *pqpkt, *pkttmp;
                        list_for_each_entry_safe(pqpkt, pkttmp, &qc->eel->rx.pqpkts, list) {
                                LIST_DEL_INIT(&pqpkt->list);
index a6472a67140b015d27f0e6b03add6e5541a81ded..2cc920d8e1b67d19ce07d80dee972ac827bf214b 100644 (file)
@@ -1671,6 +1671,17 @@ static int qc_try_rm_hp(struct quic_conn *qc, struct quic_rx_packet *pkt,
 
                TRACE_PROTO("RX hp removed", QUIC_EV_CONN_TRMHP, qc, pkt);
        }
+       else if (qel == qc->eel && qc->state >= QUIC_HS_ST_COMPLETE &&
+                !quic_tls_has_rx_sec(qel)) {
+               /* Past handshake completion, a 0-RTT packet can no longer hope
+                * for 0-RTT keys to be installed: if none exist, it will never
+                * be decrypted. Queueing it would pin the Rx buffer, since
+                * quic_rx_pkts_del() stops at the first referenced packet.
+                * The packets already queued are released in quic_conn_io_cb().
+                */
+               TRACE_PROTO("RX 0RTT packet dropped (no 0RTT keys)", QUIC_EV_CONN_TRMHP, qc, pkt);
+               goto out;
+       }
        else {
                TRACE_PROTO("RX hp not removed", QUIC_EV_CONN_TRMHP, qc, pkt);
                LIST_APPEND(&qel->rx.pqpkts, &pkt->list);