From: Christopher Faulet Date: Wed, 4 May 2022 07:52:48 +0000 (+0200) Subject: BUG/MEDIUM: conn-stream: Only keep app layer flags of the endpoint on reset X-Git-Tag: v2.6-dev9~96 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c41f93c5cd9322b0f6e9a7e6a8f43c16e97f0877;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: conn-stream: Only keep app layer flags of the endpoint on reset The commit a6c4a4834 ("BUG/MEDIUM: conn-stream: Don't erase endpoint flags on reset") was too laxy on reset. Only app layer flags must be preserved. On reset, the endpoint is detached. Thus all flags set by the endpoint itself or concerning its type must be removed. Without this fix, we can experienced crashes when a stream is released while a server connection attempt failed. Indeed, in this case, endpoint of the backend conn-stream is reset. But the endpoint type is still set. Thus when the stream is released, the endpoint is detached again. This patch is 2.6-specific. No backport needed. This commit depends on the previous one ("MINOR: conn-stream: Add mask from flags set by endpoint or app layer"). --- diff --git a/src/conn_stream.c b/src/conn_stream.c index 78d30354e4..b5147905b3 100644 --- a/src/conn_stream.c +++ b/src/conn_stream.c @@ -394,6 +394,7 @@ static void cs_detach_endp(struct conn_stream **csp) /* the cs is the only one one the endpoint */ cs->endp->target = NULL; cs->endp->ctx = NULL; + cs->endp->flags &= CS_EP_APP_MASK; cs->endp->flags |= CS_EP_DETACHED; } @@ -471,7 +472,7 @@ int cs_reset_endp(struct conn_stream *cs) cs->endp->flags |= CS_EP_ERROR; return -1; } - new_endp->flags = cs->endp->flags; + new_endp->flags = (cs->endp->flags & CS_EP_APP_MASK); /* The app is still attached, the cs will not be released */ cs_detach_endp(&cs);