Commit 13940cef authored by Yuezhang Mo's avatar Yuezhang Mo Committed by Namjae Jeon
Browse files

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: default avatarYuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
parent fda94a99
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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)",