From b737f9500980f13075668b8ea9607f47a02b8e08 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Thu, 4 May 2023 15:36:17 +0200 Subject: [PATCH] BUG/MINOR: mux-quic: prevent quic_conn error code to be overwritten When MUX performs a graceful shutdown, quic_conn error code is set to a "no error" code which depends on the application layer used. However, this may overwrite a previous error code if quic_conn layer has detected an error on its side. In practice, this behavior has not been seen on production. In fact, it may have undesirable effect only if this error code modification happens between the quic_conn error detection and the emission of the CONNECTION_CLOSE, so it should be pretty rare. However, there is still a tiny possibility it may happen. To prevent this, first check that quic_conn error code is not set before setting it. Ideally, transport layer API should be adjusted to be able to set this without fiddling with the quic_conn directly. This should be backported up to 2.6. --- src/mux_quic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mux_quic.c b/src/mux_quic.c index 82d2076c6..bd6741701 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -851,8 +851,12 @@ void qcc_emit_cc_app(struct qcc *qcc, int err, int immediate) tasklet_wakeup(qcc->wait_event.tasklet); } else { - /* Only register the error code for graceful shutdown. */ - qcc->conn->handle.qc->err = quic_err_app(err); + /* Only register the error code for graceful shutdown. + * Do not overwrite quic-conn existing code if already set. + * TODO implement a wrapper function for this in quic-conn module + */ + if (!(qcc->conn->handle.qc->flags & QUIC_FL_CONN_IMMEDIATE_CLOSE)) + qcc->conn->handle.qc->err = quic_err_app(err); } TRACE_LEAVE(QMUX_EV_QCC_END, qcc->conn);