From: Olivier Houchard Date: Thu, 3 Dec 2026 10:03:37 +0000 (+0100) Subject: BUG/MINOR: quic: do not use the FD of another thread group's listener X-Git-Url: https://git.kaiwu.me/web/%7Bsubstring-before(@doc,%20'.xml')%7D.html?a=commitdiff_plain;h=c2321db5f926d94b04453a3e1001b468fa749b8f;p=haproxy.git BUG/MINOR: quic: do not use the FD of another thread group's listener With per-thread-group FD tables, quic_dgram_parse() looks for a listener of the same bind line in the current thread group, since commit 62d6ed440 ("MEDIUM: quic: Do not use another thread group's listener FD"). But the CID tree is shared by all bind lines, so a datagram for a connection may be received on a bind line which has no listener in the group of the connection's thread, and the listener of the other group was then kept. If no connection ended up being used, its FD, which means nothing in the current group, was used to send a Version Negotiation, Retry or Stateless Reset packet, and a new connection could be attached to that listener. Drop the packet in these cases only, ie when the version is not supported or when no connection is found. Packets for an existing connection do not need the listener and are still processed. This can be tested with "tune.fd.tables per-thread-group" and two QUIC bind lines on different thread groups, by sending to the second one the datagrams of a connection established on the first one. This was reported by deanliang06 , who proposed a first fix dropping all such datagrams: https://www.mail-archive.com/haproxy@formilux.org/msg47862.html This should be backported to 3.5. --- diff --git a/src/quic_rx.c b/src/quic_rx.c index 42ab47b74..ba4734e87 100644 --- a/src/quic_rx.c +++ b/src/quic_rx.c @@ -1850,6 +1850,13 @@ static inline int quic_token_validate(struct quic_rx_packet *pkt, goto leave; } +/* Returns non-zero if 's FD cannot be used from the current thread group. */ +static inline int quic_lstnr_is_foreign(const struct listener *l) +{ + return (global.tune.options & GTUNE_NO_TG_FD_SHARING) && + l->rx.bind_tgroup != tgid; +} + /* Listener only function. * * Find the associated connection to the packet or create a new one if @@ -1888,6 +1895,12 @@ static struct quic_conn *quic_rx_pkt_retrieve_conn(struct quic_rx_packet *pkt, if (!qc && *new_tid != -1 && tid != *new_tid) goto out; + if (!qc && quic_lstnr_is_foreign(l)) { + TRACE_PROTO("no connection and listener from another thread group, packet dropped", + QUIC_EV_CONN_LPKT, NULL, NULL, NULL, pkt->version); + goto err; + } + if (pkt->type == QUIC_PACKET_TYPE_INITIAL) { BUG_ON(!pkt->version); /* This must not happen. */ @@ -2127,6 +2140,11 @@ static int quic_rx_pkt_parse(struct quic_conn *qc, struct quic_rx_packet *pkt, * sent only by servers. */ if (l && !pkt->version) { + if (quic_lstnr_is_foreign(l)) { + TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT); + goto drop; + } + /* unsupported version, send Negotiation packet */ if (send_version_negotiation(l, (struct sockaddr_storage *)&dgram->daddr, (struct sockaddr_storage *)&dgram->saddr, pkt)) {