BUG/MEDIUM: quic: fix possible exit from qc_check_dcid() without unlocking
Locking of the CID tree was extended in qc_check_dcid() by recent commit
05f59a5 ("BUG/MINOR: quic: fix race condition in qc_check_dcid()") but
there was a direct return from the middle of the function which was not
covered by the unlock, resulting in the function keeping the lock on
success return.
Let's just remove this return and replace it with a variable to merge all
exit paths.
This must be backported wherever the fix above is backported.
(cherry picked from commit 192abc6f834dcd09f310299afe253b17f9985407)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 01e25a4cf2ce667745fb04c01153f3d9f56cc8ba)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 59bd950e0561aca21695afba0c30241aa2cbf14a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/quic_conn.c b/src/quic_conn.c
index 6e74683..5a5885e 100644
--- a/src/quic_conn.c
+++ b/src/quic_conn.c
@@ -8622,6 +8622,7 @@
struct quic_connection_id *conn_id;
struct ebmb_node *node = NULL;
struct quic_cid_tree *tree = &quic_cid_trees[idx];
+ int ret;
/* Test against our default CID or client ODCID. */
if ((qc->scid.len == dcid_len &&
@@ -8638,16 +8639,17 @@
*
* TODO set it to our default CID to avoid this operation next time.
*/
+ ret = 0;
HA_RWLOCK_RDLOCK(QC_CID_LOCK, &tree->lock);
node = ebmb_lookup(&tree->root, dcid, dcid_len);
if (node) {
conn_id = ebmb_entry(node, struct quic_connection_id, node);
if (qc == conn_id->qc)
- return 1;
+ ret = 1;
}
HA_RWLOCK_RDUNLOCK(QC_CID_LOCK, &tree->lock);
- return 0;
+ return ret;
}
/* Retrieve the DCID from a QUIC datagram or packet at <pos> position,