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

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