Skip to content

Commit 92b6279

Browse files
oleg-nesterovgregkh
authored andcommitted
tracing: Change tracing_buffers_fops to rely on tracing_get_cpu()
commit 46ef2be 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>
1 parent 23b625f commit 92b6279

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4941,8 +4941,7 @@ static const struct file_operations snapshot_raw_fops = {
49414941

49424942
static int tracing_buffers_open(struct inode *inode, struct file *filp)
49434943
{
4944-
struct trace_cpu *tc = inode->i_private;
4945-
struct trace_array *tr = tc->tr;
4944+
struct trace_array *tr = inode->i_private;
49464945
struct ftrace_buffer_info *info;
49474946
int ret;
49484947

@@ -4961,7 +4960,7 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp)
49614960
mutex_lock(&trace_types_lock);
49624961

49634962
info->iter.tr = tr;
4964-
info->iter.cpu_file = tc->cpu;
4963+
info->iter.cpu_file = tracing_get_cpu(inode);
49654964
info->iter.trace = tr->current_trace;
49664965
info->iter.trace_buffer = &tr->trace_buffer;
49674966
info->spare = NULL;
@@ -5568,7 +5567,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
55685567
&data->trace_cpu, cpu, &tracing_fops);
55695568

55705569
trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu,
5571-
&data->trace_cpu, cpu, &tracing_buffers_fops);
5570+
tr, cpu, &tracing_buffers_fops);
55725571

55735572
trace_create_cpu_file("stats", 0444, d_cpu,
55745573
&data->trace_cpu, cpu, &tracing_stats_fops);
@@ -5581,7 +5580,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
55815580
&data->trace_cpu, cpu, &snapshot_fops);
55825581

55835582
trace_create_cpu_file("snapshot_raw", 0444, d_cpu,
5584-
&data->trace_cpu, cpu, &snapshot_raw_fops);
5583+
tr, cpu, &snapshot_raw_fops);
55855584
#endif
55865585
}
55875586

0 commit comments

Comments
 (0)