]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: quic: Prevent deadlock with CID tree lock
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 26 Jun 2023 08:39:56 +0000 (10:39 +0200)
committerFrédéric Lécaille <flecaille@haproxy.com>
Mon, 26 Jun 2023 12:09:58 +0000 (14:09 +0200)
commit1231810963fd00e463ca46af1130c46ede312a52
tree70faa97380cca82b1e5129e072a730637a1de5bb
parent117b03ff4af5a93bf4ed68fa1b71bd35333866b8
BUG/MINOR: quic: Prevent deadlock with CID tree lock

This bug was introduced by this commit which was not sufficient:
      BUG/MINOR: quic: Possible endless loop in quic_lstnr_dghdlr()

It was revealed by the blackhole interop runner test with neqo as client.

qc_conn_release() could be called after having locke the CID tree when two different
threads was creating the same connection at the same time. Indeed in this case
the last thread which tried to create a new connection for the same an already existing
CID could not manage to insert an already inserted CID in the connection CID tree.
This was expected. It had to destroy the newly created for nothing connection calling
qc_conn_release(). But this function also locks this tree calling free_quic_conn_cids() leading to a deadlock.
A solution would have been to delete the new CID created from its tree before
calling qc_conn_release().

A better solution is to stop inserting the first CID from qc_new_conn(), and to
insert it into the CID tree only if there was not an already created connection.
This is whas is implemented by this patch.

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