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: nvme-6.10-2024-06-05~28^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=302e9dca8428979c9c99f2dbb44dc1783f5011c3;p=nvme.git fs/ntfs3: Break dir enumeration if directory contents error 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 --- diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index 5cf3d9decf64..45e556fd7c54 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; }