Skip to content

Commit 177bcf3

Browse files
a-denoyellecapflam
authored andcommitted
BUG/MINOR: quic: fix race condition in qc_check_dcid()
qc_check_dcid() is a function which check that a DCID is associated to the expected quic_conn instance. This is used for quic_conn socket receive handler as there is a tiny risk that a datagram to another connection was received on this socket. As other operations on global CID tree, a lock must be used to protect against race condition. However, as previous commit, lock was not held long enough as CID tree node is accessed outside of the lock region. To fix this, increase critical section until CID dereferencement is done. The impact of this bug should be similar to the previous one. However, risk of crash are even less reduced as it should be extremely rare to receive datagram for other connections on a quic_conn socket. As such, most of the time first check condition of qc_check_dcid() is enough. This may fix first crash of issue github #2607. This must be backported up to 2.8. (cherry picked from commit 05f59a5) Signed-off-by: Christopher Faulet <[email protected]>
1 parent ab76fa5 commit 177bcf3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/quic_conn.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,13 +1670,12 @@ int qc_check_dcid(struct quic_conn *qc, unsigned char *dcid, size_t dcid_len)
16701670
*/
16711671
HA_RWLOCK_RDLOCK(QC_CID_LOCK, &tree->lock);
16721672
node = ebmb_lookup(&tree->root, dcid, dcid_len);
1673-
HA_RWLOCK_RDUNLOCK(QC_CID_LOCK, &tree->lock);
1674-
16751673
if (node) {
16761674
conn_id = ebmb_entry(node, struct quic_connection_id, node);
16771675
if (qc == conn_id->qc)
16781676
return 1;
16791677
}
1678+
HA_RWLOCK_RDUNLOCK(QC_CID_LOCK, &tree->lock);
16801679

16811680
return 0;
16821681
}

0 commit comments

Comments
 (0)