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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1358068095-9034-2-git-send-email-wenqing.lz@taobao.com>
Date:	Sun, 13 Jan 2013 17:08:14 +0800
From:	Zheng Liu <gnehzuil.liu@...il.com>
To:	linux-ext4@...r.kernel.org
Cc:	Zheng Liu <wenqing.lz@...bao.com>
Subject: [PATCH 2/3] mke2fs: reduce the range of cluster-size

From: Zheng Liu <wenqing.lz@...bao.com>

There are two bugs need to be fixed, which are about cluster-size.  Now the
range of cluster-size is from 1024 to 512M bytes.  Although with '-C 1024',
the cluster-size will be 4096 after making a filesystem because in
ext2fs_initialize() set_field() needs to check 'param->s_log_cluster_size' and
s_log_cluster_size is 0 as cluster-size is 1024.  Then s_log_cluster_size will
be assigned to s_log_block_size+4.  So we never set cluster-size to 1024.

Another bug is that when cluster-size is 512M EXT2FS_C2B will return 0.  So
s_blocks_per_group will be assigned to zero and we will meet a 'division by
zero' error.

Here we reduce the range of cluster-size and check s_blocks_per_group=0 to avoid
'division by zero' error.

Signed-off-by: Zheng Liu <wenqing.lz@...bao.com>
---
 lib/ext2fs/initialize.c | 4 ++++
 misc/mke2fs.c           | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index dca0d9a..0eccd59 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -226,6 +226,10 @@ errcode_t ext2fs_initialize(const char *name, int flags,
 			super->s_clusters_per_group = EXT2_MAX_CLUSTERS_PER_GROUP(super);
 		super->s_blocks_per_group = EXT2FS_C2B(fs,
 				       super->s_clusters_per_group);
+		if (super->s_blocks_per_group == 0) {
+			retval = EXT2_ET_TOOSMALL;
+			goto cleanup;
+		}
 	} else {
 		set_field(s_blocks_per_group, fs->blocksize * 8);
 		if (super->s_blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(super))
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index bf4d7a2..f4140a1 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1384,8 +1384,8 @@ profile_error:
 			break;
 		case 'C':
 			cluster_size = strtoul(optarg, &tmp, 0);
-			if (cluster_size < EXT2_MIN_CLUSTER_SIZE ||
-			    cluster_size > EXT2_MAX_CLUSTER_SIZE || *tmp) {
+			if (cluster_size <= EXT2_MIN_CLUSTER_SIZE ||
+			    cluster_size >= EXT2_MAX_CLUSTER_SIZE || *tmp) {
 				com_err(program_name, 0,
 					_("invalid cluster size - %s"),
 					optarg);
-- 
1.7.12.rc2.18.g61b472e

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ