Skip to contentSkip to conversation

t_next should increase position index

PATCH Superseded Vasily Averin 2 participants 3 messages Jan 24, 2020 – Jan 30, 2020

Subsystems (2)

v1 of 3 Superseded 3 of 7 applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 3/7 t_next should increase position index

if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.

https://bugzilla.kernel.org/show_bug.cgi?id=206283

---
 kernel/trace/ftrace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/ftrace.c +3 -1
index 9bf1f2c..ca25210 100644
@@ -3442,8 +3442,10 @@ static void *t_mod_start(struct seq_file *m, loff_t *pos)
 	loff_t l = *pos; /* t_probe_start() must use original pos */
 	void *ret;
 
-	if (unlikely(ftrace_disabled))
+	if (unlikely(ftrace_disabled)) {
+		(*pos)++;
 		return NULL;
+	}
 
 	if (iter->flags & FTRACE_ITER_PROBE)
 		return t_probe_next(m, pos);
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 14 lines · On Fri, 24 Jan 2020 10:02:51 +0300 Vasily Averin <[email protected]> wrote:

if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.

https://bugzilla.kernel.org/show_bug.cgi?id=206283

---
 kernel/trace/ftrace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/ftrace.c +0 -0
index 9bf1f2c..ca25210 100644

kernel/trace/ftrace.c static void *t_mod_start(struct seq_file *m, loff_t *pos) · line 3448

Quoted 8 lines
kernel/trace/ftrace.c +3 -1
@@ -3442,8 +3442,10 @@ static void *t_mod_start(struct seq_file *m, loff_t *pos)
 	loff_t l = *pos; /* t_probe_start() must use original pos */
 	void *ret;
 
-	if (unlikely(ftrace_disabled))
+	if (unlikely(ftrace_disabled)) {
+		(*pos)++;
 		return NULL;
+	}

This isn't needed. If ftrace_disabled is set, we shouldn't be printing anything. This case isn't the same as the report in the bugzilla.

-- Steve

Quoted 3 lines
kernel/trace/ftrace.c +0 -0
 	if (iter->flags & FTRACE_ITER_PROBE)
 		return t_probe_next(m, pos);
#2 lore raw
Quoted 20 lines · Steven Rostedt
Quoted 17 lines · On Fri, 24 Jan 2020 10:02:51 +0300 Vasily Averin <[email protected]> wrote:

if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.

https://bugzilla.kernel.org/show_bug.cgi?id=206283

---
 kernel/trace/ftrace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/ftrace.c +0 -0
index 9bf1f2c..ca25210 100644
@@ -3442,8 +3442,10 @@ static void *t_mod_start(struct seq_file *m, loff_t *pos)
 	loff_t l = *pos; /* t_probe_start() must use original pos */
 	void *ret;
 
Quoted 8 lines

kernel/trace/ftrace.c static void *t_mod_start(struct seq_file *m, loff_t *pos) · line 3448

Quoted 5 lines
kernel/trace/ftrace.c +3 -1
-	if (unlikely(ftrace_disabled))
+	if (unlikely(ftrace_disabled)) {
+		(*pos)++;
 		return NULL;
+	}

This isn't needed. If ftrace_disabled is set, we shouldn't be printing anything. This case isn't the same as the report in the bugzilla.

I'm agree, thank you, let's drop this patch.

Vasily Averin