This is a note to let you know that I've just added the patch titled exfat: fix unexpected EOF while reading dir to the 6.2-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: exfat-fix-unexpected-eof-while-reading-dir.patch and it can be found in the queue-6.2 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 6cb5d1a16a51d080fbc1649a5144cbc5ca7d6f88 Mon Sep 17 00:00:00 2001 From: Yuezhang Mo <Yuezhang.Mo@xxxxxxxx> Date: Thu, 22 Sep 2022 14:43:47 +0800 Subject: exfat: fix unexpected EOF while reading dir From: Yuezhang Mo <Yuezhang.Mo@xxxxxxxx> commit 6cb5d1a16a51d080fbc1649a5144cbc5ca7d6f88 upstream. If the position is not aligned with the dentry size, the return value of readdir() will be NULL and errno is 0, which means the end of the directory stream is reached. If the position is aligned with dentry size, but there is no file or directory at the position, exfat_readdir() will continue to get dentry from the next dentry. So the dentry gotten by readdir() may not be at the position. After this commit, if the position is not aligned with the dentry size, round the position up to the dentry size and continue to get the dentry. Fixes: ca06197382bd ("exfat: add directory operations") Cc: stable@xxxxxxxxxxxxxxx # v5.7+ Reported-by: Wang Yugui <wangyugui@xxxxxxxxxxxx> Signed-off-by: Yuezhang Mo <Yuezhang.Mo@xxxxxxxx> Reviewed-by: Andy Wu <Andy.Wu@xxxxxxxx> Reviewed-by: Aoyama Wataru <wataru.aoyama@xxxxxxxx> Reviewed-by: Sungjong Seo <sj1557.seo@xxxxxxxxxxx> Signed-off-by: Namjae Jeon <linkinjeon@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/exfat/dir.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -234,10 +234,7 @@ static int exfat_iterate(struct file *fi fake_offset = 1; } - if (cpos & (DENTRY_SIZE - 1)) { - err = -ENOENT; - goto unlock; - } + cpos = round_up(cpos, DENTRY_SIZE); /* name buffer should be allocated before use */ err = exfat_alloc_namebuf(nb); Patches currently in stable-queue which might be from Yuezhang.Mo@xxxxxxxx are queue-6.2/exfat-fix-reporting-fs-error-when-reading-dir-beyond-eof.patch queue-6.2/exfat-fix-inode-i_blocks-for-non-512-byte-sector-size-device.patch queue-6.2/exfat-fix-unexpected-eof-while-reading-dir.patch queue-6.2/exfat-redefine-dir_deleted-as-the-bad-cluster-number.patch