tracing: Report TP_printk double dereference with pr_warn()
PATCH 1/1 tracing: Report TP_printk double dereference with pr_warn()
test_double_dereference() uses WARN_ONCE(), which is per-call-site. Only the first offending event in the kernel is ever reported, and the tree still has six: ice_{rx,tx}_dim_template, two hfi1 txq events, mtu3_ep and edma_log_io. Whichever registers first hides the rest, and it taints the kernel for what is a source-level mistake.
Use pr_warn() instead, matching the "TRACE EVENT ERROR:" report that handle_dereference_arg() already emits for the same class of problem. All offenders are now listed on one boot.
--- kernel/trace/trace_events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_events.c +2 -2
@@ -415,8 +415,8 @@ static void test_double_dereference(const char *str, int len, ptr +=5 ;for (; ptr < end; ptr++) {if (ptr[0 ] =='-' && ptr[1 ] =='>' ) { -WARN_ONCE (1 ,"Event %s has double dereference in TP_printk: %.*s\n" , -trace_event_name (call), len, str); +pr_warn ("TRACE EVENT ERROR: Event %s has double dereference in TP_printk: %.*s\n" , +trace_event_name (call), len, str);return ; }if (!isalnum (*ptr) && *ptr !='_' )
Signature · 1 line
2.55.0
Quoted 9 lines · On Thu, 6 Aug 2026 06:07:16 +0100 David Carlier <[email protected]> wrote:
test_double_dereference()usesWARN_ONCE(), which is per-call-site. Only the first offending event in the kernel is ever reported, and the tree still has six: ice_{rx,tx}_dim_template, two hfi1 txq events,mtu3_epandedma_log_io. Whichever registers first hides the rest, and it taints the kernel for what is a source-level mistake.Use
pr_warn()instead, matching the "TRACE EVENT ERROR:" report thathandle_dereference_arg()already emits for the same class of problem. All offenders are now listed on one boot.
NAK!
Quoted 2 lines
Fixes b5cc230af5e5 ("tracing: Warn when an event dereferences a pointer in TP_printk()")
This is by no way a fix!
I want a big splat when this is triggered. It is a bug and needs to be fixed immediately. pr_warn() does not make tests fail. I want this to fail tests. I want this to panic when panic_on_warn is set.
Quoted 10 lines
Signed-off-by David Carlier <[email protected]>--- kernel/trace/trace_events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/trace/trace_events.c +0
-0
kernel/trace/trace_events.c static void test_double_dereference(const char *str, int len, · line 419
Quoted 7 lines
kernel/trace/trace_events.c +2
-2@@ -415,8 +415,8 @@ static void test_double_dereference(const char *str, int len, ptr +=5 ;for (; ptr < end; ptr++) {if (ptr[0 ] =='-' && ptr[1 ] =='>' ) { -WARN_ONCE (1 ,"Event %s has double dereference in TP_printk: %.*s\n" , -trace_event_name (call), len, str); +pr_warn ("TRACE EVENT ERROR: Event %s has double dereference in TP_printk: %.*s\n" , +trace_event_name (call), len, str);
Now I am OK with adding a pr_warn() with the WARN_ONCE() but the WARN_ONCE() must stay. But leave off the fixes tag.
-- Steve
Quoted 3 lines
kernel/trace/trace_events.c +0
-0return ; }if (!isalnum (*ptr) && *ptr !='_' )
PATCH v2 1/1 tracing: Report every TP_printk double dereference
WARN_ONCE() splats once per call site, so only the first offending event registered is ever reported. The tree currently has six:
ice_{rx,tx}_dim_template, two hfi1 txq events, mtu3_ep and edma_log_io. Whichever registers first hides the rest, and each has to be found again on the next boot.
Add a pr_warn() next to the WARN_ONCE() so every offender is listed, the same way test_event_printk() already pairs WARN_ON_ONCE() with pr_warn() for unsafe %p* dereferences. The WARN_ONCE() stays so the condition still fails tests and panics under panic_on_warn.
--- kernel/trace/trace_events.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/trace/trace_events.c +2 -0
@@ -415,6 +415,8 @@ static void test_double_dereference(const char *str, int len, ptr +=5 ;for (; ptr < end; ptr++) {if (ptr[0 ] =='-' && ptr[1 ] =='>' ) { +pr_warn ("TRACE EVENT ERROR: Event %s has double dereference in TP_printk: %.*s\n" , +trace_event_name (call), len, str);WARN_ONCE (1 ,"Event %s has double dereference in TP_printk: %.*s\n" ,trace_event_name (call), len, str);return ;
Signature · 1 line
2.55.0