From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>
Subject: [PATCH 2/9] tracing: Change tracing_pipe_fops() to rely on tracing_get_cpu()
Date: Fri, 26 Jul 2013 09:03:29 -0400 [thread overview]
Message-ID: <20130726130512.305024273@goodmis.org> (raw)
In-Reply-To: 20130726130327.911599518@goodmis.org
[-- Attachment #1: 0002-tracing-Change-tracing_pipe_fops-to-rely-on-tracing_.patch --]
[-- Type: text/plain, Size: 2455 bytes --]
From: Oleg Nesterov <oleg@redhat.com>
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>
---
kernel/trace/trace.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index cfff63c..51a99ef 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,
static int tracing_open_pipe(struct inode *inode, struct file *filp)
{
- struct trace_cpu *tc = inode->i_private;
- struct trace_array *tr = tc->tr;
+ struct trace_array *tr = inode->i_private;
struct trace_iterator *iter;
int ret = 0;
@@ -4006,9 +4005,9 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
if (trace_clocks[tr->clock_id].in_ns)
iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
- iter->cpu_file = tc->cpu;
- iter->tr = tc->tr;
- iter->trace_buffer = &tc->tr->trace_buffer;
+ iter->tr = tr;
+ iter->trace_buffer = &tr->trace_buffer;
+ iter->cpu_file = tracing_get_cpu(inode);
mutex_init(&iter->mutex);
filp->private_data = iter;
@@ -4031,8 +4030,7 @@ fail:
static int tracing_release_pipe(struct inode *inode, struct file *file)
{
struct trace_iterator *iter = file->private_data;
- struct trace_cpu *tc = inode->i_private;
- struct trace_array *tr = tc->tr;
+ struct trace_array *tr = inode->i_private;
mutex_lock(&trace_types_lock);
@@ -5571,7 +5569,7 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
/* per cpu trace_pipe */
trace_create_cpu_file("trace_pipe", 0444, d_cpu,
- &data->trace_cpu, cpu, &tracing_pipe_fops);
+ tr, cpu, &tracing_pipe_fops);
/* per cpu trace */
trace_create_cpu_file("trace", 0644, d_cpu,
@@ -6157,7 +6155,7 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
(void *)&tr->trace_cpu, &tracing_fops);
trace_create_file("trace_pipe", 0444, d_tracer,
- (void *)&tr->trace_cpu, &tracing_pipe_fops);
+ tr, &tracing_pipe_fops);
trace_create_file("buffer_size_kb", 0644, d_tracer,
(void *)&tr->trace_cpu, &tracing_entries_fops);
--
1.7.10.4
next prev parent reply other threads:[~2013-07-26 13:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-26 13:03 [PATCH 0/9] [GIT PULL] tracing: fixes Steven Rostedt
2013-07-26 13:03 ` [PATCH 1/9] tracing: Introduce trace_create_cpu_file() and tracing_get_cpu() Steven Rostedt
2013-07-26 13:03 ` Steven Rostedt [this message]
2013-07-26 13:03 ` [PATCH 3/9] tracing: Change tracing_buffers_fops to rely on tracing_get_cpu() Steven Rostedt
2013-07-26 13:03 ` [PATCH 4/9] tracing: Change tracing_stats_fops " Steven Rostedt
2013-07-26 13:03 ` [PATCH 5/9] tracing: Change tracing_entries_fops " Steven Rostedt
2013-07-26 13:03 ` [PATCH 6/9] tracing: Change tracing_fops/snapshot_fops " Steven Rostedt
2013-07-26 13:03 ` [PATCH 7/9] tracing: Kill trace_cpu struct/members Steven Rostedt
2013-07-26 13:03 ` [PATCH 8/9] ftrace: Add check for NULL regs if ops has SAVE_REGS set Steven Rostedt
2013-07-26 13:03 ` [PATCH 9/9] tracing: Remove locking trace_types_lock from tracing_reset_all_online_cpus() Steven Rostedt
2013-07-26 16:15 ` Arend van Spriel
2013-07-26 16:41 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130726130512.305024273@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox