fat: fix fake_offset handling on error path
fat: fix fake_offset handling on error path

For the root directory, .  and ..  are faked (using dir_emit_dots()) and
ctx->pos is reset from 2 to 0.

A corrupted root directory could cause fat_get_entry() to fail, but
->iterate() (fat_readdir()) reports progress to the VFS (with ctx->pos
rewound to 0), so any following calls to ->iterate() continue to return
the same entries again and again.

The result is that userspace will never see the end of the directory,
causing e.g.  'ls' to hang in a getdents() loop.

[1dd685eef08048be95744a1b104ca593a93cc914@mail.parknet.co.jp: cleanup and make sure to correct fake_offset]
Reported-by: Vegard Nossum <c9abf7248a519119ccb31f4fd3c3a4e0b6ebd20b@oracle.com>
Tested-by: Vegard Nossum <c9abf7248a519119ccb31f4fd3c3a4e0b6ebd20b@oracle.com>
Signed-off-by: Richard Weinberger <a27366f0c35e42b402be5a128349bd1963d6dd0d@gmail.com>
Signed-off-by: OGAWA Hirofumi <1dd685eef08048be95744a1b104ca593a93cc914@mail.parknet.co.jp>
Cc: <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs