Subject: [PATCH 1417/2944] jbd2_seq_info_next should increase position index

From: Vasily Averin <[email-masked]>
Date: Thu, 23 Jan 2020 12:05:10 +0300

task #28557737

commit 1a8e9cf40c9a6a2e40b1e924b13ed303aeea4418 upstream.

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

Script below generates endless output
 $ q=;while read -r r;do echo "$((++q)) $r";done </proc/fs/jbd2/DEV/info

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

Fixes: 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface")
Cc: [email-masked]
Signed-off-by: Vasily Averin <[email-masked]>
Reviewed-by: Jan Kara <[email-masked]>
Link: https://lore.kernel.org/r/[email-masked]
Signed-off-by: Theodore Ts'o <[email-masked]>
Signed-off-by: Greg Kroah-Hartman <[email-masked]>
Signed-off-by: Jeffle Xu <[email-masked]>
Acked-by: Joseph Qi <[email-masked]>
---
 fs/jbd2/journal.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index f522bf4..1a4eb14 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1057,6 +1057,7 @@ static void *jbd2_seq_info_start(struct seq_file *seq, loff_t *pos)
 
 static void *jbd2_seq_info_next(struct seq_file *seq, void *v, loff_t *pos)
 {
+	(*pos)++;
 	return NULL;
 }
 
-- 
1.8.3.1