]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: trace: fix null deref in lockon mechanism since TRACE_ENABLED()
authorWilly Tarreau <w@1wt.eu>
Tue, 6 Aug 2024 09:32:10 +0000 (11:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Aug 2024 14:02:59 +0000 (16:02 +0200)
When calling TRACE_ENABLED(), which is called by TRACE_PRINTF(), we pass
a NULL plockptr to __trace_enabled(). This argument is used when lockon
is active, and may update the pointer. This is an overlook which also
broke the lockon mechanism because now for calls from __trace(), it
dereferences a pointer pointing to NULL, and never updates it due to the
broken condition, so that trace() never sets up src->lockon_ptr.

The bug was introduced in 2.8 by commit 8f9a9704bb ("MINOR: trace: add a
TRACE_ENABLED() macro to determine if a trace is active"), so the fix must
be backported there.

src/trace.c

index a2fd31e0450d9e5a5a42bd242ff714892af44e77..8f6519dfb9307779bc3009a126bab05872481ec7 100644 (file)
@@ -205,7 +205,7 @@ int __trace_enabled(enum trace_level level, uint64_t mask, struct trace_source *
                if (src->lockon_ptr && src->lockon_ptr != lockon_ptr)
                        return 0;
 
-               if (*plockptr && !src->lockon_ptr && lockon_ptr && src->state == TRACE_STATE_RUNNING)
+               if (plockptr && !src->lockon_ptr && lockon_ptr && src->state == TRACE_STATE_RUNNING)
                        *plockptr = lockon_ptr;
        }