diff options
author | Steven Rostedt (Red Hat) <[email protected]> | 2015-04-17 10:27:57 -0400 |
---|---|---|
committer | Steven Rostedt <[email protected]> | 2015-04-17 10:34:43 -0400 |
commit | 3193899d4dd54056f8c2e0b1e40dd6e2f0009f28 (patch) | |
tree | 8f118c5311094656325fff91c1a036d042ce46dc | |
parent | 84fce9db4d7eaebd6cb2ee30c15da6d4e4daf846 (diff) |
tracing: Fix possible out of bounds memory access when parsing enums
The code that replaces the enum names with the enum values in the
tracepoints' format files could possible miss the end of string nul
character. This was caused by processing things like backslashes, quotes
and other tokens. After processing the tokens, a check for the nul
character needed to be done before continuing the loop, because the loop
incremented the pointer before doing the check, which could bypass the nul
character.
Link: http://lkml.kernel.org/r/[email protected]
Reported-by: Sasha Levin <[email protected]> # via KASan
Tested-by: Andrey Ryabinin <[email protected]>
Fixes: 0c564a538aa9 "tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values"
Signed-off-by: Steven Rostedt <[email protected]>
-rw-r--r-- | kernel/trace/trace_events.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 36a957c996c7..b49c107f82ac 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1760,6 +1760,8 @@ static void update_event_printk(struct ftrace_event_call *call, ptr++; /* Check for alpha chars like ULL */ } while (isalnum(*ptr)); + if (!*ptr) + break; /* * A number must have some kind of delimiter after * it, and we can ignore that too. @@ -1786,12 +1788,16 @@ static void update_event_printk(struct ftrace_event_call *call, do { ptr++; } while (isalnum(*ptr) || *ptr == '_'); + if (!*ptr) + break; /* * If what comes after this variable is a '.' or * '->' then we can continue to ignore that string. */ if (*ptr == '.' || (ptr[0] == '-' && ptr[1] == '>')) { ptr += *ptr == '.' ? 1 : 2; + if (!*ptr) + break; goto skip_more; } /* |