lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Tue, 25 Jul 2023 21:50:44 +0530
From:   Manas Ghandat <ghandatmanas@...il.com>
To:     salah.triki@...il.com, luisbg@...nel.org
Cc:     Manas Ghandat <ghandatmanas@...il.com>,
        linux-kernel@...r.kernel.org, shuah@...nel.org,
        ivan.orlov0322@...il.com
Subject: [PATCH] fs : fix shift-out-of-bounds in befs_check_sb

The consistency check for the block_size by using the block_shift caused
integer overflow. Thus a max limit to the block_shift was defined named
BEFS_MAX_BLOCK_SHIFT in befs.h. Also check for the block_shift was added
so that overflow does not occur.

Signed-off-by: Manas Ghandat <ghandatmanas@...il.com>
---
 fs/befs/befs.h  |  4 ++--
 fs/befs/super.c | 11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/befs/befs.h b/fs/befs/befs.h
index 7cd47245694d..5490024adb33 100644
--- a/fs/befs/befs.h
+++ b/fs/befs/befs.h
@@ -13,7 +13,7 @@
 
 /* used in debug.c */
 #define BEFS_VERSION "0.9.3"
-
+#define BEFS_MAX_BLOCK_SHIFT 31
 
 typedef u64 befs_blocknr_t;
 /*
@@ -133,7 +133,7 @@ blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
 
 	iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
 	iaddr.start =
-	    blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
+		blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
 	iaddr.len = 1;
 
 	return iaddr;
diff --git a/fs/befs/super.c b/fs/befs/super.c
index 7c50025c99d8..f2aeb2ed6e77 100644
--- a/fs/befs/super.c
+++ b/fs/befs/super.c
@@ -88,6 +88,17 @@ befs_check_sb(struct super_block *sb)
 		return BEFS_ERR;
 	}
 
+	/*
+	 * block_shift check added so that overflow does not
+	 * occur during the block_size check
+	 */
+
+	if (befs_sb->block_shift > BEFS_MAX_BLOCK_SHIFT) {
+		befs_error(sb, "block_size too large. "
+			   "Corruption likely.");
+		return BEFS_ERR;
+	}
+
 	/*
 	 * block_shift and block_size encode the same information
 	 * in different ways as a consistency check.
-- 
2.37.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ