diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-07-23 11:25:57 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@rostedt.homelinux.com> | 2013-07-24 11:22:51 -0400 |
commit | 15544209cb0b5312e5220a9337a1fe61d1a1f2d9 (patch) | |
tree | ec12c5587cd71821b5edff4f67dc0439438cb538 /kernel/trace/trace.c | |
parent | 649e9c70da6bfbeb563193a35d3424a5aa7c0d38 (diff) |
tracing: Change tracing_pipe_fops() to rely on tracing_get_cpu()
tracing_open_pipe() is racy, the memory inode->i_private points to
can be already freed.
Change debugfs_create_file("trace_pipe", data) callers to to pass
"data = tr", tracing_open_pipe() can use tracing_get_cpu().
Link: http://lkml.kernel.org/r/20130723152557.GA23717@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index cfff63c2148a..51a99ef2a6e5 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -3959,8 +3959,7 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf, | |||
3959 | 3959 | ||
3960 | static int tracing_open_pipe(struct inode *inode, struct file *filp) | 3960 | static int tracing_open_pipe(struct inode *inode, struct file *filp) |
3961 | { | 3961 | { |
3962 | struct trace_cpu *tc = inode->i_private; | 3962 | struct trace_array *tr = inode->i_private; |
3963 | struct trace_array *tr = tc->tr; | ||
3964 | struct trace_iterator *iter; | 3963 | struct trace_iterator *iter; |
3965 | int ret = 0; | 3964 | int ret = 0; |
3966 | 3965 | ||
@@ -4006,9 +4005,9 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp) | |||
4006 | if (trace_clocks[tr->clock_id].in_ns) | 4005 | if (trace_clocks[tr->clock_id].in_ns) |
4007 | iter->iter_flags |= TRACE_FILE_TIME_IN_NS; | 4006 | iter->iter_flags |= TRACE_FILE_TIME_IN_NS; |
4008 | 4007 | ||
4009 | iter->cpu_file = tc->cpu; | 4008 | iter->tr = tr; |
4010 | iter->tr = tc->tr; | 4009 | iter->trace_buffer = &tr->trace_buffer; |
4011 | iter->trace_buffer = &tc->tr->trace_buffer; | 4010 | iter->cpu_file = tracing_get_cpu(inode); |
4012 | mutex_init(&iter->mutex); | 4011 | mutex_init(&iter->mutex); |
4013 | filp->private_data = iter; | 4012 | filp->private_data = iter; |
4014 | 4013 | ||
@@ -4031,8 +4030,7 @@ fail: | |||
4031 | static int tracing_release_pipe(struct inode *inode, struct file *file) | 4030 | static int tracing_release_pipe(struct inode *inode, struct file *file) |
4032 | { | 4031 | { |
4033 | struct trace_iterator *iter = file->private_data; | 4032 | struct trace_iterator *iter = file->private_data; |
4034 | struct trace_cpu *tc = inode->i_private; | 4033 | struct trace_array *tr = inode->i_private; |
4035 | struct trace_array *tr = tc->tr; | ||
4036 | 4034 | ||
4037 | mutex_lock(&trace_types_lock); | 4035 | mutex_lock(&trace_types_lock); |
4038 | 4036 | ||
@@ -5571,7 +5569,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu) | |||
5571 | 5569 | ||
5572 | /* per cpu trace_pipe */ | 5570 | /* per cpu trace_pipe */ |
5573 | trace_create_cpu_file("trace_pipe", 0444, d_cpu, | 5571 | trace_create_cpu_file("trace_pipe", 0444, d_cpu, |
5574 | &data->trace_cpu, cpu, &tracing_pipe_fops); | 5572 | tr, cpu, &tracing_pipe_fops); |
5575 | 5573 | ||
5576 | /* per cpu trace */ | 5574 | /* per cpu trace */ |
5577 | trace_create_cpu_file("trace", 0644, d_cpu, | 5575 | trace_create_cpu_file("trace", 0644, d_cpu, |
@@ -6157,7 +6155,7 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer) | |||
6157 | (void *)&tr->trace_cpu, &tracing_fops); | 6155 | (void *)&tr->trace_cpu, &tracing_fops); |
6158 | 6156 | ||
6159 | trace_create_file("trace_pipe", 0444, d_tracer, | 6157 | trace_create_file("trace_pipe", 0444, d_tracer, |
6160 | (void *)&tr->trace_cpu, &tracing_pipe_fops); | 6158 | tr, &tracing_pipe_fops); |
6161 | 6159 | ||
6162 | trace_create_file("buffer_size_kb", 0644, d_tracer, | 6160 | trace_create_file("buffer_size_kb", 0644, d_tracer, |
6163 | (void *)&tr->trace_cpu, &tracing_entries_fops); | 6161 | (void *)&tr->trace_cpu, &tracing_entries_fops); |