Skip to content

Commit 01e25a4

Browse files
wtarreaucapflam
authored andcommitted
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 192abc6) Signed-off-by: Christopher Faulet <[email protected]>
1 parent 9e91316 commit 01e25a4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/quic_conn.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,7 @@ int qc_check_dcid(struct quic_conn *qc, unsigned char *dcid, size_t dcid_len)
16521652
struct quic_connection_id *conn_id;
16531653
struct ebmb_node *node = NULL;
16541654
struct quic_cid_tree *tree = &quic_cid_trees[idx];
1655+
int ret;
16551656

16561657
/* Test against our default CID or client ODCID. */
16571658
if ((qc->scid.len == dcid_len &&
@@ -1668,16 +1669,17 @@ int qc_check_dcid(struct quic_conn *qc, unsigned char *dcid, size_t dcid_len)
16681669
*
16691670
* TODO set it to our default CID to avoid this operation next time.
16701671
*/
1672+
ret = 0;
16711673
HA_RWLOCK_RDLOCK(QC_CID_LOCK, &tree->lock);
16721674
node = ebmb_lookup(&tree->root, dcid, dcid_len);
16731675
if (node) {
16741676
conn_id = ebmb_entry(node, struct quic_connection_id, node);
16751677
if (qc == conn_id->qc)
1676-
return 1;
1678+
ret = 1;
16771679
}
16781680
HA_RWLOCK_RDUNLOCK(QC_CID_LOCK, &tree->lock);
16791681

1680-
return 0;
1682+
return ret;
16811683
}
16821684

16831685
/* Wake-up upper layer for sending if all conditions are met :

0 commit comments

Comments
 (0)