On Wed, Mar 23, 2022 at 10:02:00AM -0400, Steven Rostedt wrote: > On Wed, 23 Mar 2022 08:47:10 -0400 > Brian Foster <bfoster@xxxxxxxxxx> wrote: > > > What's the best way to address this going forward with the memory usage > > verification in place? ISTM we could perhaps consider dropping the > > custom %.*s thing in favor of using %s with __string_len() and friends, > > or perhaps just replace the open-coded NULL parameter with the "(null)" > > string that the trace subsystem code seems to use on NULL pointer > > checks. The latter seems pretty simple and straightforward of a change > > to me, but I want to make sure I'm not missing something more obvious. > > Thoughts? > > Can you see if the following (totally untested) patch fixes your issue? > Yup, that restores historical behavior. Thanks! Brian > -- Steve > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index 08ea781540b5..f4de111fa18f 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -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 */ > -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; > struct trace_event *trace_event; > struct trace_event_call *event; > > + /* Ignore strings with no length */ > + if (star && !len) > + return true; > + > /* OK if part of the event data */ > if ((addr >= (unsigned long)iter->ent) && > (addr < (unsigned long)iter->ent + iter->ent_size)) > @@ -3864,7 +3869,7 @@ void trace_check_vprintf(struct trace_iterator *iter, const char *fmt, > * instead. See samples/trace_events/trace-events-sample.h > * 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, show_buffer(&iter->seq))) { > int ret; >