diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-07-23 11:26:00 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-29 12:47:32 -0400 |
commit | 92b6279e284257fb7908bf4d24956f5af13aaa2d (patch) | |
tree | 1c29b4616adc1d8a979fd56c1aac3d777c443756 /kernel | |
parent | 23b625fa111e7358ce84672c4444c068b2b1e204 (diff) |
tracing: Change tracing_buffers_fops to rely on tracing_get_cpu()
commit 46ef2be0d1d5ccea0c41bb606143586daadd537c upstream.
tracing_buffers_open() is racy, the memory inode->i_private points
to can be already freed.
Change debugfs_create_file("trace_pipe_raw", data) caller to pass
"data = tr", tracing_buffers_open() can use tracing_get_cpu().
Change debugfs_create_file("snapshot_raw_fops", data) caller too,
this file uses tracing_buffers_open/release.
Link: http://lkml.kernel.org/r/20130723152600.GA23720@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8e8bb0e25489..7dcd67332f57 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -4941,8 +4941,7 @@ static const struct file_operations snapshot_raw_fops = { | |||
4941 | 4941 | ||
4942 | static int tracing_buffers_open(struct inode *inode, struct file *filp) | 4942 | static int tracing_buffers_open(struct inode *inode, struct file *filp) |
4943 | { | 4943 | { |
4944 | struct trace_cpu *tc = inode->i_private; | 4944 | struct trace_array *tr = inode->i_private; |
4945 | struct trace_array *tr = tc->tr; | ||
4946 | struct ftrace_buffer_info *info; | 4945 | struct ftrace_buffer_info *info; |
4947 | int ret; | 4946 | int ret; |
4948 | 4947 | ||
@@ -4961,7 +4960,7 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp) | |||
4961 | mutex_lock(&trace_types_lock); | 4960 | mutex_lock(&trace_types_lock); |
4962 | 4961 | ||
4963 | info->iter.tr = tr; | 4962 | info->iter.tr = tr; |
4964 | info->iter.cpu_file = tc->cpu; | 4963 | info->iter.cpu_file = tracing_get_cpu(inode); |
4965 | info->iter.trace = tr->current_trace; | 4964 | info->iter.trace = tr->current_trace; |
4966 | info->iter.trace_buffer = &tr->trace_buffer; | 4965 | info->iter.trace_buffer = &tr->trace_buffer; |
4967 | info->spare = NULL; | 4966 | info->spare = NULL; |
@@ -5568,7 +5567,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu) | |||
5568 | &data->trace_cpu, cpu, &tracing_fops); | 5567 | &data->trace_cpu, cpu, &tracing_fops); |
5569 | 5568 | ||
5570 | trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu, | 5569 | trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu, |
5571 | &data->trace_cpu, cpu, &tracing_buffers_fops); | 5570 | tr, cpu, &tracing_buffers_fops); |
5572 | 5571 | ||
5573 | trace_create_cpu_file("stats", 0444, d_cpu, | 5572 | trace_create_cpu_file("stats", 0444, d_cpu, |
5574 | &data->trace_cpu, cpu, &tracing_stats_fops); | 5573 | &data->trace_cpu, cpu, &tracing_stats_fops); |
@@ -5581,7 +5580,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu) | |||
5581 | &data->trace_cpu, cpu, &snapshot_fops); | 5580 | &data->trace_cpu, cpu, &snapshot_fops); |
5582 | 5581 | ||
5583 | trace_create_cpu_file("snapshot_raw", 0444, d_cpu, | 5582 | trace_create_cpu_file("snapshot_raw", 0444, d_cpu, |
5584 | &data->trace_cpu, cpu, &snapshot_raw_fops); | 5583 | tr, cpu, &snapshot_raw_fops); |
5585 | #endif | 5584 | #endif |
5586 | } | 5585 | } |
5587 | 5586 | ||