]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: quic: fix uninitialized read of pkt->rs.delivered in ACK processing (BBR)
authorFrederic Lecaille <flecaille@haproxy.com>
Fri, 20 Nov 2026 16:30:57 +0000 (17:30 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Fri, 20 Nov 2026 16:43:48 +0000 (17:43 +0100)
In qc_notify_cc_of_newly_acked_pkts() the ->rs.delivered field of a TX
packet is unconditionally read for each newly acknowledged packet. But
->rs is filled in at TX time by quic_cc_drs_on_pkt_sent() (called from
drs_on_transmit() under QUIC_FL_TX_PACKET_ACK_ELICITING guard) for
ack-eliciting packets only. For a non ack-eliciting packet, e.g. a pure
ACK packet, which can be acknowledged by a peer, ->rs has never been
written and this read returns an indeterminate value.

This value is consumed by quic_cc_drs_on_ack_recv() and on_ack_rcvd()
which may corrupt the delivery rate sampling round counting
(drs->round_count, drs->next_round_delivered): a stale value from a
previously recycled packet freezes the round detection, a null one
spuriously increments round_count. Only BBR is affected: cubic neither
provides get_drs() nor on_ack_rcvd().

Fix this by reading ->rs.delivered for ack-eliciting packets only, as
already done for the call to quic_cc_drs_update_rate_sample() just
below, and for on_pkt_lost() in quic_loss.c. Also document in
quic_tx_packet_init() that ->rs is deliberately left uninitialized and
must never be read for a non ack-eliciting packet.

Thank you to @brhenc for having reported this bug in GH #3587.

This bug was introduced by 44af88d85 ("MINOR: quic: RX part
modifications to support BBR") with the delivery rate sampling support.
This must be backported up to v3.2.

src/quic_rx.c
src/quic_tx.c

index 6eaaf646ce7cabb4f23ee6c71ba928543b4b9e4e..83c3fec0f629364b13d85ab149cc23d10b7cc113 100644 (file)
@@ -482,7 +482,11 @@ static void qc_notify_cc_of_newly_acked_pkts(struct quic_conn *qc,
                if (pkt->largest_acked_pn != -1)
                        qc_treat_ack_of_ack(qc, &pkt->pktns->rx.arngs, pkt->largest_acked_pn);
                bytes_delivered += pkt->len;
-               pkt_delivered = pkt->rs.delivered;
+               /* Delivery rate sampling is applied to ack-eliciting
+                * packets only: never read it for the other ones.
+                */
+               if (pkt->flags & QUIC_FL_TX_PACKET_ACK_ELICITING)
+                       pkt_delivered = pkt->rs.delivered;
                ev.ack.acked = pkt->in_flight_len;
                ev.ack.time_sent = pkt->time_sent_ms;
                ev.ack.pn = pkt->pn_node.key;
index dc7d3438efc2c1d6fe7e76fb9da93367d8668688..b88e8632ea852b5b6f7820cfcd4f5d5f8aaca3ad 100644 (file)
@@ -2337,6 +2337,11 @@ static inline void quic_tx_packet_init(struct quic_tx_packet *pkt, int type)
        pkt->largest_acked_pn = -1;
        pkt->flags = 0;
        pkt->refcnt = 0;
+       /* Note that <pkt->rs> is deliberately left uninitialized here: it is
+        * filled in at TX time for ack-eliciting packets only by
+        * quic_cc_drs_on_pkt_sent() and must never be read for a
+        * non ack-eliciting packet.
+        */
 }
 
 /* Build a packet into a buffer at <pos> position, <end> pointing to one byte past