aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-07-23 11:26:00 -0400
committerSteven Rostedt <rostedt@rostedt.homelinux.com>2013-07-24 11:22:51 -0400
commit46ef2be0d1d5ccea0c41bb606143586daadd537c (patch)
treee924cd0e92231bdf0fa5a37fa8372fe42b319b90
parent15544209cb0b5312e5220a9337a1fe61d1a1f2d9 (diff)
tracing: Change tracing_buffers_fops to rely on tracing_get_cpu()
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>
-rw-r--r--kernel/trace/trace.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 51a99ef2a6e5..30c058a56ffb 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4949,8 +4949,7 @@ static const struct file_operations snapshot_raw_fops = {
4949 4949
4950static int tracing_buffers_open(struct inode *inode, struct file *filp) 4950static int tracing_buffers_open(struct inode *inode, struct file *filp)
4951{ 4951{
4952 struct trace_cpu *tc = inode->i_private; 4952 struct trace_array *tr = inode->i_private;
4953 struct trace_array *tr = tc->tr;
4954 struct ftrace_buffer_info *info; 4953 struct ftrace_buffer_info *info;
4955 int ret; 4954 int ret;
4956 4955
@@ -4969,7 +4968,7 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp)
4969 mutex_lock(&trace_types_lock); 4968 mutex_lock(&trace_types_lock);
4970 4969
4971 info->iter.tr = tr; 4970 info->iter.tr = tr;
4972 info->iter.cpu_file = tc->cpu; 4971 info->iter.cpu_file = tracing_get_cpu(inode);
4973 info->iter.trace = tr->current_trace; 4972 info->iter.trace = tr->current_trace;
4974 info->iter.trace_buffer = &tr->trace_buffer; 4973 info->iter.trace_buffer = &tr->trace_buffer;
4975 info->spare = NULL; 4974 info->spare = NULL;
@@ -5576,7 +5575,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
5576 &data->trace_cpu, cpu, &tracing_fops); 5575 &data->trace_cpu, cpu, &tracing_fops);
5577 5576
5578 trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu, 5577 trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu,
5579 &data->trace_cpu, cpu, &tracing_buffers_fops); 5578 tr, cpu, &tracing_buffers_fops);
5580 5579
5581 trace_create_cpu_file("stats", 0444, d_cpu, 5580 trace_create_cpu_file("stats", 0444, d_cpu,
5582 &data->trace_cpu, cpu, &tracing_stats_fops); 5581 &data->trace_cpu, cpu, &tracing_stats_fops);
@@ -5589,7 +5588,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
5589 &data->trace_cpu, cpu, &snapshot_fops); 5588 &data->trace_cpu, cpu, &snapshot_fops);
5590 5589
5591 trace_create_cpu_file("snapshot_raw", 0444, d_cpu, 5590 trace_create_cpu_file("snapshot_raw", 0444, d_cpu,
5592 &data->trace_cpu, cpu, &snapshot_raw_fops); 5591 tr, cpu, &snapshot_raw_fops);
5593#endif 5592#endif
5594} 5593}
5595 5594