BUG/MINOR: quic: fix race-condition on trace for CID retrieval
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 27 Jun 2024 16:52:23 +0000 (18:52 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 3 Jul 2024 06:45:26 +0000 (08:45 +0200)
commit9e913167aee92d33272b3d1d25210447f50233b5
tree1941a330a93584e9f0e8855943f2ec9e195c5bd5
parent177bcf3b4c5b387157a78836379ae877ec96ffe9
BUG/MINOR: quic: fix race-condition on trace for CID retrieval

quic_rx_pkt_retrieve_conn() is used when parsing a received datagram
from the listener socket. It returned the quic_conn instance
corresponding to the first packet DCID, unless it is mapped to another
thread.

As expected, global CID tree access is protected by a lock in the
function. However, there is a race condition due to the final trace
where qc instance is dereferenced outside of the lock. Fix this by
adding a new trace under lock protection and remove qc deferencement at
function end.

This may fix first crash of github issue #2607.

This must be backported up to 2.8.

(cherry picked from commit bbb9f8248e29e89c288ad55a0fb7c71280a335a0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/quic_cid.c