Skip to contentSkip to conversation

e2fsck: check htree leaf block checksums

PATCH Applied Darrick J. Wong 2 participants 2 messages Jun 22, 2015 – Jul 22, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 e2fsck: check htree leaf block checksums

We weren't verifying the checksum of an htree leaf block due to a coding error that marked all htree blocks as not having checksums. While we're at it, fix the error message that gets displayed so that it doesn't print a meaningless block offset.

---
 e2fsck/pass2.c                   |    2 +-
 e2fsck/problem.c                 |    2 +-
 tests/f_dir_bad_csum/expect.1    |    2 +-
 tests/f_htree_leaf_csum/expect.1 |   12 ++++++++++++
 tests/f_htree_leaf_csum/expect.2 |    7 +++++++
 tests/f_htree_leaf_csum/image.gz |  Bin
 tests/f_htree_leaf_csum/name     |    1 +
 7 files changed, 23 insertions(+), 3 deletions(-)
 create mode 100644 tests/f_htree_leaf_csum/expect.1
 create mode 100644 tests/f_htree_leaf_csum/expect.2
 create mode 100644 tests/f_htree_leaf_csum/image.gz
 create mode 100644 tests/f_htree_leaf_csum/name
e2fsck/pass2.c +1 -1
index ecc0aaa..3a91e98 100644
@@ -1085,7 +1085,7 @@ inline_read_fail:
 			    ((fs->blocksize - (8 + dx_csum_size)) /
 			     sizeof(struct ext2_dx_entry))))
 			dx_db->type = DX_DIRBLOCK_NODE;
-		is_leaf = 0;
+		is_leaf = (dx_db->type == DX_DIRBLOCK_LEAF);
 	}
 out_htree:
 #endif /* ENABLE_HTREE */
e2fsck/problem.c +1 -1
index 80c6492..5916d01 100644
@@ -1597,7 +1597,7 @@ static struct e2fsck_problem problem_table[] = {
 
 	/* leaf node passes checks but fails checksum */
 	{ PR_2_LEAF_NODE_ONLY_CSUM_INVALID,
-	  N_("@d @i %i, %B, offset %N: @d passes checks but fails checksum.\n"),
+	  N_("@d @i %i, %B: @d passes checks but fails checksum.\n"),
 	  PROMPT_FIX, PR_PREEN_OK },
 
 	/* inline directory inode size must be a multiple of 4 */
tests/f_dir_bad_csum/expect.1 +1 -1
index b2b2fae..94e72da 100644
@@ -1,6 +1,6 @@
 Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
-Directory inode 12, block #0, offset 12: directory passes checks but fails checksum.
+Directory inode 12, block #0: directory passes checks but fails checksum.
 Fix? yes
 
 Directory inode 13, block #0, offset 0: directory has no checksum.
tests/f_htree_leaf_csum/expect.1 new file +12 -0
new file mode 100644
index 0000000..d6b179e
@@ -0,0 +1,12 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Directory inode 12, block #1: directory passes checks but fails checksum.
+Fix? yes
+
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 430/512 files (0.2% non-contiguous), 45/512 blocks
+Exit status is 1
tests/f_htree_leaf_csum/expect.2 new file +7 -0
new file mode 100644
index 0000000..1609785
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 430/512 files (0.2% non-contiguous), 45/512 blocks
+Exit status is 0
tests/f_htree_leaf_csum/image.gz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..f2e461990c095b045750eb6fb657e660a1a360e5
GIT binary patch
tests/f_htree_leaf_csum/name new file +1 -0
new file mode 100644
index 0000000..43c6ada
@@ -0,0 +1 @@
+bad csum in htree leaf block

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in

#1 lore raw
Quoted 6 lines · Darrick J. Wong

We weren't verifying the checksum of an htree leaf block due to a coding error that marked all htree blocks as not having checksums. While we're at it, fix the error message that gets displayed so that it doesn't print a meaningless block offset.

Thanks, applied.

- Ted