Skip to content

Commit f022814

Browse files
committed
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
2 parents 710f5d6 + eca344a commit f022814

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kernel/trace/trace.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3673,12 +3673,17 @@ static char *trace_iter_expand_format(struct trace_iterator *iter)
36733673
}
36743674

36753675
/* Returns true if the string is safe to dereference from an event */
3676-
static bool trace_safe_str(struct trace_iterator *iter, const char *str)
3676+
static bool trace_safe_str(struct trace_iterator *iter, const char *str,
3677+
bool star, int len)
36773678
{
36783679
unsigned long addr = (unsigned long)str;
36793680
struct trace_event *trace_event;
36803681
struct trace_event_call *event;
36813682

3683+
/* Ignore strings with no length */
3684+
if (star && !len)
3685+
return true;
3686+
36823687
/* OK if part of the event data */
36833688
if ((addr >= (unsigned long)iter->ent) &&
36843689
(addr < (unsigned long)iter->ent + iter->ent_size))
@@ -3864,7 +3869,7 @@ void trace_check_vprintf(struct trace_iterator *iter, const char *fmt,
38643869
* instead. See samples/trace_events/trace-events-sample.h
38653870
* for reference.
38663871
*/
3867-
if (WARN_ONCE(!trace_safe_str(iter, str),
3872+
if (WARN_ONCE(!trace_safe_str(iter, str, star, len),
38683873
"fmt: '%s' current_buffer: '%s'",
38693874
fmt, show_buffer(&iter->seq))) {
38703875
int ret;

0 commit comments

Comments
 (0)