Skip to content

Commit 9207575

Browse files
YuezhangMogregkh
authored andcommitted
exfat: add a check for invalid data size
[ Upstream commit 13940ce ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 77a5ed6 commit 9207575

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/exfat/namei.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,11 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
639639
info->valid_size = le64_to_cpu(ep2->dentry.stream.valid_size);
640640
info->size = le64_to_cpu(ep2->dentry.stream.size);
641641

642+
if (unlikely(EXFAT_B_TO_CLU_ROUND_UP(info->size, sbi) > sbi->used_clusters)) {
643+
exfat_fs_error(sb, "data size is invalid(%lld)", info->size);
644+
return -EIO;
645+
}
646+
642647
info->start_clu = le32_to_cpu(ep2->dentry.stream.start_clu);
643648
if (!is_valid_cluster(sbi, info->start_clu) && info->size) {
644649
exfat_warn(sb, "start_clu is invalid cluster(0x%x)",

0 commit comments

Comments
 (0)