Skip to content

Commit e4075e8

Browse files
vaverinrostedt
authored andcommitted
ftrace: fpid_next() should increase position index
if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output. Without patch: # dd bs=4 skip=1 if=/sys/kernel/tracing/set_ftrace_pid dd: /sys/kernel/tracing/set_ftrace_pid: cannot skip to specified offset id no pid 2+1 records in 2+1 records out 10 bytes copied, 0.000213285 s, 46.9 kB/s Notice the "id" followed by "no pid". With the patch: # dd bs=4 skip=1 if=/sys/kernel/tracing/set_ftrace_pid dd: /sys/kernel/tracing/set_ftrace_pid: cannot skip to specified offset id 0+1 records in 0+1 records out 3 bytes copied, 0.000202112 s, 14.8 kB/s Notice that it only prints "id" and not the "no pid" afterward. Link: http://lkml.kernel.org/r/4f87c6ad-f114-30bb-8506-c32274ce2992@virtuozzo.com https://bugzilla.kernel.org/show_bug.cgi?id=206283 Signed-off-by: Vasily Averin <vvs@virtuozzo.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 64ae572 commit e4075e8

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎kernel/trace/ftrace.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7026,9 +7026,10 @@ static void *fpid_next(struct seq_file *m, void *v, loff_t *pos)
70267026
struct trace_array *tr = m->private;
70277027
struct trace_pid_list *pid_list = rcu_dereference_sched(tr->function_pids);
70287028

7029-
if (v == FTRACE_NO_PIDS)
7029+
if (v == FTRACE_NO_PIDS) {
7030+
(*pos)++;
70307031
return NULL;
7031-
7032+
}
70327033
return trace_pid_next(pid_list, v, pos);
70337034
}
70347035

0 commit comments

Comments
 (0)