]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ubifs: Abort readdir upon error
authorRichard Weinberger <richard@nod.at>
Wed, 19 Oct 2016 10:43:07 +0000 (12:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Feb 2017 10:03:27 +0000 (11:03 +0100)
commit1bf1f0c778877f2ba2f1a638a0646c851d47c393
treecccdbf9b7e5f81a925e504cc8f2a277106d91f47
parentd414505f516ba5af6ef5699a1cc702591bce0d9f
ubifs: Abort readdir upon error

commit c83ed4c9dbb358b9e7707486e167e940d48bfeed upstream.

If UBIFS is facing an error while walking a directory, it reports this
error and ubifs_readdir() returns the error code. But the VFS readdir
logic does not make the getdents system call fail in all cases. When the
readdir cursor indicates that more entries are present, the system call
will just return and the libc wrapper will try again since it also
knows that more entries are present.
This causes the libc wrapper to busy loop for ever when a directory is
corrupted on UBIFS.
A common approach do deal with corrupted directory entries is
skipping them by setting the cursor to the next entry. On UBIFS this
approach is not possible since we cannot compute the next directory
entry cursor position without reading the current entry. So all we can
do is setting the cursor to the "no more entries" position and make
getdents exit.

Signed-off-by: Richard Weinberger <richard@nod.at>
[wt: adjusted context]

Signed-off-by: Willy Tarreau <w@1wt.eu>
fs/ubifs/dir.c