Skip to content

Commit 13940ce

Browse files
YuezhangMonamjaejeon
authored andcommitted
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>
1 parent fda94a9 commit 13940ce

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
@@ -646,6 +646,11 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
646646
info->valid_size = le64_to_cpu(ep2->dentry.stream.valid_size);
647647
info->size = le64_to_cpu(ep2->dentry.stream.size);
648648

649+
if (unlikely(EXFAT_B_TO_CLU_ROUND_UP(info->size, sbi) > sbi->used_clusters)) {
650+
exfat_fs_error(sb, "data size is invalid(%lld)", info->size);
651+
return -EIO;
652+
}
653+
649654
info->start_clu = le32_to_cpu(ep2->dentry.stream.start_clu);
650655
if (!is_valid_cluster(sbi, info->start_clu) && info->size) {
651656
exfat_warn(sb, "start_clu is invalid cluster(0x%x)",

0 commit comments

Comments
 (0)