Skip to contentSkip to conversation

tracing: various fixes

GIT PULL New Steven Rostedt 1 participant 4 messages Jul 23, 2009

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

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(-)
author maintainer
#1 lore raw

PATCH 1/2 tracing: show proper address for trace-printk format

From: Steven Rostedt <[email protected]>

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.

---
 kernel/trace/trace_printk.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/trace_printk.c +1 -1
index 7b62781..687699d 100644
@@ -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.
Signature · 3 lines
1.6.3.3

-- 
author maintainer
#2 lore raw

PATCH 2/2 tracing: only truncate ftrace files when O_TRUNC is set

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

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.

---
 kernel/trace/ftrace.c       |    4 ++--
 kernel/trace/trace.c        |    2 +-
 kernel/trace/trace_events.c |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
kernel/trace/ftrace.c +2 -2
index 24e3ff5..bb6b566 100644
@@ -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));
 	}
kernel/trace/trace.c +1 -1
index 38a4a3e..3a522a0 100644
@@ -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)
kernel/trace/trace_events.c +1 -1
index 90cf936..90cdec5 100644
@@ -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;
Signature · 3 lines
1.6.3.3

-- 
author maintainer
#3 lore raw
In reply to Steven Rostedt
Quoted 8 lines · Steven Rostedt

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

Quoted 19 lines

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(-)