]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: mux-pt: Never fully close the connection on shutdown
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 2 Sep 2024 13:30:11 +0000 (15:30 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 2 Sep 2024 13:50:25 +0000 (15:50 +0200)
commit76fa71f7a8d27006ea1b06b417963501d3a5fcab
tree1d4f443d2604df8929426d736e49aeeebcad6522
parentf9adcdf039369cd9ae71023ccbb9c9a72993e454
BUG/MEDIUM: mux-pt: Never fully close the connection on shutdown

When a shutdown is reported to the mux (shutdown for reads or writes), the
connexion is immediately fully closed if the mux detects the connexion is
closed in both directions. Only the passthrough multiplexer is able to
perform this action at this stage because there is no stream and no internal
data. Other muxes perform a full connection close during the mux's release
stage. It was working quite well since recently. But, in theory, the bug is
quite old.

In fact, it seems possible for the lower layer to report an error on the
connection in same time a shutdown is performed on the mux. Depending on how
events are scheduled, the following may happen:

 1. An connection error is detected at the fd layer and a wakeup is
    scheduled on the mux to handle the event.

 2. A shutdown for writes is performed on the mux. Here the mux decides to
    fully close the connexion. If the xprt is not used to log info, it is
    released.

 3. The mux is finally woken up. It tries to retrieve data from the xprt
    because it is not awayre there was an error. This leads to a crash
    because of a NULL-deref.

By reading the code, it is not obvious. But it seems possible with SSL
connection when the handshake is rearmed. It happens when a
SSL_ERROR_WANT_WRITE is reported on a SSL_read() attempt or a
SSL_ERROR_WANT_READ on a SSL_write() attempt.

This bug is only visible if the XPRT is not used to log info. So it is no so
common.

This patch should fix the 2nd crash reported in the issue #2656. It must
first be backported as far as 2.9 and then slowly to all stable versions.
src/mux_pt.c