Skip to content

Commit 9655b89

Browse files
committed
MINOR: quic: add 2 BUG_ON() on datagram dispatch
QUIC datagram dispatch is an error prone operation as it must always ensure the correct thread is used before accessing to the recipient quic_conn instance. Strengthen this code part by adding two BUG_ON_HOT() to ensure thread safety.
1 parent 85752cd commit 9655b89

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/quic_rx.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,9 @@ static struct quic_conn *quic_rx_pkt_retrieve_conn(struct quic_rx_packet *pkt,
15711571

15721572
qc = retrieve_qc_conn_from_cid(pkt, &dgram->saddr, new_tid);
15731573

1574+
/* quic_conn must be set to NULL if bind on another thread. */
1575+
BUG_ON_HOT(qc && *new_tid != -1);
1576+
15741577
/* If connection already created or rebinded on another thread. */
15751578
if (!qc && *new_tid != -1 && tid != *new_tid)
15761579
goto out;
@@ -2161,6 +2164,10 @@ int quic_dgram_parse(struct quic_dgram *dgram, struct quic_conn *from_qc,
21612164
dgram->qc = qc;
21622165
}
21632166

2167+
/* Ensure quic_conn access only occurs on its attached thread. */
2168+
BUG_ON_HOT(((struct quic_connection_id *)
2169+
eb64_entry(eb64_first(qc->cids), struct quic_connection_id, seq_num))->tid != tid);
2170+
21642171
/* Ensure thread connection migration is finalized ASAP. */
21652172
if (qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED)
21662173
qc_finalize_affinity_rebind(qc);

0 commit comments

Comments
 (0)