linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] exfat: fix range validation error in alloc and free cluster
@ 2020-06-04  4:54 ` hyeongseok.kim
  2020-06-04  8:50   ` Sungjong Seo
  0 siblings, 1 reply; 3+ messages in thread
From: hyeongseok.kim @ 2020-06-04  4:54 UTC (permalink / raw)
  To: namjae.jeon, sj1557.seo; +Cc: linux-fsdevel, hyeongseok.kim

There is check error in range condition that can never be entered
even with invalid input.
Replace incorrent checking code with already existing valid checker.

Signed-off-by: hyeongseok.kim <hyeongseok@gmail.com>
---
 fs/exfat/fatent.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c
index 267e5e0..4e5c5c9 100644
--- a/fs/exfat/fatent.c
+++ b/fs/exfat/fatent.c
@@ -169,7 +169,7 @@ int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain)
 		return 0;
 
 	/* check cluster validation */
-	if (p_chain->dir < 2 && p_chain->dir >= sbi->num_clusters) {
+	if (!is_valid_cluster(sbi, p_chain->dir)) {
 		exfat_err(sb, "invalid start cluster (%u)", p_chain->dir);
 		return -EIO;
 	}
@@ -346,7 +346,7 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
 	}
 
 	/* check cluster validation */
-	if (hint_clu < EXFAT_FIRST_CLUSTER && hint_clu >= sbi->num_clusters) {
+	if (!is_valid_cluster(sbi, hint_clu)) {
 		exfat_err(sb, "hint_cluster is invalid (%u)",
 			hint_clu);
 		hint_clu = EXFAT_FIRST_CLUSTER;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] exfat: fix range validation error in alloc and free cluster
  2020-06-04  4:54 ` [PATCH] exfat: fix range validation error in alloc and free cluster hyeongseok.kim
@ 2020-06-04  8:50   ` Sungjong Seo
  2020-06-05  7:53     ` Namjae Jeon
  0 siblings, 1 reply; 3+ messages in thread
From: Sungjong Seo @ 2020-06-04  8:50 UTC (permalink / raw)
  To: 'hyeongseok.kim', namjae.jeon; +Cc: linux-fsdevel

> There is check error in range condition that can never be entered even
> with invalid input.
> Replace incorrent checking code with already existing valid checker.
> 
> Signed-off-by: hyeongseok.kim <hyeongseok@gmail.com>

Acked-by: Sungjong Seo <sj1557.seo@samsung.com>

Looks good. Thank you!

> ---
>  fs/exfat/fatent.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index 267e5e0..4e5c5c9
> 100644
> --- a/fs/exfat/fatent.c
> +++ b/fs/exfat/fatent.c
> @@ -169,7 +169,7 @@ int exfat_free_cluster(struct inode *inode, struct
> exfat_chain *p_chain)
>  		return 0;
> 
>  	/* check cluster validation */
> -	if (p_chain->dir < 2 && p_chain->dir >= sbi->num_clusters) {
> +	if (!is_valid_cluster(sbi, p_chain->dir)) {
>  		exfat_err(sb, "invalid start cluster (%u)", p_chain->dir);
>  		return -EIO;
>  	}
> @@ -346,7 +346,7 @@ int exfat_alloc_cluster(struct inode *inode, unsigned
> int num_alloc,
>  	}
> 
>  	/* check cluster validation */
> -	if (hint_clu < EXFAT_FIRST_CLUSTER && hint_clu >= sbi->num_clusters)
> {
> +	if (!is_valid_cluster(sbi, hint_clu)) {
>  		exfat_err(sb, "hint_cluster is invalid (%u)",
>  			hint_clu);
>  		hint_clu = EXFAT_FIRST_CLUSTER;
> --
> 2.7.4



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] exfat: fix range validation error in alloc and free cluster
  2020-06-04  8:50   ` Sungjong Seo
@ 2020-06-05  7:53     ` Namjae Jeon
  0 siblings, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2020-06-05  7:53 UTC (permalink / raw)
  To: 'hyeongseok.kim'; +Cc: linux-fsdevel, 'Sungjong Seo'

> 
> > There is check error in range condition that can never be entered even
> > with invalid input.
> > Replace incorrent checking code with already existing valid checker.
> >
> > Signed-off-by: hyeongseok.kim <hyeongseok@gmail.com>
> 
> Acked-by: Sungjong Seo <sj1557.seo@samsung.com>
> 
> Looks good. Thank you!
Applied. Thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-05  7:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20200604045437epcas1p17180ef9b61d8ff1d4877c49755e766a2@epcas1p1.samsung.com>
2020-06-04  4:54 ` [PATCH] exfat: fix range validation error in alloc and free cluster hyeongseok.kim
2020-06-04  8:50   ` Sungjong Seo
2020-06-05  7:53     ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).