aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-07-23 11:26:03 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-29 12:47:32 -0400
commit6dafb0f13798c998ec344bf910b2d89c51961481 (patch)
tree81b45e5ef0f224801d09f6453199d39b4c6b7412 /kernel
parent92b6279e284257fb7908bf4d24956f5af13aaa2d (diff)
tracing: Change tracing_stats_fops to rely on tracing_get_cpu()
commit 4d3435b8a4c3357695e09c5e7a3bf73a19fca5b0 upstream. tracing_open_generic_tc() is racy, the memory inode->i_private points to can be already freed. 1. Change one of its users, tracing_stats_fops, to use tracing_*_generic_tr() instead. 2. Change trace_create_cpu_file("stats", data) to pass "data = tr". 3. Change tracing_stats_read() to use tracing_get_cpu(). Link: http://lkml.kernel.org/r/20130723152603.GA23727@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.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 7dcd67332f57..801d72b84a2a 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2973,7 +2973,6 @@ int tracing_open_generic_tr(struct inode *inode, struct file *filp)
2973 filp->private_data = inode->i_private; 2973 filp->private_data = inode->i_private;
2974 2974
2975 return 0; 2975 return 0;
2976
2977} 2976}
2978 2977
2979int tracing_open_generic_tc(struct inode *inode, struct file *filp) 2978int tracing_open_generic_tc(struct inode *inode, struct file *filp)
@@ -5277,14 +5276,14 @@ static ssize_t
5277tracing_stats_read(struct file *filp, char __user *ubuf, 5276tracing_stats_read(struct file *filp, char __user *ubuf,
5278 size_t count, loff_t *ppos) 5277 size_t count, loff_t *ppos)
5279{ 5278{
5280 struct trace_cpu *tc = filp->private_data; 5279 struct inode *inode = file_inode(filp);
5281 struct trace_array *tr = tc->tr; 5280 struct trace_array *tr = inode->i_private;
5282 struct trace_buffer *trace_buf = &tr->trace_buffer; 5281 struct trace_buffer *trace_buf = &tr->trace_buffer;
5282 int cpu = tracing_get_cpu(inode);
5283 struct trace_seq *s; 5283 struct trace_seq *s;
5284 unsigned long cnt; 5284 unsigned long cnt;
5285 unsigned long long t; 5285 unsigned long long t;
5286 unsigned long usec_rem; 5286 unsigned long usec_rem;
5287 int cpu = tc->cpu;
5288 5287
5289 s = kmalloc(sizeof(*s), GFP_KERNEL); 5288 s = kmalloc(sizeof(*s), GFP_KERNEL);
5290 if (!s) 5289 if (!s)
@@ -5337,10 +5336,10 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
5337} 5336}
5338 5337
5339static const struct file_operations tracing_stats_fops = { 5338static const struct file_operations tracing_stats_fops = {
5340 .open = tracing_open_generic_tc, 5339 .open = tracing_open_generic_tr,
5341 .read = tracing_stats_read, 5340 .read = tracing_stats_read,
5342 .llseek = generic_file_llseek, 5341 .llseek = generic_file_llseek,
5343 .release = tracing_release_generic_tc, 5342 .release = tracing_release_generic_tr,
5344}; 5343};
5345 5344
5346#ifdef CONFIG_DYNAMIC_FTRACE 5345#ifdef CONFIG_DYNAMIC_FTRACE
@@ -5570,7 +5569,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
5570 tr, cpu, &tracing_buffers_fops); 5569 tr, cpu, &tracing_buffers_fops);
5571 5570
5572 trace_create_cpu_file("stats", 0444, d_cpu, 5571 trace_create_cpu_file("stats", 0444, d_cpu,
5573 &data->trace_cpu, cpu, &tracing_stats_fops); 5572 tr, cpu, &tracing_stats_fops);
5574 5573
5575 trace_create_cpu_file("buffer_size_kb", 0444, d_cpu, 5574 trace_create_cpu_file("buffer_size_kb", 0444, d_cpu,
5576 &data->trace_cpu, cpu, &tracing_entries_fops); 5575 &data->trace_cpu, cpu, &tracing_entries_fops);