Blame SOURCES/0037-exfat-fix-range-validation-error-in-alloc-and-free-c.patch

Kmods SIG 9e3ffb
From a949824f01f3b39f737d77aed6cba47aced09319 Mon Sep 17 00:00:00 2001
Kmods SIG 9e3ffb
From: "hyeongseok.kim" <hyeongseok@gmail.com>
Kmods SIG 9e3ffb
Date: Thu, 4 Jun 2020 13:54:28 +0900
Kmods SIG 9e3ffb
Subject: [Backport a949824f01f3] exfat: fix range validation error in alloc
Kmods SIG 9e3ffb
 and free cluster
Kmods SIG 9e3ffb
Kmods SIG 9e3ffb
There is check error in range condition that can never be entered
Kmods SIG 9e3ffb
even with invalid input.
Kmods SIG 9e3ffb
Replace incorrent checking code with already existing valid checker.
Kmods SIG 9e3ffb
Kmods SIG 9e3ffb
Signed-off-by: hyeongseok.kim <hyeongseok@gmail.com>
Kmods SIG 9e3ffb
Acked-by: Sungjong Seo <sj1557.seo@samsung.com>
Kmods SIG 9e3ffb
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Kmods SIG 9e3ffb
---
Kmods SIG 9e3ffb
 src/fatent.c | 4 ++--
Kmods SIG 9e3ffb
 1 file changed, 2 insertions(+), 2 deletions(-)
Kmods SIG 9e3ffb
Kmods SIG 9e3ffb
diff --git a/src/fatent.c b/src/fatent.c
Kmods SIG 9e3ffb
index 267e5e09eb134c34990ac2d5ce17e2692c955be8..4e5c5c9c0f2df4457670dfeb14f30bfbcbd32a5d 100644
Kmods SIG 9e3ffb
--- a/src/fatent.c
Kmods SIG 9e3ffb
+++ b/src/fatent.c
Kmods SIG 9e3ffb
@@ -169,7 +169,7 @@ int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain)
Kmods SIG 9e3ffb
 		return 0;
Kmods SIG 9e3ffb
 
Kmods SIG 9e3ffb
 	/* check cluster validation */
Kmods SIG 9e3ffb
-	if (p_chain->dir < 2 && p_chain->dir >= sbi->num_clusters) {
Kmods SIG 9e3ffb
+	if (!is_valid_cluster(sbi, p_chain->dir)) {
Kmods SIG 9e3ffb
 		exfat_err(sb, "invalid start cluster (%u)", p_chain->dir);
Kmods SIG 9e3ffb
 		return -EIO;
Kmods SIG 9e3ffb
 	}
Kmods SIG 9e3ffb
@@ -346,7 +346,7 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
Kmods SIG 9e3ffb
 	}
Kmods SIG 9e3ffb
 
Kmods SIG 9e3ffb
 	/* check cluster validation */
Kmods SIG 9e3ffb
-	if (hint_clu < EXFAT_FIRST_CLUSTER && hint_clu >= sbi->num_clusters) {
Kmods SIG 9e3ffb
+	if (!is_valid_cluster(sbi, hint_clu)) {
Kmods SIG 9e3ffb
 		exfat_err(sb, "hint_cluster is invalid (%u)",
Kmods SIG 9e3ffb
 			hint_clu);
Kmods SIG 9e3ffb
 		hint_clu = EXFAT_FIRST_CLUSTER;
Kmods SIG 9e3ffb
-- 
Kmods SIG 9e3ffb
2.31.1
Kmods SIG 9e3ffb