seq_file: fix incomplete reset on read from zero offset
authorMiklos Szeredi <mszeredi@redhat.com>
Wed, 15 Nov 2017 10:34:58 +0000 (11:34 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Feb 2018 14:42:28 +0000 (15:42 +0100)
commit29b4af70409cfca62d045cd4e0170912ab262c66
treeb97abcbd943f432e07887b161621d0128a16cfb6
parent0f0fd00739118302568ff8b57ddfc5898c1a3796
seq_file: fix incomplete reset on read from zero offset

commit cf5eebae2cd28d37581507668605f4d23cd7218d upstream.

When resetting iterator on a zero offset we need to discard any data
already in the buffer (count), and private state of the iterator (version).

For example this bug results in first line being repeated in /proc/mounts
if doing a zero size read before a non-zero size read.

Reported-by: Rich Felker <dalias@libc.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: e522751d605d ("seq_file: reset iterator to first record for zero offset")
Cc: <stable@vger.kernel.org> # v4.10
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/seq_file.c