]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: conn-stream: Only keep app layer flags of the endpoint on reset
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 4 May 2022 07:52:48 +0000 (09:52 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 May 2022 07:23:44 +0000 (09:23 +0200)
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").

src/conn_stream.c

index 78d30354e40e3c16ae92b3889a4e0b956e9325e5..b5147905b36affcfa6d519d8367ac3c53bbdc728 100644 (file)
@@ -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);