From: Frederic Lecaille Date: Fri, 20 Nov 2026 16:30:57 +0000 (+0100) Subject: BUG/MINOR: quic: fix uninitialized read of pkt->rs.delivered in ACK processing (BBR) X-Git-Url: https://git.kaiwu.me/http/%7B@url%7D?a=commitdiff_plain;h=383e07a8787ab9f838158daf74c0d75961bb133e;p=haproxy.git BUG/MINOR: quic: fix uninitialized read of pkt->rs.delivered in ACK processing (BBR) 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. --- diff --git a/src/quic_rx.c b/src/quic_rx.c index 6eaaf646c..83c3fec0f 100644 --- a/src/quic_rx.c +++ b/src/quic_rx.c @@ -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; diff --git a/src/quic_tx.c b/src/quic_tx.c index dc7d3438e..b88e8632e 100644 --- a/src/quic_tx.c +++ b/src/quic_tx.c @@ -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 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 position, pointing to one byte past