BUG/MINOR: quic: Possible endless loop in quic_lstnr_dghdlr()
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 16 Jun 2023 14:10:58 +0000 (16:10 +0200)
committerFrédéric Lécaille <flecaille@haproxy.com>
Fri, 16 Jun 2023 14:10:58 +0000 (16:10 +0200)
commit4ae29be18c5b212dd2a1a8e9fa0ee2fcb9dbb4b3
tree78d6b8eba63f8c4e5a215c63aac5aa610f6bfc90
parentc02d898cd13d036e1897daae5e2362ec8705e427
BUG/MINOR: quic: Possible endless loop in quic_lstnr_dghdlr()

This may happen when the initilization of a new QUIC conn fails with qc_new_conn()
when receiving an Initial paquet. This is done after having allocated a CID with
new_quic_cid() called by quic_rx_pkt_retrieve_conn() which stays in the listener
connections tree without a QUIC connection attached to. Then when the listener
receives another Initial packet for the same CID, quic_rx_pkt_retrieve_conn()
returns NULL again (no QUIC connection) but with an thread ID already bound to the
connection, leading the datagram to be requeued in the same datagram handler thread
queue. And so on.

To fix this, the connection is created after having created the connection ID.
If this fails, the connection is deallocated.

During the race condition, when two different threads handle two datagrams for
the same connection, in addition to releasing the newer created connection ID,
the newer QUIC connection must also be released.

Must be backported as far as 2.7.
src/quic_conn.c