]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: trace: avoid race condition when retrieving session from conn->owner
authorWilly Tarreau <w@1wt.eu>
Fri, 18 Mar 2022 16:37:20 +0000 (17:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Mar 2022 16:43:28 +0000 (17:43 +0100)
There's a rare race condition possible when trying to retrieve session from
a back connection's owner, that was fixed in 2.4 and described in commit
3aab17bd5 ("BUG/MAJOR: connection: reset conn->owner when detaching from
session list").

It also affects the trace code which does the same, so the same fix is
needed, i.e. check from conn->session_list that the connection is still
enlisted. It's visible when sending a few tens to hundreds of parallel
requests to an h2 backend and enabling traces in parallel.

This should be backported as far as 2.2 which is the oldest version
supporting traces.

src/trace.c

index 8a39854066885e6d08f629b05215a81f9a0b640a..541acf213245fe0f961a4db5b4b648a196138bbf 100644 (file)
@@ -122,7 +122,7 @@ void __trace(enum trace_level level, uint64_t mask, struct trace_source *src,
 
        if (!sess && strm)
                sess = strm->sess;
-       else if (!sess && conn)
+       else if (!sess && conn && LIST_INLIST(&conn->session_list))
                sess = conn->owner;
        else if (!sess && check)
                sess = check->sess;