public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] [GIT PULL] tracing: various fixes
@ 2009-07-23  3:35 Steven Rostedt
  2009-07-23  3:35 ` [PATCH 1/2] tracing: show proper address for trace-printk format Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-07-23  3:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker


Ingo,

These two patches are built against my last push, but perhaps these
should go to 2.6.31. The first one fixes a bug that makes the 
printk_format file useless (making trace_bprintk useless for binary
readers). The other is a bug with the way the files may be truncated
incorrectly.

Please pull the latest tip/tracing/core-1 tree, which can be found at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/core-1


Steven Rostedt (2):
      tracing: show proper address for trace-printk format
      tracing: only truncate ftrace files when O_TRUNC is set

----
 kernel/trace/ftrace.c       |    4 ++--
 kernel/trace/trace.c        |    2 +-
 kernel/trace/trace_events.c |    2 +-
 kernel/trace/trace_printk.c |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
-- 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] tracing: show proper address for trace-printk format
  2009-07-23  3:35 [PATCH 0/2] [GIT PULL] tracing: various fixes Steven Rostedt
@ 2009-07-23  3:35 ` Steven Rostedt
  2009-07-23  3:35 ` [PATCH 2/2] tracing: only truncate ftrace files when O_TRUNC is set Steven Rostedt
  2009-07-23 14:06 ` [PATCH 0/2] [GIT PULL] tracing: various fixes Steven Rostedt
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-07-23  3:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker

[-- Attachment #1: 0001-tracing-show-proper-address-for-trace-printk-format.patch --]
[-- Type: text/plain, Size: 1202 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Since the trace_printk may use pointers to the format fields
in the buffer, they are exported via debugfs/tracing/printk_formats.
This is used by utilities that read the ring buffer in binary format.
It helps the utilities map the address of the format in the binary
buffer to what the printf format looks like.

Unfortunately, the way the output code works, it exports the address
of the pointer to the format address, and not the format address
itself. This makes the file totally useless in trying to figure
out what format string a binary address belongs to.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_printk.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c
index 7b62781..687699d 100644
--- a/kernel/trace/trace_printk.c
+++ b/kernel/trace/trace_printk.c
@@ -176,7 +176,7 @@ static int t_show(struct seq_file *m, void *v)
 	const char *str = *fmt;
 	int i;
 
-	seq_printf(m, "0x%lx : \"", (unsigned long)fmt);
+	seq_printf(m, "0x%lx : \"", *(unsigned long *)fmt);
 
 	/*
 	 * Tabs and new lines need to be converted.
-- 
1.6.3.3

-- 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] tracing: only truncate ftrace files when O_TRUNC is set
  2009-07-23  3:35 [PATCH 0/2] [GIT PULL] tracing: various fixes Steven Rostedt
  2009-07-23  3:35 ` [PATCH 1/2] tracing: show proper address for trace-printk format Steven Rostedt
@ 2009-07-23  3:35 ` Steven Rostedt
  2009-07-23 14:06 ` [PATCH 0/2] [GIT PULL] tracing: various fixes Steven Rostedt
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-07-23  3:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker

[-- Attachment #1: 0002-tracing-only-truncate-ftrace-files-when-O_TRUNC-is-s.patch --]
[-- Type: text/plain, Size: 2324 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

The current code will truncate the ftrace files contents if O_APPEND
is not set and the file is opened in write mode. This is incorrect.
It should only truncate the file if O_TRUNC is set. Otherwise
if one of these files is opened by a C program with fopen "r+",
it will incorrectly truncate the file.

Reported-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c       |    4 ++--
 kernel/trace/trace.c        |    2 +-
 kernel/trace/trace_events.c |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 24e3ff5..bb6b566 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1617,7 +1617,7 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable)
 
 	mutex_lock(&ftrace_regex_lock);
 	if ((file->f_mode & FMODE_WRITE) &&
-	    !(file->f_flags & O_APPEND))
+	    (file->f_flags & O_TRUNC))
 		ftrace_filter_reset(enable);
 
 	if (file->f_mode & FMODE_READ) {
@@ -2527,7 +2527,7 @@ ftrace_graph_open(struct inode *inode, struct file *file)
 
 	mutex_lock(&graph_lock);
 	if ((file->f_mode & FMODE_WRITE) &&
-	    !(file->f_flags & O_APPEND)) {
+	    (file->f_flags & O_TRUNC)) {
 		ftrace_graph_count = 0;
 		memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs));
 	}
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 38a4a3e..3a522a0 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2031,7 +2031,7 @@ static int tracing_open(struct inode *inode, struct file *file)
 
 	/* If this file was open for write, then erase contents */
 	if ((file->f_mode & FMODE_WRITE) &&
-	    !(file->f_flags & O_APPEND)) {
+	    (file->f_flags & O_TRUNC)) {
 		long cpu = (long) inode->i_private;
 
 		if (cpu == TRACE_PIPE_ALL_CPU)
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 90cf936..90cdec5 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -378,7 +378,7 @@ ftrace_event_seq_open(struct inode *inode, struct file *file)
 	const struct seq_operations *seq_ops;
 
 	if ((file->f_mode & FMODE_WRITE) &&
-	    !(file->f_flags & O_APPEND))
+	    (file->f_flags & O_TRUNC))
 		ftrace_clear_events();
 
 	seq_ops = inode->i_private;
-- 
1.6.3.3

-- 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] [GIT PULL] tracing: various fixes
  2009-07-23  3:35 [PATCH 0/2] [GIT PULL] tracing: various fixes Steven Rostedt
  2009-07-23  3:35 ` [PATCH 1/2] tracing: show proper address for trace-printk format Steven Rostedt
  2009-07-23  3:35 ` [PATCH 2/2] tracing: only truncate ftrace files when O_TRUNC is set Steven Rostedt
@ 2009-07-23 14:06 ` Steven Rostedt
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-07-23 14:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, Frederic Weisbecker


On Wed, 22 Jul 2009, Steven Rostedt wrote:

> 
> Ingo,
> 
> These two patches are built against my last push, but perhaps these
> should go to 2.6.31. The first one fixes a bug that makes the 
> printk_format file useless (making trace_bprintk useless for binary
> readers). The other is a bug with the way the files may be truncated
> incorrectly.

I may pull these over to urgent. They probably should go into 31.

I'll make another pull request there instead.

Thanks,

-- Steve

> 
> Please pull the latest tip/tracing/core-1 tree, which can be found at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tip/tracing/core-1
> 
> 
> Steven Rostedt (2):
>       tracing: show proper address for trace-printk format
>       tracing: only truncate ftrace files when O_TRUNC is set
> 
> ----
>  kernel/trace/ftrace.c       |    4 ++--
>  kernel/trace/trace.c        |    2 +-
>  kernel/trace/trace_events.c |    2 +-
>  kernel/trace/trace_printk.c |    2 +-
>  4 files changed, 5 insertions(+), 5 deletions(-)
> -- 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-23 14:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-23  3:35 [PATCH 0/2] [GIT PULL] tracing: various fixes Steven Rostedt
2009-07-23  3:35 ` [PATCH 1/2] tracing: show proper address for trace-printk format Steven Rostedt
2009-07-23  3:35 ` [PATCH 2/2] tracing: only truncate ftrace files when O_TRUNC is set Steven Rostedt
2009-07-23 14:06 ` [PATCH 0/2] [GIT PULL] tracing: various fixes Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox