]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: mux_quic: fix ALPN retrieval from server
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 27 Oct 2026 14:11:34 +0000 (15:11 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 28 Oct 2026 10:06:00 +0000 (11:06 +0100)
On backend side, ALPN may be retrieved from the server when 0-RTT is
used. This requires the server lock to protect concurrent modification
of the server access.

This code was badly written as server ALPN was still accessed outside of
the lock. Fix this by copying the server ALPN in a local string before
releasing the lock.

This also fixes the detection of an empty server ALPN to avoid an
unnecessary call to quic_alpn_to_app_ops().

This must be backported up to 3.4.

src/mux_quic.c

index a0bc0a11031556421188b6e9ec9df3eb32c457fa..94c4ea8909efd9387f0933a81a0999e53ef52ab9 100644 (file)
 #include <haproxy/quic_tx.h>
 #include <haproxy/quic_utils.h>
 #include <haproxy/session.h>
+#include <haproxy/server-t.h>
 #include <haproxy/ssl_sock-t.h>
 #include <haproxy/stconn.h>
 #include <haproxy/time.h>
+#include <haproxy/tools.h>
 #include <haproxy/trace.h>
 #include <haproxy/xprt_qmux.h>
 #include <haproxy/xref.h>
@@ -1908,7 +1910,8 @@ int qcc_install_app_ops(struct qcc *qcc)
        struct connection *conn = qcc->conn;
        const struct qcc_app_ops *app_ops;
        struct server *srv;
-       const char *alpn;
+       char srv_alpn[MAX_ALPN_SIZE];
+       const char *alpn = NULL;
        int alpn_len;
 
        TRACE_ENTER(QMUX_EV_QCC_NEW, conn);
@@ -1919,12 +1922,13 @@ int qcc_install_app_ops(struct qcc *qcc)
 
                srv = __objt_server(conn->target);
                HA_RWLOCK_RDLOCK(SERVER_LOCK, &srv->path_params.param_lock);
-               alpn = srv->path_params.nego_alpn;
+               strlcpy2(srv_alpn, srv->path_params.nego_alpn, MAX_ALPN_SIZE);
                HA_RWLOCK_RDUNLOCK(SERVER_LOCK, &srv->path_params.param_lock);
 
-               if (!alpn)
+               if (!*srv_alpn)
                        goto err;
-               alpn_len = strlen(srv->path_params.nego_alpn);
+               alpn = srv_alpn;
+               alpn_len = strlen(srv_alpn);
        }
 
        app_ops = quic_alpn_to_app_ops(alpn, alpn_len);