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)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 3 Sep 2024 16:38:22 +0000 (18:38 +0200)
commitfe71ad89da6638be39f71824cdab7ef015a575d2
treea7c61261bea84094ca8f8804b3ac6849164c42a8
parentab1a247177547d85ae995bb0d03981a8c621247a
BUG/MEDIUM: trace: fix null deref in lockon mechanism since TRACE_ENABLED()

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.

(cherry picked from commit b5df6b5a31b86b4403f00b7e0230c97883eca0f3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/trace.c