qc_new_conn() stores the connection passed as argument in qc->conn before the
first failure points, while quic_conn_release(), called from its own error
path, BUG_ONs on a non-null ->conn. As the upper connection is still
allocated while qc_new_conn() runs, any failure after this point aborts the
whole process instead of returning an error. Only backend connections are
affected, as the frontend caller passes a NULL connection.
qc->conn cannot simply be removed from qc_new_conn(): it is dereferenced by
ssl_sock_srv_try_reuse_sess(), called from qc_alloc_ssl_sock_ctx() on the
backend side, to look up a reusable TLS session. The latter leaves
ctx->conn to NULL, unlike its non-QUIC counterpart ssl_sock_init(), which
forces ssl_sock_srv_try_reuse_sess() to fall back to qc->conn.
Pass the connection to qc_alloc_ssl_sock_ctx() so that ctx->conn is always
valid, and use it unconditionally in ssl_sock_srv_try_reuse_sess(). Then let
the caller register the connection, next to conn->handle.qc, once
qc_new_conn() has succeeded.
Commit
ca5511f02 fixed this by setting ->conn only once the quic_conn was
fully initialized. Commit
a83ed86b7, which reinstated the conn argument,
moved the assignment back into the initialization block and reintroduced
the bug.
Must be backported to 3.4.
int ssl_quic_initial_ctx(struct bind_conf *bind_conf);
SSL_CTX *ssl_quic_srv_new_ssl_ctx(void);
-int qc_alloc_ssl_sock_ctx(struct quic_conn *qc, void *target);
+int qc_alloc_ssl_sock_ctx(struct quic_conn *qc, void *target,
+ struct connection *conn);
int qc_ssl_provide_all_quic_data(struct quic_conn *qc, struct ssl_sock_ctx *ctx);
int qc_ssl_do_hanshake(struct quic_conn *qc, struct ssl_sock_ctx *ctx);
qc->idle_timer_task = NULL;
qc->xprt_ctx = NULL;
- qc->conn = conn;
+ /* Set by the caller once the quic_conn is fully initialized:
+ * quic_conn_release(), called from the error paths below, BUG_ONs on a
+ * non-null ->conn while the upper connection is still allocated.
+ */
+ qc->conn = NULL;
qc->qcc = NULL;
qc->strm_reject = NULL;
qc->path = NULL;
qc->wait_event.events = 0;
qc->subs = NULL;
- if (qc_alloc_ssl_sock_ctx(qc, target) ||
+ if (qc_alloc_ssl_sock_ctx(qc, target, conn) ||
!quic_conn_init_timer(qc) ||
!quic_conn_init_idle_timer_task(qc, prx))
goto err;
*
* Returns 0 on success else non-zero.
*/
-int qc_alloc_ssl_sock_ctx(struct quic_conn *qc, void *target)
+int qc_alloc_ssl_sock_ctx(struct quic_conn *qc, void *target,
+ struct connection *conn)
{
struct ssl_sock_ctx *ctx = NULL;
struct bind_conf *bc;
goto err;
}
- ctx->conn = NULL;
+ /* ssl_sock_srv_try_reuse_sess(), called from this function on the
+ * backend side, dereferences ->conn to look up a reusable TLS session.
+ *
+ * It is NULL for frontend connections, which never reuse a session.
+ * Note that this field is not read anywhere else for QUIC: this
+ * function neither enables KTLS nor installs ssl_sock_io_cb(), so the
+ * generic ssl_sock handlers, which rely on it, are never used here.
+ */
+ ctx->conn = conn;
ctx->bio = NULL;
ctx->xprt = NULL;
ctx->xprt_ctx = NULL;
*/
void ssl_sock_srv_try_reuse_sess(struct ssl_sock_ctx *ctx, struct server *srv)
{
-#ifdef USE_QUIC
- struct quic_conn *qc = ctx->qc;
- struct connection *conn = qc ? qc->conn : ctx->conn;
-#else
struct connection *conn = ctx->conn;
-#endif
/* Do nothing for check connections */
if (conn->flags & CO_FL_SSL_NO_CACHED_INFO)
conn->flags |= CO_FL_SSL_WAIT_HS | CO_FL_WAIT_L6_CONN | CO_FL_FDLESS;
conn->handle.qc = qc;
+ qc->conn = conn;
}
ret = 0;