]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
seq_file: fix big-enough lseek() + read()
authorAlexey Dobriyan <adobriyan@gmail.com>
Thu, 5 Feb 2009 21:30:05 +0000 (00:30 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 12 Feb 2009 17:50:35 +0000 (09:50 -0800)
commit f01d1d546abb2f4028b5299092f529eefb01253a upstream.

lseek() further than length of the file will leave stale ->index
(second-to-last during iteration). Next seq_read() will not notice
that ->f_pos is big enough to return 0, but will print last item
as if ->f_pos is pointing to it.

Introduced in commit cb510b8172602a66467f3551b4be1911f5a7c8c2
aka "seq_file: more atomicity in traverse()".

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/seq_file.c

index 9549b71737b085b699add03d964cbbe43ada7ff2..3404ec8269c0497245f131cca19046b968419695 100644 (file)
@@ -102,6 +102,7 @@ static int traverse(struct seq_file *m, loff_t offset)
                p = m->op->next(m, p, &index);
        }
        m->op->stop(m, p);
+       m->index = index;
        return error;
 
 Eoverflow: