]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Do not wakeup the I/O handler before the mux is started
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 12 Jan 2022 16:46:56 +0000 (17:46 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 12 Jan 2022 17:08:29 +0000 (18:08 +0100)
If we wakeup the I/O handler before the mux is started, it is possible
it has enough time to parse the ClientHello TLS message and update the
mux transport parameters, leading to a crash.
So, we initialize ->qcc quic_conn struct member at the very last time,
when the mux if fully initialized. The condition to wakeup the I/O handler
from lstnr_rcv_pkt() is: xprt context and mux both initialized.
Note that if the xprt context is initialized, it implies its tasklet is
initialized. So, we do not check anymore this latter condition.

src/mux_quic.c
src/xprt_quic.c

index 9326dc819a3a3bd0eca39c75af8e8bf525f69d2a..2156730cfd47db3932eacd8462626952d72cc77e 100644 (file)
@@ -395,7 +395,6 @@ static int qc_init(struct connection *conn, struct proxy *prx,
 
        qcc->conn = conn;
        conn->ctx = qcc;
-       conn->qc->qcc = qcc;
 
        qcc->app_ops = NULL;
 
@@ -441,6 +440,7 @@ static int qc_init(struct connection *conn, struct proxy *prx,
        qcc->wait_event.tasklet->process = qc_io_cb;
        qcc->wait_event.tasklet->context = qcc;
 
+       HA_ATOMIC_STORE(&conn->qc->qcc, qcc);
        /* init read cycle */
        tasklet_wakeup(qcc->wait_event.tasklet);
 
index 4d0f75246a524a5ece8e2f8819658ba57358395e..094bb64c914ca384ce5843662b99af7f788fd7df 100644 (file)
@@ -4456,7 +4456,7 @@ static ssize_t qc_lstnr_pkt_rcv(unsigned char *buf, const unsigned char *end,
         * initialized.
         */
        conn_ctx = HA_ATOMIC_LOAD(&qc->xprt_ctx);
-       if (conn_ctx && conn_ctx->wait_event.tasklet)
+       if (conn_ctx && HA_ATOMIC_LOAD(&qc->qcc))
                tasklet_wakeup(conn_ctx->wait_event.tasklet);
 
        TRACE_LEAVE(QUIC_EV_CONN_LPKT, qc ? qc : NULL, pkt);