Commit f0228146 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'trace-v5.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull trace event string verifier fix from Steven Rostedt:
 "The run-time string verifier checks all trace event formats as
  they are read from the tracing file to make sure that the %s pointers
  are not reading something that no longer exists.

  However, it failed to account for the valid case of '%*.s' where the
  length given is zero, and the string is NULL. It incorrectly flagged
  it as a null pointer dereference and gave a WARN_ON()"

* tag 'trace-v5.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  tracing: Have trace event string test handle zero length strings
parents 710f5d62 eca344a7
...@@ -3673,12 +3673,17 @@ static char *trace_iter_expand_format(struct trace_iterator *iter) ...@@ -3673,12 +3673,17 @@ static char *trace_iter_expand_format(struct trace_iterator *iter)
} }
/* Returns true if the string is safe to dereference from an event */ /* Returns true if the string is safe to dereference from an event */
static bool trace_safe_str(struct trace_iterator *iter, const char *str) static bool trace_safe_str(struct trace_iterator *iter, const char *str,
bool star, int len)
{ {
unsigned long addr = (unsigned long)str; unsigned long addr = (unsigned long)str;
struct trace_event *trace_event; struct trace_event *trace_event;
struct trace_event_call *event; struct trace_event_call *event;
/* Ignore strings with no length */
if (star && !len)
return true;
/* OK if part of the event data */ /* OK if part of the event data */
if ((addr >= (unsigned long)iter->ent) && if ((addr >= (unsigned long)iter->ent) &&
(addr < (unsigned long)iter->ent + iter->ent_size)) (addr < (unsigned long)iter->ent + iter->ent_size))
...@@ -3864,7 +3869,7 @@ void trace_check_vprintf(struct trace_iterator *iter, const char *fmt, ...@@ -3864,7 +3869,7 @@ void trace_check_vprintf(struct trace_iterator *iter, const char *fmt,
* instead. See samples/trace_events/trace-events-sample.h * instead. See samples/trace_events/trace-events-sample.h
* for reference. * for reference.
*/ */
if (WARN_ONCE(!trace_safe_str(iter, str), if (WARN_ONCE(!trace_safe_str(iter, str, star, len),
"fmt: '%s' current_buffer: '%s'", "fmt: '%s' current_buffer: '%s'",
fmt, show_buffer(&iter->seq))) { fmt, show_buffer(&iter->seq))) {
int ret; int ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment