]> Git Repo - J-linux.git/commitdiff
tracing: Check field value in hist_field_name()
authorSteven Rostedt (Google) <[email protected]>
Thu, 2 Mar 2023 01:00:53 +0000 (20:00 -0500)
committerSteven Rostedt (Google) <[email protected]>
Fri, 10 Mar 2023 03:17:06 +0000 (22:17 -0500)
The function hist_field_name() cannot handle being passed a NULL field
parameter. It should never be NULL, but due to a previous bug, NULL was
passed to the function and the kernel crashed due to a NULL dereference.
Mark Rutland reported this to me on IRC.

The bug was fixed, but to prevent future bugs from crashing the kernel,
check the field and add a WARN_ON() if it is NULL.

Link: https://lkml.kernel.org/r/[email protected]
Cc: [email protected]
Cc: Masami Hiramatsu <[email protected]>
Cc: Andrew Morton <[email protected]>
Reported-by: Mark Rutland <[email protected]>
Fixes: c6afad49d127f ("tracing: Add hist trigger 'sym' and 'sym-offset' modifiers")
Tested-by: Mark Rutland <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
kernel/trace/trace_events_hist.c

index 6e8ab726a7b5ef0d96a1e034ccc0747785090a50..486cca3c2b75450f23f8b680045421cf234d232f 100644 (file)
@@ -1331,6 +1331,9 @@ static const char *hist_field_name(struct hist_field *field,
 {
        const char *field_name = "";
 
+       if (WARN_ON_ONCE(!field))
+               return field_name;
+
        if (level > 1)
                return field_name;
 
This page took 0.052278 seconds and 4 git commands to generate.