diff options
author | Yuezhang Mo <Yuezhang.Mo@sony.com> | 2025-02-08 17:16:58 +0800 |
---|---|---|
committer | Namjae Jeon <linkinjeon@kernel.org> | 2025-03-05 21:53:20 +0900 |
commit | 13940cef95491472760ca261b6713692ece9b946 (patch) | |
tree | 8fb2557a5098d5dcf2824de92525c46fdabd872a | |
parent | fda94a9919fd632033979ad7765a99ae3cab9289 (diff) | |
download | linux-13940cef95491472760ca261b6713692ece9b946.tar.gz linux-13940cef95491472760ca261b6713692ece9b946.tar.bz2 linux-13940cef95491472760ca261b6713692ece9b946.zip |
exfat: add a check for invalid data size
Add a check for invalid data size to avoid corrupted filesystem
from being further corrupted.
Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
-rw-r--r-- | fs/exfat/namei.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 5b16181a4c2e..8b30027d8251 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -646,6 +646,11 @@ static int exfat_find(struct inode *dir, struct qstr *qname, info->valid_size = le64_to_cpu(ep2->dentry.stream.valid_size); info->size = le64_to_cpu(ep2->dentry.stream.size); + if (unlikely(EXFAT_B_TO_CLU_ROUND_UP(info->size, sbi) > sbi->used_clusters)) { + exfat_fs_error(sb, "data size is invalid(%lld)", info->size); + return -EIO; + } + info->start_clu = le32_to_cpu(ep2->dentry.stream.start_clu); if (!is_valid_cluster(sbi, info->start_clu) && info->size) { exfat_warn(sb, "start_clu is invalid cluster(0x%x)", |