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]
Date:	Mon, 30 Jan 2012 00:01:04 +0800
From:	Yongqiang Yang <xiaoqiangnk@...il.com>
To:	linux-ext4@...r.kernel.org
Cc:	adilger@...il.com, Yongqiang Yang <xiaoqiangnk@...il.com>
Subject: [PATCH 2/4] ext4: fix a bug in resize when first_data_block != 0

ext4_group_first_block_no should be used to computer block offset and
first block no in group rather than group * block_per_group. Otherwise,
if first_data_block != 0, the result is wrong.

Signed-off-by: Yongqiang Yang <xiaoqiangnk@...il.com>
---
 fs/ext4/resize.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 9a6fb74..58109fa 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -956,7 +956,6 @@ static void update_backups(struct super_block *sb,
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	const ext4_group_t last = sbi->s_groups_count;
-	const int bpg = EXT4_BLOCKS_PER_GROUP(sb);
 	unsigned three = 1;
 	unsigned five = 5;
 	unsigned seven = 7;
@@ -982,7 +981,8 @@ static void update_backups(struct super_block *sb,
 		    (err = ext4_journal_restart(handle, EXT4_MAX_TRANS_DATA)))
 			break;
 
-		bh = sb_getblk(sb, group * bpg + blk_off);
+		bh = sb_getblk(sb, ext4_group_first_block_no(sb, group) +
+				   blk_off);
 		if (!bh) {
 			err = -EIO;
 			break;
@@ -1291,15 +1291,17 @@ exit_journal:
 
 	if (!err) {
 		int i;
-		update_backups(sb, sbi->s_sbh->b_blocknr, (char *)es,
-			       sizeof(struct ext4_super_block));
+		ext4_fsblk_t first_block;
+		first_block = ext4_group_first_block_no(sb, 0);
+		update_backups(sb, sbi->s_sbh->b_blocknr - first_block,
+			       (char *)es, sizeof(struct ext4_super_block));
 		for (i = 0; i < flex_gd->count; i++, group++) {
 			struct buffer_head *gdb_bh;
 			int gdb_num;
 			gdb_num = group / EXT4_BLOCKS_PER_GROUP(sb);
 			gdb_bh = sbi->s_group_desc[gdb_num];
-			update_backups(sb, gdb_bh->b_blocknr, gdb_bh->b_data,
-				       gdb_bh->b_size);
+			update_backups(sb, gdb_bh->b_blocknr - first_block,
+				       gdb_bh->b_data, gdb_bh->b_size);
 		}
 	}
 exit:
-- 
1.7.5.1

--
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