From: Konstantin Komarov Date: Tue, 23 Apr 2024 14:21:58 +0000 (+0300) Subject: fs/ntfs3: Break dir enumeration if directory contents error X-Git-Tag: v5.15.161~373 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=98740ae2b361f3cd848ab91b7c977b9c99dc4292;p=thirdparty%2Fkernel%2Fstable.git fs/ntfs3: Break dir enumeration if directory contents error commit 302e9dca8428979c9c99f2dbb44dc1783f5011c3 upstream. If we somehow attempt to read beyond the directory size, an error is supposed to be returned. However, in some cases, read requests do not stop and instead enter into a loop. To avoid this, we set the position in the directory to the end. Signed-off-by: Konstantin Komarov Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index 72cdfa8727d3c..98f57d0c702eb 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -475,6 +475,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *ctx) vbo = (u64)bit << index_bits; if (vbo >= i_size) { ntfs_inode_err(dir, "Looks like your dir is corrupt"); + ctx->pos = eod; err = -EINVAL; goto out; }