From 6e805dab2add31c7a60f2f4be933f8e6903151fe Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 18 Mar 2022 17:37:20 +0100 Subject: [PATCH] BUG/MEDIUM: trace: avoid race condition when retrieving session from conn->owner 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trace.c b/src/trace.c index 8a3985406..541acf213 100644 --- a/src/trace.c +++ b/src/trace.c @@ -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;