aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-07-23 11:25:57 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-29 12:47:32 -0400
commit23b625fa111e7358ce84672c4444c068b2b1e204 (patch)
tree592c16d7d53e3034a324f8132f0930af74c1c89c /kernel
parente2d4dbe02175e54616fe52c4e9c367199f8ecdaa (diff)
tracing: Change tracing_pipe_fops() to rely on tracing_get_cpu()
commit 15544209cb0b5312e5220a9337a1fe61d1a1f2d9 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index f064dfb973fe..8e8bb0e25489 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3950,8 +3950,7 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf,
3950 3950
3951static int tracing_open_pipe(struct inode *inode, struct file *filp) 3951static int tracing_open_pipe(struct inode *inode, struct file *filp)
3952{ 3952{
3953 struct trace_cpu *tc = inode->i_private; 3953 struct trace_array *tr = inode->i_private;
3954 struct trace_array *tr = tc->tr;
3955 struct trace_iterator *iter; 3954 struct trace_iterator *iter;
3956 int ret = 0; 3955 int ret = 0;
3957 3956
@@ -3997,9 +3996,9 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
3997 if (trace_clocks[tr->clock_id].in_ns) 3996 if (trace_clocks[tr->clock_id].in_ns)
3998 iter->iter_flags |= TRACE_FILE_TIME_IN_NS; 3997 iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
3999 3998
4000 iter->cpu_file = tc->cpu; 3999 iter->tr = tr;
4001 iter->tr = tc->tr; 4000 iter->trace_buffer = &tr->trace_buffer;
4002 iter->trace_buffer = &tc->tr->trace_buffer; 4001 iter->cpu_file = tracing_get_cpu(inode);
4003 mutex_init(&iter->mutex); 4002 mutex_init(&iter->mutex);
4004 filp->private_data = iter; 4003 filp->private_data = iter;
4005 4004
@@ -4022,8 +4021,7 @@ fail:
4022static int tracing_release_pipe(struct inode *inode, struct file *file) 4021static int tracing_release_pipe(struct inode *inode, struct file *file)
4023{ 4022{
4024 struct trace_iterator *iter = file->private_data; 4023 struct trace_iterator *iter = file->private_data;
4025 struct trace_cpu *tc = inode->i_private; 4024 struct trace_array *tr = inode->i_private;
4026 struct trace_array *tr = tc->tr;
4027 4025
4028 mutex_lock(&trace_types_lock); 4026 mutex_lock(&trace_types_lock);
4029 4027
@@ -5563,7 +5561,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
5563 5561
5564 /* per cpu trace_pipe */ 5562 /* per cpu trace_pipe */
5565 trace_create_cpu_file("trace_pipe", 0444, d_cpu, 5563 trace_create_cpu_file("trace_pipe", 0444, d_cpu,
5566 &data->trace_cpu, cpu, &tracing_pipe_fops); 5564 tr, cpu, &tracing_pipe_fops);
5567 5565
5568 /* per cpu trace */ 5566 /* per cpu trace */
5569 trace_create_cpu_file("trace", 0644, d_cpu, 5567 trace_create_cpu_file("trace", 0644, d_cpu,
@@ -6149,7 +6147,7 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
6149 (void *)&tr->trace_cpu, &tracing_fops); 6147 (void *)&tr->trace_cpu, &tracing_fops);
6150 6148
6151 trace_create_file("trace_pipe", 0444, d_tracer, 6149 trace_create_file("trace_pipe", 0444, d_tracer,
6152 (void *)&tr->trace_cpu, &tracing_pipe_fops); 6150 tr, &tracing_pipe_fops);
6153 6151
6154 trace_create_file("buffer_size_kb", 0644, d_tracer, 6152 trace_create_file("buffer_size_kb", 0644, d_tracer,
6155 (void *)&tr->trace_cpu, &tracing_entries_fops); 6153 (void *)&tr->trace_cpu, &tracing_entries_fops);