android_kernel_xiaomi_sm8450/fs/exfat
Yuezhang Mo 34b0588341 exfat: fix reporting fs error when reading dir beyond EOF
commit 706fdcac002316893434d753be8cfb549fe1d40d upstream.

Since seekdir() does not check whether the position is valid, the
position may exceed the size of the directory. We found that for
a directory with discontinuous clusters, if the position exceeds
the size of the directory and the excess size is greater than or
equal to the cluster size, exfat_readdir() will return -EIO,
causing a file system error and making the file system unavailable.

Reproduce this bug by:

seekdir(dir, dir_size + cluster_size);
dirent = readdir(dir);

The following log will be printed if mount with 'errors=remount-ro'.

[11166.712896] exFAT-fs (sdb1): error, invalid access to FAT (entry 0xffffffff)
[11166.712905] exFAT-fs (sdb1): Filesystem has been set read-only

Fixes: 1e5654de0f51 ("exfat: handle wrong stream entry size in exfat_readdir()")
Cc: stable@vger.kernel.org # v5.7+
Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Andy Wu <Andy.Wu@sony.com>
Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com>
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-03-11 16:39:56 +01:00
..
balloc.c exfat: check if cluster num is valid 2022-06-06 08:42:42 +02:00
cache.c exfat: fix use of uninitialized spinlock on error path 2020-10-07 14:27:13 +09:00
dir.c exfat: fix reporting fs error when reading dir beyond EOF 2023-03-11 16:39:56 +01:00
exfat_fs.h exfat: check if cluster num is valid 2022-06-06 08:42:42 +02:00
exfat_raw.h exfat: fix shift-out-of-bounds in exfat_fill_super() 2021-03-04 11:38:41 +01:00
fatent.c exfat: check if cluster num is valid 2022-06-06 08:42:42 +02:00
file.c exfat: fix i_blocks for files truncated over 4 GiB 2022-03-08 19:09:30 +01:00
inode.c exfat: fix i_blocks for files truncated over 4 GiB 2022-03-08 19:09:30 +01:00
Kconfig exfat: Improve wording of EXFAT_DEFAULT_IOCHARSET config option 2020-06-09 16:48:39 +09:00
Makefile exfat: add Kconfig and Makefile 2020-03-05 21:00:40 -05:00
misc.c exfat: write multiple sectors at once 2020-08-12 08:31:11 +09:00
namei.c exfat: reuse exfat_inode_info variable instead of calling EXFAT_I() 2022-03-08 19:09:30 +01:00
nls.c exfat: Avoid allocating upcase table using kcalloc() 2020-12-26 16:02:38 +01:00
super.c exfat: avoid incorrectly releasing for root inode 2022-03-28 09:57:07 +02:00