Skip to content

Commit

Permalink
Merge tag 'trace-v6.13-rc5' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/trace/linux-trace

Pull tracing fix from Steven Rostedt:
 "Fix trace event string check when dealing with array of strings

  The xe_bo_move event has a field that indexes into an array of
  strings. The TP_fast_assign() added the index into the ring buffer and
  the TP_printk() had a "%s" that referenced the array using the index
  in the ring buffer. This is a legitimate use of "%s" in trace events.
  But this triggered a false positive in the test_event_printk() at boot
  saying that the string was dangerous.

  Change the check to allow arrays using fields in the ring buffer as an
  index to be considered a safe string"

* tag 'trace-v6.13-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  tracing: Have process_string() also allow arrays
  • Loading branch information
torvalds committed Jan 1, 2025
2 parents ccb98cc + afc6717 commit 56e6a34
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,18 @@ static bool process_string(const char *fmt, int len, struct trace_event_call *ca
s = r + 1;
} while (s < e);

/*
* Check for arrays. If the argument has: foo[REC->val]
* then it is very likely that foo is an array of strings
* that are safe to use.
*/
r = strstr(s, "[");
if (r && r < e) {
r = strstr(r, "REC->");
if (r && r < e)
return true;
}

/*
* If there's any strings in the argument consider this arg OK as it
* could be: REC->field ? "foo" : "bar" and we don't want to get into
Expand Down

0 comments on commit 56e6a34

Please sign in to comment.