mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-18 01:14:38 +00:00
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.
This commit is contained in:
parent
6d943b8db6
commit
192abc6f83
@ -1652,6 +1652,7 @@ int qc_check_dcid(struct quic_conn *qc, unsigned char *dcid, size_t dcid_len)
|
||||
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 &&
|
||||
@ -1668,16 +1669,17 @@ int qc_check_dcid(struct quic_conn *qc, unsigned char *dcid, size_t dcid_len)
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
|
||||
/* Wake-up upper layer for sending if all conditions are met :
|
||||
|
Loading…
Reference in New Issue
Block a user