BUG/MINOR: mux-quic: prevent crash after MUX init failure
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 17 Feb 2025 09:54:41 +0000 (10:54 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 19 Feb 2025 09:35:04 +0000 (10:35 +0100)
commite02d842f091e79dd58a13c0c12c7d72affc131cd
tree881ebad71081adcdeed1d06fb42440092d99332f
parent82e7d79e727b148afae59592931fd0191c5eb1c5
BUG/MINOR: mux-quic: prevent crash after MUX init failure

qmux_init() may fail for several reasons. In this case, connection
resources are freed and underlying and a CONNECTION_CLOSE will be
emitted via its quic_conn instance.

In case of qmux_init() failure, qcc_release() is used to clean up
resources, but QCC <conn> member is first resetted to NULL, as
connection released must be delayed. Some cleanup operations are thus
skipped, one of them is the resetting of <ctx> connection member to
NULL. This may cause a crash as <ctx> is a dangling pointer after QCC
release. One of the possible reproducer is to activate QMUX traces,
which will cause a segfault on the qmux_init() error leave trace.

To fix this, simply reset <ctx> to NULL manually on qmux_init() failure.

This must be backported up to 3.0.

(cherry picked from commit 2715dbe9d065d8700a8fba6e2605a451cfbb72b8)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/mux_quic.c