Commit 46ef2be0 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Steven Rostedt

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.comSigned-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 15544209
...@@ -4949,8 +4949,7 @@ static const struct file_operations snapshot_raw_fops = { ...@@ -4949,8 +4949,7 @@ static const struct file_operations snapshot_raw_fops = {
static int tracing_buffers_open(struct inode *inode, struct file *filp) static int tracing_buffers_open(struct inode *inode, struct file *filp)
{ {
struct trace_cpu *tc = inode->i_private; struct trace_array *tr = inode->i_private;
struct trace_array *tr = tc->tr;
struct ftrace_buffer_info *info; struct ftrace_buffer_info *info;
int ret; int ret;
...@@ -4969,7 +4968,7 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp) ...@@ -4969,7 +4968,7 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp)
mutex_lock(&trace_types_lock); mutex_lock(&trace_types_lock);
info->iter.tr = tr; info->iter.tr = tr;
info->iter.cpu_file = tc->cpu; info->iter.cpu_file = tracing_get_cpu(inode);
info->iter.trace = tr->current_trace; info->iter.trace = tr->current_trace;
info->iter.trace_buffer = &tr->trace_buffer; info->iter.trace_buffer = &tr->trace_buffer;
info->spare = NULL; info->spare = NULL;
...@@ -5576,7 +5575,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu) ...@@ -5576,7 +5575,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
&data->trace_cpu, cpu, &tracing_fops); &data->trace_cpu, cpu, &tracing_fops);
trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu, trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu,
&data->trace_cpu, cpu, &tracing_buffers_fops); tr, cpu, &tracing_buffers_fops);
trace_create_cpu_file("stats", 0444, d_cpu, trace_create_cpu_file("stats", 0444, d_cpu,
&data->trace_cpu, cpu, &tracing_stats_fops); &data->trace_cpu, cpu, &tracing_stats_fops);
...@@ -5589,7 +5588,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu) ...@@ -5589,7 +5588,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
&data->trace_cpu, cpu, &snapshot_fops); &data->trace_cpu, cpu, &snapshot_fops);
trace_create_cpu_file("snapshot_raw", 0444, d_cpu, trace_create_cpu_file("snapshot_raw", 0444, d_cpu,
&data->trace_cpu, cpu, &snapshot_raw_fops); tr, cpu, &snapshot_raw_fops);
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment