diff options
author | Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com> | 2014-06-06 02:35:17 +0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-06-06 12:47:46 +0400 |
commit | dc81e5e3abb9f98a3cb6f269c0bee595b2c1235d (patch) | |
tree | 7a61f4727ce4bcee34e8ec808b5c51e2510d9a9a /kernel/trace/trace.h | |
parent | 34839f5a69989c0ee48386a788fba37eb75910f7 (diff) | |
download | linux-dc81e5e3abb9f98a3cb6f269c0bee595b2c1235d.tar.xz |
tracing: Return error if ftrace_trace_arrays list is empty
ftrace_trace_arrays links global_trace.list. However, global_trace
is not added to ftrace_trace_arrays if trace_alloc_buffers() failed.
As the result, ftrace_trace_arrays becomes an empty list. If
ftrace_trace_arrays is an empty list, current top_trace_array() returns
an invalid pointer. As the result, the kernel can induce memory corruption
or panic.
Current implementation does not check whether ftrace_trace_arrays is empty
list or not. So, in this patch, if ftrace_trace_arrays is empty list,
top_trace_array() returns NULL. Moreover, this patch makes all functions
calling top_trace_array() handle it appropriately.
Link: http://lkml.kernel.org/p/20140605223517.32311.99233.stgit@yunodevel
Signed-off-by: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r-- | kernel/trace/trace.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 217207ad60b3..9e82551dd566 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -252,6 +252,9 @@ static inline struct trace_array *top_trace_array(void) { struct trace_array *tr; + if (list_empty(ftrace_trace_arrays.prev)) + return NULL; + tr = list_entry(ftrace_trace_arrays.prev, typeof(*tr), list); WARN_ON(!(tr->flags & TRACE_ARRAY_FL_GLOBAL)); |