All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1
@ 2014-08-01 18:11 Darrick J. Wong
  2014-08-01 18:11 ` [PATCH 01/19] e2fuzz: fix fs handle cleanup when closing fails Darrick J. Wong
                   ` (18 more replies)
  0 siblings, 19 replies; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:11 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

Hi all,

Here are revisions to the patchset that I sent last Friday, fixing
e2fsck failures with filesystems containing the metadata checksumming
features.  Like last week, e2fuzz helped me to find the failures.

The first patch fixes a Coverity complaint against e2fuzz.  Patch 2
ensures that e2fsck never clears a block in block_found_map if it's in
marked in the block_metadata_map.  Patch 3 suggests putting lost
inodes in the root directory if it's impossible to recreate the
lost+found directory.  Patch 4 fixes dumpe2fs to complain about
checksum errors without requiring command line options.

Patches 5-8 tear down the foundations of the strict_csum vs
no_strict_csum patchset in favor of checking any object that fails
checksum verification for some basic sanity.  If it finds sanity it'll
try to recover it, otherwise it'll declare it to be garbage and simply
zap it.  Users will not have to decide on a config option.

Patches 9-12 also fix errors when dealing with FS objects that fail
checksum tests.  Library flag handling, error reporting, and inode
re-checking (for regular mode) all receive some treatment.

Patches 13-19 are simple regression tests to check that e2fsck can
deal with various kinds of checksum failures -- errors that trigger
other corrective action; errors that don't make the FS inconsistent
(and would have gone unnoticed without metadata_csu); the checksum
itself being wrong; and total block destruction.

I've tested these e2fsprogs changes against the -next branch as of
7/29.  As I stated in the part 1 introduction, I use several VMs, each
with 32M-1G ramdisks to test with; the test process is "misc/e2fuzz.sh
-B <fuzz> -s <size>", where fuzz is anything from 2 bytes to "0.1%"
of metadata bytes.  I've been running five VMs for the past two days,
and the only new failures it found resulted in the patches 2-3.

Comments and questions are, as always, welcome.

--D

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

* [PATCH 01/19] e2fuzz: fix fs handle cleanup when closing fails
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
@ 2014-08-01 18:11 ` Darrick J. Wong
  2014-08-03  2:22   ` Theodore Ts'o
  2014-08-01 18:11 ` [PATCH 02/19] e2fsck: never free critical metadata blocks in the block found map Darrick J. Wong
                   ` (17 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:11 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Fix the handling of 'fs' when closing the FS fails so that we don't
dereference a NULL pointer.  Adapt to use ext2fs_close_free while
we're at it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Fixes-Coverity-Bug: 1229241
---
 misc/e2fuzz.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/misc/e2fuzz.c b/misc/e2fuzz.c
index 644c9c5..8c989dd 100644
--- a/misc/e2fuzz.c
+++ b/misc/e2fuzz.c
@@ -279,23 +279,20 @@ int process_fs(const char *fsname)
 	close(fd);
 
 	/* Clean up */
-	ret = ext2fs_close(fs);
+	ret = ext2fs_close_free(&fs);
 	if (ret) {
-		fs = NULL;
 		fprintf(stderr, "%s: error while closing filesystem\n",
 			fsname);
-		goto fail2;
+		return 1;
 	}
 
 	return 0;
 fail3:
 	close(fd);
-fail2:
 	if (corrupt_map != fs->block_map)
 		ext2fs_free_block_bitmap(corrupt_map);
 fail:
-	if (fs)
-		ext2fs_close(fs);
+	ext2fs_close_free(&fs);
 	return 1;
 }
 


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

* [PATCH 02/19] e2fsck: never free critical metadata blocks in the block found map
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
  2014-08-01 18:11 ` [PATCH 01/19] e2fuzz: fix fs handle cleanup when closing fails Darrick J. Wong
@ 2014-08-01 18:11 ` Darrick J. Wong
  2014-08-03  2:22   ` Theodore Ts'o
  2014-08-01 18:11 ` [PATCH 03/19] e2fsck: use root dir for lost+found when really desperate Darrick J. Wong
                   ` (16 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:11 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Don't allow critical metadata blocks to be marked free in the block
found map.  This can theoretically happen on an FS where a first
inode's ETB/indirect map block is in the inode table, the first inode
is itself unclonable (and thus gets deleted) and there are enough
crosslinked files before and after the first inode to use up all the
free blocks during pass 1b.

(I do actually have a test FS image but it's 256M and it proved very
difficult to craft a bite-sized test case that actually hit this bug.)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/pass1.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 26fe60c..e7a6acd 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -3356,6 +3356,13 @@ static void e2fsck_block_alloc_stats(ext2_filsys fs, blk64_t blk, int inuse)
 {
 	e2fsck_t ctx = (e2fsck_t) fs->priv_data;
 
+	/* Never free a critical metadata block */
+	if (ctx->block_found_map &&
+	    ctx->block_metadata_map &&
+	    inuse < 0 &&
+	    ext2fs_test_block_bitmap2(ctx->block_metadata_map, blk))
+		return;
+
 	if (ctx->block_found_map) {
 		if (inuse > 0)
 			ext2fs_mark_block_bitmap2(ctx->block_found_map, blk);


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

* [PATCH 03/19] e2fsck: use root dir for lost+found when really desperate
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
  2014-08-01 18:11 ` [PATCH 01/19] e2fuzz: fix fs handle cleanup when closing fails Darrick J. Wong
  2014-08-01 18:11 ` [PATCH 02/19] e2fsck: never free critical metadata blocks in the block found map Darrick J. Wong
@ 2014-08-01 18:11 ` Darrick J. Wong
  2014-08-03  2:25   ` Theodore Ts'o
  2014-08-01 18:12 ` [PATCH 04/19] dumpe2fs: complain when checksum verification fails Darrick J. Wong
                   ` (15 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:11 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

If we're totally unable to allocate a lost+found directory, ask the
user if he would like to dump orphaned files in the root directory.
Hopefully this enables the user to delete enough files so that a
subsequent run of e2fsck will make more progress.  Better to cram lost
files in the rootdir than the current behavior, which is to fail at
linking them in, thereby leaving them as lost files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/pass3.c                    |   12 ++++++++++++
 e2fsck/problem.c                  |    5 +++++
 e2fsck/problem.h                  |    3 +++
 tests/f_nospc_create_lnf/expect.1 |   28 ++++++++++++++++++++++++++++
 tests/f_nospc_create_lnf/expect.2 |   25 +++++++++++++++++++++++++
 tests/f_nospc_create_lnf/image.gz |  Bin
 tests/f_nospc_create_lnf/name     |    1 +
 7 files changed, 74 insertions(+)
 create mode 100644 tests/f_nospc_create_lnf/expect.1
 create mode 100644 tests/f_nospc_create_lnf/expect.2
 create mode 100644 tests/f_nospc_create_lnf/image.gz
 create mode 100644 tests/f_nospc_create_lnf/name

diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index 31131ab..e6142ad 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -450,6 +450,12 @@ unlink:
 		goto skip_new_block;
 	}
 	retval = ext2fs_new_block2(fs, 0, ctx->block_found_map, &blk);
+	if (retval == EXT2_ET_BLOCK_ALLOC_FAIL &&
+	    fix_problem(ctx, PR_3_LPF_NO_SPACE, &pctx)) {
+		printf("Delete some files and re-run e2fsck.\n\n");
+		ctx->lost_and_found = EXT2_ROOT_INO;
+		return 0;
+	}
 	if (retval) {
 		pctx.errcode = retval;
 		fix_problem(ctx, PR_3_ERR_LPF_NEW_BLOCK, &pctx);
@@ -464,6 +470,12 @@ skip_new_block:
 	 */
 	retval = ext2fs_new_inode(fs, EXT2_ROOT_INO, 040700,
 				  ctx->inode_used_map, &ino);
+	if (retval == EXT2_ET_INODE_ALLOC_FAIL &&
+	    fix_problem(ctx, PR_3_LPF_NO_SPACE, &pctx)) {
+		printf("Delete some files and re-run e2fsck.\n\n");
+		ctx->lost_and_found = EXT2_ROOT_INO;
+		return 0;
+	}
 	if (retval) {
 		pctx.errcode = retval;
 		fix_problem(ctx, PR_3_ERR_LPF_NEW_INODE, &pctx);
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 2c9386f..e68433b 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1630,6 +1630,11 @@ static struct e2fsck_problem problem_table[] = {
 	  N_("/@l has inline data\n"),
 	  PROMPT_CLEAR, 0 },
 
+	/* Cannot allocate /lost+found. */
+	{ PR_3_LPF_NO_SPACE,
+	  N_("Cannot allocate space for /@l.\nPlace lost files in root directory instead"),
+	  PROMPT_NULL, 0 },
+
 	/* Pass 3A Directory Optimization	*/
 
 	/* Pass 3A: Optimizing directories */
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index 80ef4a2..496e873 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -973,6 +973,9 @@ struct problem_context {
 /* Lost+found has inline data */
 #define PR_3_LPF_INLINE_DATA		0x030018
 
+/* Cannot allocate lost+found */
+#define PR_3_LPF_NO_SPACE		0x030019
+
 /*
  * Pass 3a --- rehashing diretories
  */
diff --git a/tests/f_nospc_create_lnf/expect.1 b/tests/f_nospc_create_lnf/expect.1
new file mode 100644
index 0000000..fc20628
--- /dev/null
+++ b/tests/f_nospc_create_lnf/expect.1
@@ -0,0 +1,28 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+/lost+found not found.  Create? yes
+
+Cannot allocate space for /lost+found.
+Place lost files in root directory instead? yes
+
+Delete some files and re-run e2fsck.
+
+Pass 3A: Optimizing directories
+Pass 4: Checking reference counts
+Unattached inode 125
+Connect to /lost+found? yes
+
+Inode 125 ref count is 2, should be 1.  Fix? yes
+
+Pass 5: Checking group summary information
+Free blocks count wrong for group #0 (496, counted=495).
+Fix? yes
+
+Free blocks count wrong (496, counted=495).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 128/128 files (0.0% non-contiguous), 17/512 blocks
+Exit status is 1
diff --git a/tests/f_nospc_create_lnf/expect.2 b/tests/f_nospc_create_lnf/expect.2
new file mode 100644
index 0000000..5a44649
--- /dev/null
+++ b/tests/f_nospc_create_lnf/expect.2
@@ -0,0 +1,25 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+/lost+found not found.  Create? yes
+
+Cannot allocate space for /lost+found.
+Place lost files in root directory instead? yes
+
+Delete some files and re-run e2fsck.
+
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences:  -9
+Fix? yes
+
+Free blocks count wrong for group #0 (494, counted=495).
+Fix? yes
+
+Free blocks count wrong (494, counted=495).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 128/128 files (0.0% non-contiguous), 17/512 blocks
+Exit status is 1
diff --git a/tests/f_nospc_create_lnf/image.gz b/tests/f_nospc_create_lnf/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..dc71b61a0028603aac348c61b015fd3c0b25273a
GIT binary patch
literal 4201
zcmeHH{Zms{8qRK~jkCIDtaWjUB+hmRwcAP&l#L18rEX>XB6YHbwR~hNB9l_cB9?dw
z<my^Wtz&|VihM|lSwTff`KY3S+}bE#0kSOGs3ZXek`PFugb?#_@7cp%e(Vqa0c7UQ
z%{lM$KIeI#^WLydEusCh<O%=RuQ^O;Tb*Y${kgT;B9FYkY}MY?fB0yVuHy6uJ#T&}
zjC^ZvZR`H#ukWPxyt(uI$2)h1?mY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4=(=5Cvh|7+3U1BYm;;-?7j}kyi5_fDJB^G4r1K^qxoQ~j<&D30v{Krk=
zPCI^oMfpNm41BYOWn|2>2CQ1>vB^q^>^6*8A&D5E6uY2(mPRsUTAE2YBbu~fjvQ9|
zyVNA%@D5Wreu1YgOtnyw13Qo;18a_Nh-wnlS_uFzr3E#NQ_jd_WV!UPDSKgx>q}5@
z(mRL+O@823V1$eGeUHI=?=~tX<_l)spd9v?oeWOAWBC8h1FT2ehWz5c<l^R{1B(tU
bI<V-#q63Q#yqW_*K`wuwV)xT%Yia)j*ECk;

literal 0
HcmV?d00001

diff --git a/tests/f_nospc_create_lnf/name b/tests/f_nospc_create_lnf/name
new file mode 100644
index 0000000..df6c932
--- /dev/null
+++ b/tests/f_nospc_create_lnf/name
@@ -0,0 +1 @@
+no space to create lost+found


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

* [PATCH 04/19] dumpe2fs: complain when checksum verification fails
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (2 preceding siblings ...)
  2014-08-01 18:11 ` [PATCH 03/19] e2fsck: use root dir for lost+found when really desperate Darrick J. Wong
@ 2014-08-01 18:12 ` Darrick J. Wong
  2014-08-03  2:26   ` Theodore Ts'o
  2014-08-01 18:12 ` [PATCH 05/19] libext2fs: check EA block headers when reading in the block Darrick J. Wong
                   ` (14 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:12 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Warn the user to run e2fsck if the superblock or bitmaps fails
checksum verification.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 misc/dumpe2fs.c |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index 0b84ece..7cbb99b 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -620,7 +620,7 @@ int main (int argc, char ** argv)
 		flags |= EXT2_FLAG_FORCE;
 	if (image_dump)
 		flags |= EXT2_FLAG_IMAGE_FILE;
-
+try_open_again:
 	if (use_superblock && !use_blocksize) {
 		for (use_blocksize = EXT2_MIN_BLOCK_SIZE;
 		     use_blocksize <= EXT2_MAX_BLOCK_SIZE;
@@ -635,6 +635,13 @@ int main (int argc, char ** argv)
 	} else
 		retval = ext2fs_open (device_name, flags, use_superblock,
 				      use_blocksize, unix_io_manager, &fs);
+	if (retval && !(flags & EXT2_FLAG_IGNORE_CSUM_ERRORS)) {
+		flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
+		goto try_open_again;
+	}
+	if (!retval && (fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS))
+		printf("%s", _("\n*** Checksum errors detected in filesystem!  Run e2fsck now!\n\n"));
+	flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
 	if (retval) {
 		com_err (program_name, retval, _("while trying to open %s"),
 			 device_name);
@@ -663,7 +670,15 @@ int main (int argc, char ** argv)
 			ext2fs_close_free(&fs);
 			exit (0);
 		}
+		fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS;
+try_bitmaps_again:
 		retval = ext2fs_read_bitmaps (fs);
+		if (retval && !(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS)) {
+			fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
+			goto try_bitmaps_again;
+		}
+		if (!retval && (fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS))
+			printf("%s", _("\n*** Checksum errors detected in bitmaps!  Run e2fsck now!\n\n"));
 		list_desc (fs);
 		if (retval) {
 			printf(_("\n%s: %s: error reading bitmaps: %s\n"),


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

* [PATCH 05/19] libext2fs: check EA block headers when reading in the block
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (3 preceding siblings ...)
  2014-08-01 18:12 ` [PATCH 04/19] dumpe2fs: complain when checksum verification fails Darrick J. Wong
@ 2014-08-01 18:12 ` Darrick J. Wong
  2014-08-03  2:33   ` Theodore Ts'o
  2014-08-01 18:12 ` [PATCH 06/19] e2fsck: try to salvage extent blocks with bad checksums Darrick J. Wong
                   ` (13 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:12 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

When reading an EA block in from disk, do a quick sanity check of the
block header, and return an error if we think we have garbage.  Teach
e2fsck to ignore the new error code in favor of doing its own
checking, and remove the strict_csums bits while we're at it.

(Also document some assumptions in the new ext_attr code.)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/pass1.c        |   18 ++++++++++++------
 e2fsck/problem.c      |    5 -----
 e2fsck/problem.h      |    3 ---
 lib/ext2fs/ext_attr.c |   25 +++++++++++++++++++------
 4 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index e7a6acd..02683d3 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -1748,12 +1748,16 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx,
 	pctx->blk = blk;
 	pctx->errcode = ext2fs_read_ext_attr3(fs, blk, block_buf, pctx->ino);
 	if (pctx->errcode == EXT2_ET_EXT_ATTR_CSUM_INVALID) {
-		if (fix_problem(ctx, PR_1_EA_BLOCK_CSUM_INVALID, pctx))
-			goto clear_extattr;
+		pctx->errcode = 0;
 		failed_csum = 1;
-	}
-	if (pctx->errcode && fix_problem(ctx, PR_1_READ_EA_BLOCK, pctx))
+	} else if (pctx->errcode == EXT2_ET_BAD_EA_HEADER)
+		pctx->errcode = 0;
+
+	if (pctx->errcode &&
+	    fix_problem(ctx, PR_1_READ_EA_BLOCK, pctx)) {
+		pctx->errcode = 0;
 		goto clear_extattr;
+	}
 	header = (struct ext2_ext_attr_header *) block_buf;
 	pctx->blk = ext2fs_file_acl_block(fs, inode);
 	if (((ctx->ext_attr_ver == 1) &&
@@ -1769,6 +1773,9 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx,
 			goto clear_extattr;
 	}
 
+	if (pctx->errcode && fix_problem(ctx, PR_1_READ_EA_BLOCK, pctx))
+		goto clear_extattr;
+
 	region = region_create(0, fs->blocksize);
 	if (!region) {
 		fix_problem(ctx, PR_1_EA_ALLOC_REGION_ABORT, pctx);
@@ -2438,8 +2445,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
 		}
 	}
 
-	if (ext2fs_file_acl_block(fs, inode) &&
-	    check_ext_attr(ctx, pctx, block_buf)) {
+	if (check_ext_attr(ctx, pctx, block_buf)) {
 		if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
 			goto out;
 		pb.num_blocks++;
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index e68433b..dc094ed 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -992,11 +992,6 @@ static struct e2fsck_problem problem_table[] = {
 	     "extent\n\t(logical @b %c, @n physical @b %b, len %N)\n"),
 	  PROMPT_FIX, 0 },
 
-	/* Inode extended attribute block checksum does not match block. */
-	{ PR_1_EA_BLOCK_CSUM_INVALID,
-	  N_("@i %i @a @b %b checksum does not match block.  "),
-	  PROMPT_CLEAR, 0 },
-
 	/*
 	 * Inode extended attribute block passes checks, but checksum does not
 	 * match block.
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index 496e873..af7a73e 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -583,9 +583,6 @@ struct problem_context {
 /* extent block passes checks, but checksum does not match extent block */
 #define PR_1_EXTENT_ONLY_CSUM_INVALID  0x01006A
 
-/* ea block checksum invalid */
-#define PR_1_EA_BLOCK_CSUM_INVALID     0x01006B
-
 /* ea block passes checks, but checksum invalid */
 #define PR_1_EA_BLOCK_ONLY_CSUM_INVALID        0x01006C
 
diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c
index 308d21d..f3fba96 100644
--- a/lib/ext2fs/ext_attr.c
+++ b/lib/ext2fs/ext_attr.c
@@ -58,12 +58,23 @@ __u32 ext2fs_ext_attr_hash_entry(struct ext2_ext_attr_entry *entry, void *data)
 	return hash;
 }
 
+static errcode_t check_ext_attr_header(struct ext2_ext_attr_header *header)
+{
+	if ((header->h_magic != EXT2_EXT_ATTR_MAGIC_v1 &&
+	     header->h_magic != EXT2_EXT_ATTR_MAGIC) ||
+	    header->h_blocks != 1)
+		return EXT2_ET_BAD_EA_HEADER;
+
+	return 0;
+}
+
 #undef NAME_HASH_SHIFT
 #undef VALUE_HASH_SHIFT
 
 errcode_t ext2fs_read_ext_attr3(ext2_filsys fs, blk64_t block, void *buf,
 				ext2_ino_t inum)
 {
+	int		csum_failed = 0;
 	errcode_t	retval;
 
 	retval = io_channel_read_blk64(fs->io, block, 1, buf);
@@ -72,12 +83,16 @@ errcode_t ext2fs_read_ext_attr3(ext2_filsys fs, blk64_t block, void *buf,
 
 	if (!(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) &&
 	    !ext2fs_ext_attr_block_csum_verify(fs, inum, block, buf))
-		retval = EXT2_ET_EXT_ATTR_CSUM_INVALID;
+		csum_failed = 1;
 
 #ifdef WORDS_BIGENDIAN
 	ext2fs_swap_ext_attr(buf, buf, fs->blocksize, 1);
 #endif
 
+	retval = check_ext_attr_header(buf);
+	if (retval == 0 && csum_failed)
+		retval = EXT2_ET_EXT_ATTR_CSUM_INVALID;
+
 	return retval;
 }
 
@@ -321,6 +336,7 @@ errcode_t ext2fs_free_ext_attr(ext2_filsys fs, ext2_ino_t ino,
 	if (err)
 		goto out2;
 
+	/* We only know how to deal with v2 EA blocks */
 	header = (struct ext2_ext_attr_header *) block_buf;
 	if (header->h_magic != EXT2_EXT_ATTR_MAGIC) {
 		err = EXT2_ET_BAD_EA_HEADER;
@@ -380,6 +396,7 @@ static errcode_t prep_ea_block_for_write(ext2_filsys fs, ext2_ino_t ino,
 		if (err)
 			goto out2;
 
+		/* We only know how to deal with v2 EA blocks */
 		header = (struct ext2_ext_attr_header *) block_buf;
 		if (header->h_magic != EXT2_EXT_ATTR_MAGIC) {
 			err = EXT2_ET_BAD_EA_HEADER;
@@ -763,17 +780,13 @@ read_ea_block:
 		if (err)
 			goto out3;
 
+		/* We only know how to deal with v2 EA blocks */
 		header = (struct ext2_ext_attr_header *) block_buf;
 		if (header->h_magic != EXT2_EXT_ATTR_MAGIC) {
 			err = EXT2_ET_BAD_EA_HEADER;
 			goto out3;
 		}
 
-		if (header->h_blocks != 1) {
-			err = EXT2_ET_BAD_EA_HEADER;
-			goto out3;
-		}

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

* [PATCH 06/19] e2fsck: try to salvage extent blocks with bad checksums
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (4 preceding siblings ...)
  2014-08-01 18:12 ` [PATCH 05/19] libext2fs: check EA block headers when reading in the block Darrick J. Wong
@ 2014-08-01 18:12 ` Darrick J. Wong
  2014-08-03  2:33   ` Theodore Ts'o
  2014-08-01 18:12 ` [PATCH 07/19] e2fsck: try to salvage corrupt directory entry blocks Darrick J. Wong
                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:12 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Remove the code that would zap an extent block immediately if the
checksum failed (i.e. strict_csums).  Instead, we'll only do that if
the extent block header shows obvious structural problems; if the
header checks out, then we'll iterate the block and see if we can
recover some extents.

Requires a minor modification to ext2fs_extent_get such that the
extent block will be returned in the buffer even if the return code
indicates a checksum error.  This brings its behavior in line with
the rest of libext2fs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/pass1.c      |   45 +++++++++++++++++++--------------------------
 e2fsck/problem.c    |    6 ------
 e2fsck/problem.h    |    3 ---
 lib/ext2fs/extent.c |   10 ++++++----
 4 files changed, 25 insertions(+), 39 deletions(-)

diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 02683d3..283b0b1 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -2001,7 +2001,10 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
 	int			is_dir, is_leaf;
 	problem_t		problem;
 	struct ext2_extent_info	info;
-	int			failed_csum;
+	int			failed_csum = 0;
+
+	if (pctx->errcode == EXT2_ET_EXTENT_CSUM_INVALID)
+		failed_csum = 1;
 
 	pctx->errcode = ext2fs_extent_get_info(ehandle, &info);
 	if (pctx->errcode)
@@ -2012,7 +2015,6 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
 	while ((pctx->errcode == 0 ||
 		pctx->errcode == EXT2_ET_EXTENT_CSUM_INVALID) &&
 	       info.num_entries-- > 0) {
-		failed_csum = 0;
 		is_leaf = extent.e_flags & EXT2_EXTENT_FLAGS_LEAF;
 		is_dir = LINUX_S_ISDIR(pctx->inode->i_mode);
 		last_lblk = extent.e_lblk + extent.e_len - 1;
@@ -2023,15 +2025,6 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
 		pctx->num = extent.e_len;
 		pctx->blkcount = extent.e_lblk + extent.e_len;
 
-		/* Ask to clear a corrupt extent block */
-		if (try_repairs &&
-		    pctx->errcode == EXT2_ET_EXTENT_CSUM_INVALID) {
-			problem = PR_1_EXTENT_CSUM_INVALID;
-			if (fix_problem(ctx, problem, pctx))
-				goto fix_problem_now;
-			failed_csum = 1;
-		}
-
 		if (extent.e_pblk == 0 ||
 		    extent.e_pblk < ctx->fs->super->s_first_data_block ||
 		    extent.e_pblk >= ext2fs_blocks_count(ctx->fs->super))
@@ -2069,16 +2062,6 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
 			failed_csum = 0;
 		}
 
-		/* Failed csum but passes checks?  Ask to fix checksum. */
-		if (try_repairs && failed_csum && problem == 0 &&
-		    fix_problem(ctx, PR_1_EXTENT_ONLY_CSUM_INVALID, pctx)) {
-			pb->inode_modified = 1;
-			pctx->errcode = ext2fs_extent_replace(ehandle,
-							0, &extent);
-			if (pctx->errcode)
-				return;
-		}
-
 		if (try_repairs && problem) {
 report_problem:
 			if (fix_problem(ctx, problem, pctx)) {
@@ -2124,6 +2107,7 @@ fix_problem_now:
 					pctx->errcode = 0;
 					break;
 				}
+				failed_csum = 0;
 				continue;
 			}
 			goto next;
@@ -2152,15 +2136,13 @@ fix_problem_now:
 			}
 			pctx->errcode = ext2fs_extent_get(ehandle,
 						  EXT2_EXTENT_DOWN, &extent);
-			if (pctx->errcode) {
+			if (pctx->errcode &&
+			    pctx->errcode != EXT2_ET_EXTENT_CSUM_INVALID) {
 				pctx->str = "EXT2_EXTENT_DOWN";
 				problem = PR_1_EXTENT_HEADER_INVALID;
 				if (!next_try_repairs)
 					return;
-				if (pctx->errcode ==
-					EXT2_ET_EXTENT_HEADER_BAD ||
-				    pctx->errcode ==
-					EXT2_ET_EXTENT_CSUM_INVALID)
+				if (pctx->errcode == EXT2_ET_EXTENT_HEADER_BAD)
 					goto report_problem;
 				return;
 			}
@@ -2256,6 +2238,7 @@ fix_problem_now:
 				if (pctx->errcode)
 					goto failed_add_dir_block;
 				last_lblk = extent.e_lblk + extent.e_len - 1;
+				failed_csum = 0;
 			}
 		}
 alloc_later:
@@ -2323,6 +2306,16 @@ alloc_later:
 						  EXT2_EXTENT_NEXT_SIB,
 						  &extent);
 	}
+
+	/* Failed csum but passes checks?  Ask to fix checksum. */
+	if (failed_csum &&
+	    fix_problem(ctx, PR_1_EXTENT_ONLY_CSUM_INVALID, pctx)) {
+		pb->inode_modified = 1;
+		pctx->errcode = ext2fs_extent_replace(ehandle, 0, &extent);
+		if (pctx->errcode)
+			return;
+	}
+
 	if (pctx->errcode == EXT2_ET_EXTENT_NO_NEXT)
 		pctx->errcode = 0;
 }
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index dc094ed..1b6bdb0 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -977,12 +977,6 @@ static struct e2fsck_problem problem_table[] = {
 	  N_("@i %i passes checks, but checksum does not match @i.  "),
 	  PROMPT_FIX, PR_PREEN_OK },
 
-	/* Inode extent block checksum does not match extent */
-	{ PR_1_EXTENT_CSUM_INVALID,
-	  N_("@i %i extent block checksum does not match extent\n\t(logical @b "
-	     "%c, @n physical @b %b, len %N)\n"),
-	  PROMPT_CLEAR, 0 },
-
 	/*
 	 * Inode extent block passes checks, but checksum does not match
 	 * extent
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index af7a73e..89db5f3 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -577,9 +577,6 @@ struct problem_context {
 /* inode passes checks, but checksum does not match inode */
 #define PR_1_INODE_ONLY_CSUM_INVALID   0x010068
 
-/* extent block checksum does not match extent block */
-#define PR_1_EXTENT_CSUM_INVALID       0x010069
-
 /* extent block passes checks, but checksum does not match extent block */
 #define PR_1_EXTENT_ONLY_CSUM_INVALID  0x01006A
 
diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index 30673b5..32bc214 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -283,6 +283,7 @@ errcode_t ext2fs_extent_get(ext2_extent_handle_t handle,
 	blk64_t				blk;
 	blk64_t				end_blk;
 	int				orig_op, op;
+	int				failed_csum = 0;
 
 	EXT2_CHECK_MAGIC(handle, EXT2_ET_MAGIC_EXTENT_HANDLE);
 
@@ -457,10 +458,8 @@ retry:
 
 		if (!(handle->fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) &&
 		    !ext2fs_extent_block_csum_verify(handle->fs, handle->ino,
-						     eh)) {
-			handle->level--;
-			return EXT2_ET_EXTENT_CSUM_INVALID;
-		}
+						     eh))
+			failed_csum = 1;
 
 		newpath->left = newpath->entries =
 			ext2fs_le16_to_cpu(eh->eh_entries);
@@ -540,6 +539,9 @@ retry:
 	     (path->left != 0)))
 		goto retry;
 
+	if (failed_csum)
+		return EXT2_ET_EXTENT_CSUM_INVALID;
+
 	return 0;
 }
 


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

* [PATCH 07/19] e2fsck: try to salvage corrupt directory entry blocks
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (5 preceding siblings ...)
  2014-08-01 18:12 ` [PATCH 06/19] e2fsck: try to salvage extent blocks with bad checksums Darrick J. Wong
@ 2014-08-01 18:12 ` Darrick J. Wong
  2014-08-03  2:33   ` Theodore Ts'o
  2014-08-01 18:12 ` [PATCH 08/19] e2fsck: offer to clear inode table blocks that are insane Darrick J. Wong
                   ` (11 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:12 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Remove the code that would prompt the user to zap directory entry
blocks with bad checksums (i.e. strict_csums).  Instead, we'll run the
directory entries through the usual repair routines in an attempt to
save whatever we can.  At the same time, refactor the code that
schedules the repair of missing dirblock checksum entries.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/pass2.c   |   34 +++++++++-------------------------
 e2fsck/problem.c |    5 -----
 e2fsck/problem.h |    3 ---
 3 files changed, 9 insertions(+), 33 deletions(-)

diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 69ebab6..ae7768f 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -944,32 +944,16 @@ static int check_dir_block(ext2_filsys fs,
 out_htree:
 #endif /* ENABLE_HTREE */
 
-	/* Verify checksum. */
-	if (is_leaf && de_csum_size && !inline_data_size) {
-		/* No space for csum?  Rebuild dirs in pass 3A. */
-		if (!ext2fs_dirent_has_tail(fs, (struct ext2_dir_entry *)buf)) {
-			de_csum_size = 0;
-			if (e2fsck_dir_will_be_rehashed(ctx, ino))
-				goto skip_checksum;
-			if (!fix_problem(cd->ctx, PR_2_LEAF_NODE_MISSING_CSUM,
-					 &cd->pctx))
-				goto skip_checksum;
-			e2fsck_rehash_dir_later(ctx, ino);
+	/* Leaf node with no space for csum?  Rebuild dirs in pass 3A. */
+	if (is_leaf && !inline_data_size && failed_csum &&
+	    !ext2fs_dirent_has_tail(fs, (struct ext2_dir_entry *)buf)) {
+		de_csum_size = 0;
+		if (e2fsck_dir_will_be_rehashed(ctx, ino) ||
+		    !fix_problem(cd->ctx, PR_2_LEAF_NODE_MISSING_CSUM,
+				 &cd->pctx))
 			goto skip_checksum;
-		}
-		if (failed_csum) {
-			char *buf2;
-			if (!fix_problem(cd->ctx, PR_2_LEAF_NODE_CSUM_INVALID,
-					 &cd->pctx))
-				goto skip_checksum;
-			ext2fs_new_dir_block(fs,
-					     db->blockcnt == 0 ? ino : 0,
-					     EXT2_ROOT_INO, &buf2);
-			memcpy(buf, buf2, fs->blocksize);
-			ext2fs_free_mem(&buf2);
-			dir_modified++;
-			failed_csum = 0;
-		}
+		e2fsck_rehash_dir_later(ctx, ino);
+		goto skip_checksum;
 	}
 	/* htree nodes don't use fake dirents to store checksums */
 	if (!is_leaf)
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 1b6bdb0..80ca3a0 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1477,11 +1477,6 @@ static struct e2fsck_problem problem_table[] = {
 	  N_("@p @h %d: internal node fails checksum.\n"),
 	  PROMPT_CLEAR_HTREE, PR_PREEN_OK },
 
-	/* leaf node fails checksum */
-	{ PR_2_LEAF_NODE_CSUM_INVALID,
-	  N_("@d @i %i, %B, offset %N: @d fails checksum.\n"),
-	  PROMPT_SALVAGE, PR_PREEN_OK },
-
 	/* leaf node has no checksum */
 	{ PR_2_LEAF_NODE_MISSING_CSUM,
 	  N_("@d @i %i, %B, offset %N: @d has no checksum.\n"),
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index 89db5f3..4813fc6 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -879,9 +879,6 @@ struct problem_context {
 /* htree node fails checksum */
 #define PR_2_HTREE_NODE_CSUM_INVALID	0x02004A
 
-/* dir leaf node fails checksum */
-#define PR_2_LEAF_NODE_CSUM_INVALID	0x02004B

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

* [PATCH 08/19] e2fsck: offer to clear inode table blocks that are insane
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (6 preceding siblings ...)
  2014-08-01 18:12 ` [PATCH 07/19] e2fsck: try to salvage corrupt directory entry blocks Darrick J. Wong
@ 2014-08-01 18:12 ` Darrick J. Wong
  2014-08-03  2:46   ` Theodore Ts'o
  2014-08-01 18:12 ` [PATCH 09/19] e2fsck: correctly preserve fs flags when modifying ignore-csum-error flag Darrick J. Wong
                   ` (10 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:12 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4, Darrick J. Wong

From: Darrick J. Wong <darrick.wong@oracle.com>

Add a new behavior flag to the inode scan functions; when specified,
this flag will do some simple sanity checking of entire inode table
blocks.  If all the checksums are ok, we can skip checksum
verification on individual inodes later on.  If more than half of the
inodes look "insane" (bad extent tree root or checksum failure) then
ext2fs_get_next_inode_full() can return a special status code
indicating that what's in the buffer is probably garbage.

When e2fsck' inode scan encounters the 'inode is garbage' return code
it'll offer to zap the inode straightaway instead of trying to recover
anything.  This replaces the previous behavior of asking to zap
anything with a checksum error (strict_csum).

Signed-off-by: Darrick J. Wong <darrick.wong@orale.com>
---
 e2fsck/pass1.c            |   18 ++++--
 e2fsck/problem.c          |    8 +--
 e2fsck/problem.h          |    4 +
 lib/ext2fs/ext2_err.et.in |    3 +
 lib/ext2fs/ext2fs.h       |    1 
 lib/ext2fs/inode.c        |  137 ++++++++++++++++++++++++++++++++++++++++++++-
 6 files changed, 154 insertions(+), 17 deletions(-)

diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 283b0b1..a7792c4 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -809,7 +809,8 @@ void e2fsck_pass1(e2fsck_t ctx)
 		ctx->flags |= E2F_FLAG_ABORT;
 		goto endit;
 	}
-	ext2fs_inode_scan_flags(scan, EXT2_SF_SKIP_MISSING_ITABLE, 0);
+	ext2fs_inode_scan_flags(scan, EXT2_SF_SKIP_MISSING_ITABLE |
+				      EXT2_SF_WARN_GARBAGE_INODES, 0);
 	ctx->stashed_inode = inode;
 	scan_struct.ctx = ctx;
 	scan_struct.block_buf = block_buf;
@@ -851,7 +852,8 @@ void e2fsck_pass1(e2fsck_t ctx)
 			continue;
 		}
 		if (pctx.errcode &&
-		    pctx.errcode != EXT2_ET_INODE_CSUM_INVALID) {
+		    pctx.errcode != EXT2_ET_INODE_CSUM_INVALID &&
+		    pctx.errcode != EXT2_ET_INODE_IS_GARBAGE) {
 			fix_problem(ctx, PR_1_ISCAN_ERROR, &pctx);
 			ctx->flags |= E2F_FLAG_ABORT;
 			goto endit;
@@ -862,12 +864,14 @@ void e2fsck_pass1(e2fsck_t ctx)
 		pctx.inode = inode;
 		ctx->stashed_ino = ino;
 
-		/* Clear corrupt inode? */
-		if (pctx.errcode == EXT2_ET_INODE_CSUM_INVALID) {
-			if (fix_problem(ctx, PR_1_INODE_CSUM_INVALID, &pctx))
-				goto clear_inode;
-			failed_csum = 1;
+		/* Clear trashed inode? */
+		if (pctx.errcode == EXT2_ET_INODE_IS_GARBAGE &&
+		    inode->i_links_count > 0 &&
+		    fix_problem(ctx, PR_1_INODE_IS_GARBAGE, &pctx)) {
+			pctx.errcode = 0;
+			e2fsck_clear_inode(ctx, ino, inode, 0, "pass1");
 		}
+		failed_csum = pctx.errcode != 0;
 
 		if (inode->i_links_count) {
 			pctx.errcode = ext2fs_icount_store(ctx->inode_link_info,
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 80ca3a0..452137a 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -967,10 +967,10 @@ static struct e2fsck_problem problem_table[] = {
 	  N_("@i %i has zero length extent\n\t(@n logical @b %c, physical @b %b)\n"),
 	  PROMPT_CLEAR, 0 },
 
-	/* inode checksum does not match inode */
-	{ PR_1_INODE_CSUM_INVALID,
-	  N_("@i %i checksum does not match @i.  "),
-	  PROMPT_CLEAR, PR_PREEN_OK },
+	/* inode seems to contain garbage */
+	{ PR_1_INODE_IS_GARBAGE,
+	  N_("@i %i seems to contain garbage.  "),
+	  PROMPT_CLEAR, 0 },
 
 	/* inode passes checks, but checksum does not match inode */
 	{ PR_1_INODE_ONLY_CSUM_INVALID,
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index 4813fc6..72cfc4d 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -571,8 +571,8 @@ struct problem_context {
 /* Extent has zero length */
 #define PR_1_EXTENT_LENGTH_ZERO		0x010066
 
-/* inode checksum does not match inode */
-#define PR_1_INODE_CSUM_INVALID                0x010067
+/* inode seems to contain garbage */
+#define PR_1_INODE_IS_GARBAGE		0x010067
 
 /* inode passes checks, but checksum does not match inode */
 #define PR_1_INODE_ONLY_CSUM_INVALID   0x010068
diff --git a/lib/ext2fs/ext2_err.et.in b/lib/ext2fs/ext2_err.et.in
index 51c88d0..2194a18 100644
--- a/lib/ext2fs/ext2_err.et.in
+++ b/lib/ext2fs/ext2_err.et.in
@@ -515,4 +515,7 @@ ec	EXT2_ET_INLINE_DATA_NO_SPACE,
 ec	EXT2_ET_MAGIC_EA_HANDLE,
 	"Wrong magic number for extended attribute structure"
 
+ec	EXT2_ET_INODE_IS_GARBAGE,
+	"Inode seems to contain garbage"
+
 	end
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 7812956..b4a9f84 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -462,6 +462,7 @@ typedef struct ext2_struct_inode_scan *ext2_inode_scan;
 #define EXT2_SF_BAD_EXTRA_BYTES	0x0004
 #define EXT2_SF_SKIP_MISSING_ITABLE	0x0008
 #define EXT2_SF_DO_LAZY		0x0010
+#define EXT2_SF_WARN_GARBAGE_INODES	0x0020
 
 /*
  * ext2fs_check_if_mounted flags
diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
index 0cea9f0..08024cb 100644
--- a/lib/ext2fs/inode.c
+++ b/lib/ext2fs/inode.c
@@ -30,6 +30,10 @@
 #include "ext2fsP.h"
 #include "e2image.h"
 
+#define IBLOCK_STATUS_CSUMS_OK	1
+#define IBLOCK_STATUS_INSANE	2
+#define SCAN_BLOCK_STATUS(scan)	((scan)->temp_buffer + (scan)->inode_size)
+
 struct ext2_struct_inode_scan {
 	errcode_t		magic;
 	ext2_filsys		fs;
@@ -193,12 +197,14 @@ errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks,
 		ext2fs_free_mem(&scan);
 		return retval;
 	}
-	retval = ext2fs_get_mem(scan->inode_size, &scan->temp_buffer);
+	retval = ext2fs_get_mem(scan->inode_size + scan->inode_buffer_blocks,
+				&scan->temp_buffer);
 	if (retval) {
 		ext2fs_free_mem(&scan->inode_buffer);
 		ext2fs_free_mem(&scan);
 		return retval;
 	}
+	memset(SCAN_BLOCK_STATUS(scan), 0, scan->inode_buffer_blocks);
 	if (scan->fs->badblocks && scan->fs->badblocks->num)
 		scan->scan_flags |= EXT2_SF_CHK_BADBLOCKS;
 	if (ext2fs_has_group_desc_csum(fs))
@@ -348,6 +354,114 @@ static errcode_t check_for_inode_bad_blocks(ext2_inode_scan scan,
 	return 0;
 }
 
+static int block_map_looks_insane(ext2_filsys fs,
+				  struct ext2_inode_large *inode)
+{
+	unsigned int i, bad;
+
+	/* We're only interested in block mapped files, dirs, and symlinks */
+	if ((inode->i_flags & EXT4_INLINE_DATA_FL) ||
+	    (inode->i_flags & EXT4_EXTENTS_FL))
+		return 0;
+	if (!LINUX_S_ISREG(inode->i_mode) &&
+	    !LINUX_S_ISLNK(inode->i_mode) &&
+	    !LINUX_S_ISDIR(inode->i_mode))
+		return 0;
+	if (LINUX_S_ISLNK(inode->i_mode) &&
+	    EXT2_I_SIZE(inode) <= sizeof(inode->i_block))
+		return 0;
+
+	/* Unused inodes probably aren't insane */
+	if (inode->i_links_count == 0)
+		return 0;
+
+	/* See if more than half the block maps are insane */
+	for (i = 0, bad = 0; i < EXT2_N_BLOCKS; i++)
+		if (inode->i_block[i] != 0 &&
+		    (inode->i_block[i] < fs->super->s_first_data_block ||
+		     inode->i_block[i] >= ext2fs_blocks_count(fs->super)))
+			bad++;
+	return bad > EXT2_N_BLOCKS / 2;
+}
+
+static int extent_head_looks_insane(struct ext2_inode_large *inode)
+{
+	if (!(inode->i_flags & EXT4_EXTENTS_FL) ||
+	    ext2fs_extent_header_verify(inode->i_block,
+					sizeof(inode->i_block)) == 0)
+		return 0;
+	return 1;
+}
+
+/*
+ * Check all the inodes that we just read into the buffer.  Record what we
+ * find here -- currently, we can observe that all checksums are ok; more
+ * than half the inodes are insane; or no conclusions at all.
+ */
+static void check_inode_block_sanity(ext2_inode_scan scan, blk64_t num_blocks)
+{
+	ext2_ino_t	ino, inodes_to_scan;
+	unsigned int	badness, checksum_failures;
+	unsigned int	inodes_in_buf, inodes_per_block;
+	void		*p;
+	struct ext2_inode_large *inode;
+	char		*block_status;
+	unsigned int	blk;
+
+	if (!(scan->scan_flags & EXT2_SF_WARN_GARBAGE_INODES))
+		return;
+
+	inodes_to_scan = scan->inodes_left;
+	inodes_in_buf = num_blocks * scan->fs->blocksize / scan->inode_size;
+	if (inodes_to_scan > inodes_in_buf)
+		inodes_to_scan = inodes_in_buf;
+
+	p = scan->inode_buffer;
+	ino = scan->current_inode + 1;
+	checksum_failures = badness = 0;
+	block_status = SCAN_BLOCK_STATUS(scan);
+	memset(block_status, 0, scan->inode_buffer_blocks);
+	inodes_per_block = EXT2_INODES_PER_BLOCK(scan->fs->super);
+
+	while (inodes_to_scan > 0) {
+		blk = (p - (void *)scan->inode_buffer) / scan->fs->blocksize;
+		inode = p;
+
+		/* Is this inode insane? */
+		if (!ext2fs_inode_csum_verify(scan->fs, ino, inode)) {
+			checksum_failures++;
+			badness++;
+		} else if (extent_head_looks_insane(inode) ||
+			   block_map_looks_insane(scan->fs, inode))
+			badness++;
+
+		/* If more than half are insane, declare the whole block bad */
+		if (badness > inodes_per_block / 2) {
+			unsigned int ino_adj;
+
+			block_status[blk] |= IBLOCK_STATUS_INSANE;
+			ino_adj = inodes_per_block -
+						((ino - 1) % inodes_per_block);
+			if (ino_adj > inodes_to_scan)
+				ino_adj = inodes_to_scan;
+			inodes_to_scan -= ino_adj;
+			p += scan->inode_size * ino_adj;
+			ino += ino_adj;
+			checksum_failures = badness = 0;
+			continue;
+		}
+
+		if ((ino % inodes_per_block) == 0) {
+			if (checksum_failures == 0)
+				block_status[blk] |= IBLOCK_STATUS_CSUMS_OK;
+			checksum_failures = badness = 0;
+		}
+		inodes_to_scan--;
+		p += scan->inode_size;
+		ino++;
+	};
+}
+
 /*
  * This function is called by ext2fs_get_next_inode when it needs to
  * read in more blocks from the current blockgroup's inode table.
@@ -397,12 +511,15 @@ static errcode_t get_next_blocks(ext2_inode_scan scan)
 		if (retval)
 			return EXT2_ET_NEXT_INODE_READ;
 	}
+	check_inode_block_sanity(scan, num_blocks);
+
 	scan->ptr = scan->inode_buffer;
 	scan->bytes_left = num_blocks * scan->fs->blocksize;
 
 	scan->blocks_left -= num_blocks;
 	if (scan->current_block)
 		scan->current_block += num_blocks;
+
 	return 0;
 }
 
@@ -432,10 +549,14 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
 {
 	errcode_t	retval;
 	int		extra_bytes = 0;
-	const int	length = EXT2_INODE_SIZE(scan->fs->super);
+	int		length;
 	struct ext2_inode_large	*iptr = (struct ext2_inode_large *)inode;
+	char		*iblock_status;
+	unsigned int	iblk;
 
 	EXT2_CHECK_MAGIC(scan, EXT2_ET_MAGIC_INODE_SCAN);
+	length = EXT2_INODE_SIZE(scan->fs->super);
+	iblock_status = SCAN_BLOCK_STATUS(scan);
 
 	/*
 	 * Do we need to start reading a new block group?
@@ -503,6 +624,9 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
 	}
 
 	retval = 0;
+	iblk = scan->current_inode % EXT2_INODES_PER_GROUP(scan->fs->super) /
+				EXT2_INODES_PER_BLOCK(scan->fs->super) %
+				scan->inode_buffer_blocks;
 	if (extra_bytes) {
 		memcpy(scan->temp_buffer+extra_bytes, scan->ptr,
 		       scan->inode_size - extra_bytes);
@@ -510,7 +634,8 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
 		scan->bytes_left -= scan->inode_size - extra_bytes;
 
 		/* Verify the inode checksum. */
-		if (!(scan->fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) &&
+		if (!(iblock_status[iblk] & IBLOCK_STATUS_CSUMS_OK) &&
+		    !(scan->fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) &&
 		    !ext2fs_inode_csum_verify(scan->fs, scan->current_inode + 1,
 				(struct ext2_inode_large *)scan->temp_buffer))
 			retval = EXT2_ET_INODE_CSUM_INVALID;
@@ -529,7 +654,8 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
 		scan->scan_flags &= ~EXT2_SF_BAD_EXTRA_BYTES;
 	} else {
 		/* Verify the inode checksum. */
-		if (!(scan->fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) &&
+		if (!(iblock_status[iblk] & IBLOCK_STATUS_CSUMS_OK) &&
+		    !(scan->fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) &&
 		    !ext2fs_inode_csum_verify(scan->fs, scan->current_inode + 1,
 				(struct ext2_inode_large *)scan->ptr))
 			retval = EXT2_ET_INODE_CSUM_INVALID;
@@ -548,6 +674,9 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
 		if (scan->scan_flags & EXT2_SF_BAD_INODE_BLK)
 			retval = EXT2_ET_BAD_BLOCK_IN_INODE_TABLE;
 	}
+	if ((iblock_status[iblk] & IBLOCK_STATUS_INSANE) &&
+	    (retval == 0 || retval == EXT2_ET_INODE_CSUM_INVALID))
+		retval = EXT2_ET_INODE_IS_GARBAGE;
 
 	scan->inodes_left--;
 	scan->current_inode++;


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

* [PATCH 09/19] e2fsck: correctly preserve fs flags when modifying ignore-csum-error flag
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (7 preceding siblings ...)
  2014-08-01 18:12 ` [PATCH 08/19] e2fsck: offer to clear inode table blocks that are insane Darrick J. Wong
@ 2014-08-01 18:12 ` Darrick J. Wong
  2014-08-03  2:48   ` Theodore Ts'o
  2014-08-01 18:12 ` [PATCH 10/19] libext2fs: Don't cache inodes that fail checksum verification Darrick J. Wong
                   ` (9 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:12 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

When we need to modify the "ignore checksum error" behavior flag to
get us past a library call, it's possible that the library call can
result in other flag bits being changed.  Therefore, it is not correct
to restore unconditionally the previous flags value, since this will
have unintended side effects on the other fs->flags; nor is it correct
to assume that we can unconditionally set (or clear) the "ignore csum
error" flag bit.  Therefore, we must merge the previous value of the
"ignore csum error" flag with the value of flags after the call.

Note that we want to leave checksum verification on as much as
possible because doing so exposes e2fsck bugs where two metadata
blocks are "sharing" the same disk block, and attempting to fix one
before relocating the other causes major filesystem damage.  The
damage is much more obvious when a previously checked piece of
metadata suddenly fails in a subsequent pass.

The modifications to the pass 2, 3, and 3A code are justified as
follows: When e2fsck encounters a block of directory entries and
cannot find the placeholder entry at the end that contains the
checksum, it will try to insert the placeholder.  If that fails, it
will schedule the directory for a pass 3A reconstruction.  Until that
happens, we don't want directory block writing (pass 2), block
iteration (pass 3), or block reading (pass 3A) to fail due to checksum
errors, because failing to find the placeholder is itself a checksum
verification error, which causes e2fsck to abort without fixing
anything.

The e2fsck call to ext2fs_read_bitmaps must never fail due to a
checksum error because e2fsck subsequently (a) verifies the bitmaps
itself; or (b) decides that they don't match what has been observed,
and rewrites them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/pass2.c     |   14 ++++++++++----
 e2fsck/pass3.c     |   11 ++++++++---
 e2fsck/rehash.c    |    4 +++-
 e2fsck/util.c      |    5 ++++-
 lib/ext2fs/inode.c |    3 ++-
 5 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index ae7768f..e968831 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -1292,6 +1292,7 @@ skip_checksum:
 		}
 	}
 	if (dir_modified) {
+		int	flags, will_rehash;
 		/* leaf block with no tail?  Rehash dirs later. */
 		if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
 				EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
@@ -1304,8 +1305,11 @@ skip_checksum:
 		}
 
 write_and_fix:
-		if (e2fsck_dir_will_be_rehashed(ctx, ino))
+		will_rehash = e2fsck_dir_will_be_rehashed(ctx, ino);
+		if (will_rehash) {
+			flags = ctx->fs->flags;
 			ctx->fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
+		}
 		if (inline_data_size) {
 			cd->pctx.errcode =
 				ext2fs_inline_data_set(fs, ino, 0, buf,
@@ -1313,8 +1317,11 @@ write_and_fix:
 		} else
 			cd->pctx.errcode = ext2fs_write_dir_block4(fs, block_nr,
 								   buf, 0, ino);
-		if (e2fsck_dir_will_be_rehashed(ctx, ino))
-			ctx->fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS;
+		if (will_rehash)
+			ctx->fs->flags = (flags &
+					  EXT2_FLAG_IGNORE_CSUM_ERRORS) |
+					 (ctx->fs->flags &
+					  ~EXT2_FLAG_IGNORE_CSUM_ERRORS);
 		if (cd->pctx.errcode) {
 			if (!fix_problem(ctx, PR_2_WRITE_DIRBLOCK,
 					 &cd->pctx))
@@ -1590,7 +1597,6 @@ int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
 	return 0;
 }
 
-
 /*
  * allocate_dir_block --- this function allocates a new directory
  * 	block for a particular inode; this is done if a directory has
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index e6142ad..0b02961 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -699,6 +699,7 @@ static void fix_dotdot(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent)
 	errcode_t	retval;
 	struct fix_dotdot_struct fp;
 	struct problem_context pctx;
+	int		flags, will_rehash;
 
 	fp.fs = fs;
 	fp.parent = parent;
@@ -711,12 +712,16 @@ static void fix_dotdot(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent)
 
 	clear_problem_context(&pctx);
 	pctx.ino = ino;
-	if (e2fsck_dir_will_be_rehashed(ctx, ino))
+	will_rehash = e2fsck_dir_will_be_rehashed(ctx, ino);
+	if (will_rehash) {
+		flags = ctx->fs->flags;
 		ctx->fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
+	}
 	retval = ext2fs_dir_iterate(fs, ino, DIRENT_FLAG_INCLUDE_EMPTY,
 				    0, fix_dotdot_proc, &fp);
-	if (e2fsck_dir_will_be_rehashed(ctx, ino))
-		ctx->fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS;
+	if (will_rehash)
+		ctx->fs->flags = (flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) |
+			(ctx->fs->flags & ~EXT2_FLAG_IGNORE_CSUM_ERRORS);
 	if (retval || !fp.done) {
 		pctx.errcode = retval;
 		fix_problem(ctx, retval ? PR_3_FIX_PARENT_ERR :
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index 2983e32..e37e871 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -126,10 +126,12 @@ static int fill_dir_block(ext2_filsys fs,
 		dirent = (struct ext2_dir_entry *) dir;
 		(void) ext2fs_set_rec_len(fs, fs->blocksize, dirent);
 	} else {
+		int flags = fs->flags;
 		fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
 		fd->err = ext2fs_read_dir_block4(fs, *block_nr, dir, 0,
 						 fd->dir);
-		fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS;
+		fs->flags = (flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) |
+			    (fs->flags & ~EXT2_FLAG_IGNORE_CSUM_ERRORS);
 		if (fd->err)
 			return BLOCK_ABORT;
 	}
diff --git a/e2fsck/util.c b/e2fsck/util.c
index e36e902..8237328 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -267,6 +267,7 @@ void e2fsck_read_bitmaps(e2fsck_t ctx)
 	errcode_t	retval;
 	const char	*old_op;
 	unsigned int	save_type;
+	int		flags;
 
 	if (ctx->invalid_bitmaps) {
 		com_err(ctx->program_name, 0,
@@ -278,9 +279,11 @@ void e2fsck_read_bitmaps(e2fsck_t ctx)
 	old_op = ehandler_operation(_("reading inode and block bitmaps"));
 	e2fsck_set_bitmap_type(fs, EXT2FS_BMAP64_RBTREE, "fs_bitmaps",
 			       &save_type);
+	flags = ctx->fs->flags;
 	ctx->fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
 	retval = ext2fs_read_bitmaps(fs);
-	ctx->fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS;
+	ctx->fs->flags = (flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) |
+			 (ctx->fs->flags & ~EXT2_FLAG_IGNORE_CSUM_ERRORS);
 	fs->default_bitmap_type = save_type;
 	ehandler_operation(old_op);
 	if (retval) {
diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
index 08024cb..a6213ae 100644
--- a/lib/ext2fs/inode.c
+++ b/lib/ext2fs/inode.c
@@ -846,7 +846,8 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
 		retval = ext2fs_read_inode_full(fs, ino,
 						(struct ext2_inode *)w_inode,
 						length);
-		fs->flags = old_flags;
+		fs->flags = (old_flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) |
+			    (fs->flags & ~EXT2_FLAG_IGNORE_CSUM_ERRORS);
 		if (retval)
 			goto errout;
 	}


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

* [PATCH 10/19] libext2fs: Don't cache inodes that fail checksum verification
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (8 preceding siblings ...)
  2014-08-01 18:12 ` [PATCH 09/19] e2fsck: correctly preserve fs flags when modifying ignore-csum-error flag Darrick J. Wong
@ 2014-08-01 18:12 ` Darrick J. Wong
  2014-08-03  2:50   ` Theodore Ts'o
  2014-08-01 18:12 ` [PATCH 11/19] e2fsck: disable checksum verification in a few select places Darrick J. Wong
                   ` (8 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:12 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

If an inode fails checksum verification, don't stuff a copy of it in
the inode cache, because this can cause the library to fail to return
the "corrupt inode" error code.

In general, this happens if ext2fs_read_inode_full() is called twice
on an inode with an incorrect checksum.  If fs->flags has
EXT2_FLAG_IGNORE_CSUM_ERRORS set during the first call and *unset*
during the second call, the cache hit during the second call fails to
return EXT2_ET_INODE_CSUM_INVALID as you'd expect.  This happens
during fsck because the first read_inode call happens as part of
check_blocks and the second call happens during inode checksum
revalidation.  A file system with a slightly corrupt non-extent inode
will trigger this.

While we're at it, make the inode read function consistent with the
rest of libext2fs -- copy the metadata object into the caller's buffer
even if it fails checksum verification.  This will help e2fsck avoid a
double re-read later on down the line.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 lib/ext2fs/inode.c                      |   15 +++++++++------
 tests/f_no_cache_corrupt_inode/expect.1 |   11 +++++++++++
 tests/f_no_cache_corrupt_inode/expect.2 |    7 +++++++
 tests/f_no_cache_corrupt_inode/image.gz |  Bin
 tests/f_no_cache_corrupt_inode/name     |    1 +
 5 files changed, 28 insertions(+), 6 deletions(-)
 create mode 100644 tests/f_no_cache_corrupt_inode/expect.1
 create mode 100644 tests/f_no_cache_corrupt_inode/expect.2
 create mode 100644 tests/f_no_cache_corrupt_inode/image.gz
 create mode 100644 tests/f_no_cache_corrupt_inode/name

diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
index a6213ae..6c766af 100644
--- a/lib/ext2fs/inode.c
+++ b/lib/ext2fs/inode.c
@@ -709,7 +709,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
 	io_channel	io;
 	int		length = EXT2_INODE_SIZE(fs->super);
 	struct ext2_inode_large	*iptr;
-	int		cache_slot;
+	int		cache_slot, fail_csum;
 
 	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
@@ -787,9 +787,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
 	length = EXT2_INODE_SIZE(fs->super);
 
 	/* Verify the inode checksum. */
-	if (!(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) &&
-	    !ext2fs_inode_csum_verify(fs, ino, iptr))
-		return EXT2_ET_INODE_CSUM_INVALID;
+	fail_csum = !ext2fs_inode_csum_verify(fs, ino, iptr);
 
 #ifdef WORDS_BIGENDIAN
 	ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) iptr,
@@ -798,10 +796,15 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
 #endif
 
 	/* Update the inode cache bookkeeping */
-	fs->icache->cache_last = cache_slot;
-	fs->icache->cache[cache_slot].ino = ino;
+	if (!fail_csum) {
+		fs->icache->cache_last = cache_slot;
+		fs->icache->cache[cache_slot].ino = ino;
+	}
 	memcpy(inode, iptr, (bufsize > length) ? length : bufsize);
 
+	if (!(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) && fail_csum)
+		return EXT2_ET_INODE_CSUM_INVALID;
+
 	return 0;
 }
 
diff --git a/tests/f_no_cache_corrupt_inode/expect.1 b/tests/f_no_cache_corrupt_inode/expect.1
new file mode 100644
index 0000000..4f82f75
--- /dev/null
+++ b/tests/f_no_cache_corrupt_inode/expect.1
@@ -0,0 +1,11 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 passes checks, but checksum does not match inode.  Fix? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/128 files (0.0% non-contiguous), 19/512 blocks
+Exit status is 1
diff --git a/tests/f_no_cache_corrupt_inode/expect.2 b/tests/f_no_cache_corrupt_inode/expect.2
new file mode 100644
index 0000000..1b43315
--- /dev/null
+++ b/tests/f_no_cache_corrupt_inode/expect.2
@@ -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: 12/128 files (0.0% non-contiguous), 19/512 blocks
+Exit status is 0
diff --git a/tests/f_no_cache_corrupt_inode/image.gz b/tests/f_no_cache_corrupt_inode/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..e17e9216deac289cf5c13a33be87b1810640a66d
GIT binary patch
literal 2606
zcmb2|=3wyobSapL`Ry(14B<o>h7a#A{ZQZy>*8x|QnKm@V3(D-?OG_n)#_yJ!7jME
zccFxPCX1kBt6$TLWsAF;`vY|rJyPTFYwCAAxQJ1dedE2Sil)~bqkGT(t$SEM{r$V5
z^84lefA)JjF<e?ThsQ|q%aO%5HClpdtCq=KWj(d^V#U*s0h)apXU_8O?RMHzA<=uf
zx777(Vfx+;+L7*iCMn+(*tTZBLGiB(^L{U9TlbZ}?oIvWJ@U7?-M#B~ud{9gI$`~{
zxf=I(#nr{Fdot<o+4QW>&#ou0{Bmr4M&rwy6_4VU%juSV`?OqhEd#^L$xHU%EzDW<
z?ElgobJqIRTYdVPt0{6lLy>`jA>!Y&Pd7g-O%|Nb4&?o-KKcItPl425PH*=!{G4#|
z%h#*_4)4}`VkCStd1)?t_wjx?k7unP7OYm*66uzk1JrTANZ|X^`FE>t1i#FA^?(1n
zRbT%zGB7lJd+|SCBD&hV^8Z5bYM?TQ-QWIe?>@c^EbH)J9w?O2|IZ#sfxw16qFqPl
zgh4nsNrku1cFj5kly<oNk%a}PGJ+Bf_YI>eZLW0GZ$0}^eC_)0ZyanQqF4V<vCS&B
zI`rz7QQ+1sU*vpSFG$bhS${9;gxW<5zD&#Ke)-<tP0b7S?tZ;rVtn^&{r{a`e+Sq}
z^1u6{U+}+w-~IppLehgRv$V?J`@E}{SDUrJ{Zi2%^ZQ=kf7bt~+4Z`<dfC_C1?ng3
ze~F*^Z<P3W&(ldyQe0)UA4hC;xm~x@e&@gZIhjwt)_+Y2S$q45|Ihd@&i|%IA2HLr
zyU*zF>dL)|HA^P`SDl!%e<C*%K_8AP7!85Z5Eu=C(GVC7fzc2kF9bgP-p6Po@Th@-
HL4g4PrH?{0

literal 0
HcmV?d00001

diff --git a/tests/f_no_cache_corrupt_inode/name b/tests/f_no_cache_corrupt_inode/name
new file mode 100644
index 0000000..fb213e2
--- /dev/null
+++ b/tests/f_no_cache_corrupt_inode/name
@@ -0,0 +1 @@
+don't cache inodes that fail checksum verification


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

* [PATCH 11/19] e2fsck: disable checksum verification in a few select places
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (9 preceding siblings ...)
  2014-08-01 18:12 ` [PATCH 10/19] libext2fs: Don't cache inodes that fail checksum verification Darrick J. Wong
@ 2014-08-01 18:12 ` Darrick J. Wong
  2014-08-03  2:51   ` Theodore Ts'o
  2014-08-01 18:13 ` [PATCH 12/19] e2fsck: always ask to fix an inode that fails checksum verification Darrick J. Wong
                   ` (7 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:12 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Selectively disable checksum verification in a couple more places:

In check_blocks, disable checksum verification when iterating a block
map because the block map iterator function (re)reads the inode, which
could be unchanged since the scan found that the checksum fails.  We
don't want to abort here; we want to keep evaluating the inode, and we
already know if the inode checksum doesn't match.

Further down in check_blocks when we're trying to see if i_size
matches the amount of data stored in the inode, don't allow checksum
errors when we go looking for the size of inline data.  If the
required attribute is at all find-able in the EA block, we'll fix any
other problems with the EA block later.  In the meantime, we don't
want to be truncating files unnecessarily.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/pass1.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index a7792c4..39ebaae 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -2452,6 +2452,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
 		if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL))
 			check_blocks_extents(ctx, pctx, &pb);
 		else {
+			int flags;
 			/*
 			 * If we've modified the inode, write it out before
 			 * iterate() tries to use it.
@@ -2461,6 +2462,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
 						   "check_blocks");
 				dirty_inode = 0;
 			}
+			flags = fs->flags;
 			fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
 			pctx->errcode = ext2fs_block_iterate3(fs, ino,
 						pb.is_dir ? BLOCK_FLAG_HOLE : 0,
@@ -2479,7 +2481,8 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
 			if (pb.inode_modified)
 				e2fsck_read_inode(ctx, ino, inode,
 						  "check_blocks");
-			fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS;
+			fs->flags = (flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) |
+				    (fs->flags & ~EXT2_FLAG_IGNORE_CSUM_ERRORS);
 		}
 	} else {
 		/* check inline data */
@@ -2545,10 +2548,17 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
 	if (pb.is_dir) {
 		int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
 		if (inode->i_flags & EXT4_INLINE_DATA_FL) {
+			int flags;
 			size_t size;
 
+			flags = ctx->fs->flags;
+			ctx->fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
 			if (ext2fs_inline_data_size(ctx->fs, pctx->ino, &size))
 				bad_size = 5;
+			ctx->fs->flags = (flags &
+					  EXT2_FLAG_IGNORE_CSUM_ERRORS) |
+					 (ctx->fs->flags &
+					  ~EXT2_FLAG_IGNORE_CSUM_ERRORS);
 			if (size != inode->i_size)
 				bad_size = 5;
 		} else if (inode->i_size & (fs->blocksize - 1))


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

* [PATCH 12/19] e2fsck: always ask to fix an inode that fails checksum verification
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (10 preceding siblings ...)
  2014-08-01 18:12 ` [PATCH 11/19] e2fsck: disable checksum verification in a few select places Darrick J. Wong
@ 2014-08-01 18:13 ` Darrick J. Wong
  2014-08-03  2:55   ` Theodore Ts'o
  2014-08-01 18:13 ` [PATCH 13/19] tests: add regression tests for EA blocks with bad checksums Darrick J. Wong
                   ` (6 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:13 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

If an inode fails checksum verification during pass 1 and the user
doesn't fix or clear the inode as part of the regular inode checks,
ensure that e2fsck remembers to ask the user if he simply wants to
correct the checksum.

We weren't capturing all the ways out of an interation of the inode
scanning loop, which means that not all errors were caught.  Also,
we might as well clear the 'failed csum' flag if we write the inode
directly from the inode scanning loop.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/pass1.c                          |   65 +++++++++++++++++++++++--------
 tests/f_deleted_inode_bad_csum/expect.1 |   11 +++++
 tests/f_deleted_inode_bad_csum/expect.2 |    7 +++
 tests/f_deleted_inode_bad_csum/image.gz |  Bin
 tests/f_deleted_inode_bad_csum/name     |    1 
 5 files changed, 67 insertions(+), 17 deletions(-)
 create mode 100644 tests/f_deleted_inode_bad_csum/expect.1
 create mode 100644 tests/f_deleted_inode_bad_csum/expect.2
 create mode 100644 tests/f_deleted_inode_bad_csum/image.gz
 create mode 100644 tests/f_deleted_inode_bad_csum/name

diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 39ebaae..5c72f48 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -594,10 +594,7 @@ static errcode_t recheck_bad_inode_checksum(ext2_filsys fs, ext2_ino_t ino,
 
 	retval = ext2fs_write_inode_full(fs, ino, (struct ext2_inode *)&inode,
 					 sizeof(inode));
-	if (retval)
-		return retval;
-
-	return 0;
+	return retval;
 }
 
 static void reserve_block_for_root_repair(e2fsck_t ctx)
@@ -636,6 +633,29 @@ static void reserve_block_for_lnf_repair(e2fsck_t ctx)
 	ctx->lnf_repair_block = blk;
 }
 
+static void finish_processing_inode(e2fsck_t ctx, ext2_ino_t ino,
+				    struct problem_context *pctx,
+				    int failed_csum)
+{
+	if (!failed_csum)
+		return;
+
+	/*
+	 * If the inode failed the checksum and the user didn't
+	 * clear the inode, test the checksum again -- if it still
+	 * fails, ask the user if the checksum should be corrected.
+	 */
+	pctx->errcode = recheck_bad_inode_checksum(ctx->fs, ino, ctx, pctx);
+	if (pctx->errcode)
+		ctx->flags |= E2F_FLAG_ABORT;
+}
+#define FINISH_INODE_LOOP(ctx, ino, pctx, failed_csum) \
+	do { \
+		finish_processing_inode((ctx), (ino), (pctx), (failed_csum)); \
+		if ((ctx)->flags & E2F_FLAG_ABORT) \
+			return; \
+	} while (0)
+
 void e2fsck_pass1(e2fsck_t ctx)
 {
 	int	i;
@@ -898,6 +918,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 				inlinedata_fs = 1;
 			} else if (!fix_problem(ctx, PR_1_INLINE_DATA_SET, &pctx)) {
 				e2fsck_clear_inode(ctx, ino, inode, 0, "pass1");
+				/* skip FINISH_INODE_LOOP */
 				continue;
 			}
 		}
@@ -932,6 +953,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 				if (ino == EXT2_BAD_INO)
 					ext2fs_mark_inode_bitmap2(ctx->inode_used_map,
 								 ino);
+				/* skip FINISH_INODE_LOOP */
 				continue;
 			}
 		}
@@ -968,6 +990,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 				       sizeof(inode->i_block));
 #endif
 				e2fsck_write_inode(ctx, ino, inode, "pass1");
+				failed_csum = 0;
 			}
 		}
 
@@ -982,6 +1005,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 				memset(inode, 0, sizeof(struct ext2_inode));
 				e2fsck_write_inode(ctx, ino, inode,
 						   "clear bad inode");
+				failed_csum = 0;
 			}
 
 			pctx.errcode = ext2fs_copy_bitmap(ctx->block_found_map,
@@ -1016,6 +1040,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 			}
 			ext2fs_mark_inode_bitmap2(ctx->inode_used_map, ino);
 			clear_problem_context(&pctx);
+			FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum);
 			continue;
 		} else if (ino == EXT2_ROOT_INO) {
 			/*
@@ -1041,6 +1066,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 					inode->i_dtime = 0;
 					e2fsck_write_inode(ctx, ino, inode,
 							   "pass1");
+					failed_csum = 0;
 				}
 			}
 		} else if (ino == EXT2_JOURNAL_INO) {
@@ -1052,8 +1078,10 @@ void e2fsck_pass1(e2fsck_t ctx)
 					inode->i_mode = LINUX_S_IFREG;
 					e2fsck_write_inode(ctx, ino, inode,
 							   "pass1");
+					failed_csum = 0;
 				}
 				check_blocks(ctx, &pctx, block_buf);
+				FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum);
 				continue;
 			}
 			if ((inode->i_links_count ||
@@ -1065,6 +1093,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 						    ino, 0);
 				e2fsck_write_inode_full(ctx, ino, inode,
 							inode_size, "pass1");
+				failed_csum = 0;
 			}
 		} else if ((ino == EXT4_USR_QUOTA_INO) ||
 			   (ino == EXT4_GRP_QUOTA_INO)) {
@@ -1079,8 +1108,10 @@ void e2fsck_pass1(e2fsck_t ctx)
 					inode->i_mode = LINUX_S_IFREG;
 					e2fsck_write_inode(ctx, ino, inode,
 							"pass1");
+					failed_csum = 0;
 				}
 				check_blocks(ctx, &pctx, block_buf);
+				FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum);
 				continue;
 			}
 			if ((inode->i_links_count ||
@@ -1092,6 +1123,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 						    ino, 0);
 				e2fsck_write_inode_full(ctx, ino, inode,
 							inode_size, "pass1");
+				failed_csum = 0;
 			}
 		} else if (ino < EXT2_FIRST_INODE(fs->super)) {
 			problem_t problem = 0;
@@ -1113,9 +1145,11 @@ void e2fsck_pass1(e2fsck_t ctx)
 					inode->i_mode = 0;
 					e2fsck_write_inode(ctx, ino, inode,
 							   "pass1");
+					failed_csum = 0;
 				}
 			}
 			check_blocks(ctx, &pctx, block_buf);
+			FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum);
 			continue;
 		}
 
@@ -1143,6 +1177,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 					0 : ctx->now;
 				e2fsck_write_inode(ctx, ino, inode,
 						   "pass1");
+				failed_csum = 0;
 			}
 		}
 
@@ -1157,8 +1192,10 @@ void e2fsck_pass1(e2fsck_t ctx)
 					inode->i_dtime = ctx->now;
 					e2fsck_write_inode(ctx, ino, inode,
 							   "pass1");
+					failed_csum = 0;
 				}
 			}
+			FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum);
 			continue;
 		}
 		/*
@@ -1175,6 +1212,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 			if (fix_problem(ctx, PR_1_SET_DTIME, &pctx)) {
 				inode->i_dtime = 0;
 				e2fsck_write_inode(ctx, ino, inode, "pass1");
+				failed_csum = 0;
 			}
 		}
 
@@ -1211,6 +1249,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 					inode->i_flags &= ~EXT2_IMAGIC_FL;
 					e2fsck_write_inode(ctx, ino,
 							   inode, "pass1");
+					failed_csum = 0;
 				}
 			}
 		}
@@ -1228,6 +1267,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 		    fix_problem(ctx, PR_1_FAST_SYMLINK_EXTENT_FL, &pctx)) {
 			inode->i_flags &= ~EXT4_EXTENTS_FL;
 			e2fsck_write_inode(ctx, ino, inode, "pass1");
+			failed_csum = 0;
 		}
 
 		if (LINUX_S_ISDIR(inode->i_mode)) {
@@ -1253,10 +1293,12 @@ void e2fsck_pass1(e2fsck_t ctx)
 			check_immutable(ctx, &pctx);
 			ctx->fs_symlinks_count++;
 			if (inode->i_flags & EXT4_INLINE_DATA_FL) {
+				FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum);
 				continue;
 			} else if (ext2fs_inode_data_blocks(fs, inode) == 0) {
 				ctx->fs_fast_symlinks_count++;
 				check_blocks(ctx, &pctx, block_buf);
+				FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum);
 				continue;
 			}
 		}
@@ -1293,19 +1335,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 		} else
 			check_blocks(ctx, &pctx, block_buf);
 
-		/*
-		 * If the inode failed the checksum and the user didn't
-		 * clear the inode, test the checksum again -- if it still
-		 * fails, ask the user if the checksum should be corrected.
-		 */
-		if (failed_csum) {
-			pctx.errcode = recheck_bad_inode_checksum(fs, ino, ctx,
-								  &pctx);
-			if (pctx.errcode) {
-				ctx->flags |= E2F_FLAG_ABORT;
-				return;
-			}
-		}
+		FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum);
 
 		if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
 			goto endit;
@@ -1410,6 +1440,7 @@ endit:
 	if ((ctx->flags & E2F_FLAG_SIGNAL_MASK) == 0)
 		print_resource_track(ctx, _("Pass 1"), &rtrack, ctx->fs->io);
 }
+#undef FINISH_INODE_LOOP
 
 /*
  * When the inode_scan routines call this callback at the end of the
diff --git a/tests/f_deleted_inode_bad_csum/expect.1 b/tests/f_deleted_inode_bad_csum/expect.1
new file mode 100644
index 0000000..8420361
--- /dev/null
+++ b/tests/f_deleted_inode_bad_csum/expect.1
@@ -0,0 +1,11 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 passes checks, but checksum does not match inode.  Fix? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 1
diff --git a/tests/f_deleted_inode_bad_csum/expect.2 b/tests/f_deleted_inode_bad_csum/expect.2
new file mode 100644
index 0000000..eb48b40
--- /dev/null
+++ b/tests/f_deleted_inode_bad_csum/expect.2
@@ -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: 12/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 0
diff --git a/tests/f_deleted_inode_bad_csum/image.gz b/tests/f_deleted_inode_bad_csum/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..a27e50e85f91e2724e846644729b27faefccc561
GIT binary patch
literal 2676
zcmb2|=3w}~<VG+P^V?g#86x2_3?Iy2%Ux1YO<K5cLesYt!NsBzFGNYbJm}@Xzpz~N
zVw05avT4r(gx<1ebO-Fw*doNSx8g$gl&&AG?zS9Ujw{&xn^q*e^}V@oyD|5!HSKC<
zt7qQN|9SrQ_q4S1f18arzki#@;Skxo+*7rsJn5qXcjA_e^&)}s2{!us=FXC{6H(^g
zdh5esog+sNN31cA)7Cz<Zjq5d_vw$WWns=cj0(P7c8}-V`}OjqvwQ95|9iCl+24qb
z)hS>8pZofzcc1X~cR4lR+ZU>)+y5!fP~vW0xO>w1YP0_7OZDwGiM_pgW5>aj?z8Vk
z)>f@w%)sz;@~-{eNqfTI|L;Fmwe{Y<m#6gizvI6DeP71jzw__dzI?&Rz;NL8!fS!N
z{$gj6Y8e<99!#BH_y0X#<Wl=5|5;z~P4%j;|0jR%=)%pLvd{0kn0otrjp-)cv#a%I
z*9x3APoDGo<fhPlPC!!{!oy@v-@jM!{?e^=%Rc_UJFn&sKhU@{{U86Y-M+ta&OG~f
zg*HHegnfPg!`Ih5E`MAP<Qe>92a?Z@|Bwe##DKW+t@oB$0aY5j|G~yWj1KH-8vZBc
zWL51DEZ%zdWdH5?-~W~tZZbIk|G3g8OKvCky>B|sJH7a0&3!ff+UZx`XU=`yDDdmh
z<lx88?X4y)`e--h=^X1l3-4UNGmZV}x%#8MMbH0#srdapu|~;Hk8j(K|LI5n=0Dpt
z>s4g%-$Nz4{{Jmr@UwV@&intr%}>|<dtVXp?$3FjZT0ec%l@5DSp6?vRY&ia{X*CO
z%cG9u%=uvz`~UU&t)G9*pLODNv+Mo$4~lCK*!*8J@Bf+4cWo<kd{=*q(tY~>_{=Nc
zcke1WeoZ9v_sTi1|LpI+oqObS`Rkj{?LRgBu?}DQr~db!%?ooXl`nk@&U9hJ9t@+R
iqaiRF0;3@?8UmvsFd70BhrpRD`&VBR-p0V7zyJWnQ+oUW

literal 0
HcmV?d00001

diff --git a/tests/f_deleted_inode_bad_csum/name b/tests/f_deleted_inode_bad_csum/name
new file mode 100644
index 0000000..516701a
--- /dev/null
+++ b/tests/f_deleted_inode_bad_csum/name
@@ -0,0 +1 @@
+deleted inode with a bad csum that wasn't getting fixed (metadata_csum)


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

* [PATCH 13/19] tests: add regression tests for EA blocks with bad checksums
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (11 preceding siblings ...)
  2014-08-01 18:13 ` [PATCH 12/19] e2fsck: always ask to fix an inode that fails checksum verification Darrick J. Wong
@ 2014-08-01 18:13 ` Darrick J. Wong
  2014-08-03  3:42   ` Theodore Ts'o
  2014-08-01 18:13 ` [PATCH 14/19] tests: add tests for handling of corrupt extents Darrick J. Wong
                   ` (5 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:13 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Add regression tests for e2fsck dealing with (a) EA block with a bad
checksum; (b) EA block with a bad magic number; and (c) EA block with
damage that isn't otherwise noticeable.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/f_ea_bad_csum/expect.1 |   29 +++++++++++++++++++++++++++++
 tests/f_ea_bad_csum/expect.2 |    7 +++++++
 tests/f_ea_bad_csum/image.gz |  Bin
 tests/f_ea_bad_csum/name     |    1 +
 4 files changed, 37 insertions(+)
 create mode 100644 tests/f_ea_bad_csum/expect.1
 create mode 100644 tests/f_ea_bad_csum/expect.2
 create mode 100644 tests/f_ea_bad_csum/image.gz
 create mode 100644 tests/f_ea_bad_csum/name

diff --git a/tests/f_ea_bad_csum/expect.1 b/tests/f_ea_bad_csum/expect.1
new file mode 100644
index 0000000..4fc365f
--- /dev/null
+++ b/tests/f_ea_bad_csum/expect.1
@@ -0,0 +1,29 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 has a bad extended attribute block 1074.  Clear? yes
+
+Inode 12, i_blocks is 2, should be 0.  Fix? yes
+
+Extended attribute in inode 13 has a hash (1631637196) which is invalid
+Clear? yes
+
+Inode 13, i_blocks is 2, should be 0.  Fix? yes
+
+Inode 14 extended attribute block 1076 passes checks, but checksum does not match block.  Fix? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences:  -(1074--1075)
+Fix? yes
+
+Free blocks count wrong for group #0 (971, counted=973).
+Fix? yes
+
+Free blocks count wrong (971, counted=973).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 14/128 files (7.1% non-contiguous), 1075/2048 blocks
+Exit status is 1
diff --git a/tests/f_ea_bad_csum/expect.2 b/tests/f_ea_bad_csum/expect.2
new file mode 100644
index 0000000..d83fdfb
--- /dev/null
+++ b/tests/f_ea_bad_csum/expect.2
@@ -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: 14/128 files (7.1% non-contiguous), 1075/2048 blocks
+Exit status is 0
diff --git a/tests/f_ea_bad_csum/image.gz b/tests/f_ea_bad_csum/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..e7a25c512feec33336f18ef0954737e91003269c
GIT binary patch
literal 3176
zcmeIy`&ZH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lK#|5xq65?DuSu9@&0f3b
z$HWHmv1TH`@Qo51DpVH9_UY6qYYQnKa@<|@x3T5?ixqO>@Ejb=i~(d=9Nt*UAp*D)
zCw}w{AAQ|4H1b+h_>!gEbD>)o5o0j%Am<^+G7w|Nav}tGGOPr}AX<Lu4qoOF*;Z11
zWqiDNKC~fW2@J${wyHx0iG|9l>H8`d-t&xqz`U1tX4$2TMlDeI{SjGgjfj(_A9w99
z-oqySz8J!9b36@S%+xJYoy2{fzfx+adZVtcNJcJY{bq>ciA_Zyl<Wk74BJqan)i&k
zEV(tZz%+J5cO2xe8y)G>SyMV&tI=(0RJM-Xgi_09Y0$f6Nz>(ujm||-vKBt!1jetf
zn|?WEz7*vaz7<mRV#2Fdh+Py2x5V~?^UglTp9D36=A+kFw;tX06x6*V0mQs{@@lH!
z7^y-?3fg^q5Nq9<z?#4(FK|(b_Xv}qv5ISd(N68}DtOS3pbPZpynJlM@hT;YcRW=P
zt6I>+Rmd|P$WrQ4_WAj@wJ$fVR#uSDZokTnTJe4-aI^z40pxFzLeJIzKb|MsK6$vc
W0oMdRZ2`h{3@q4p;W7+n5Bm?Qd!Nbx

literal 0
HcmV?d00001

diff --git a/tests/f_ea_bad_csum/name b/tests/f_ea_bad_csum/name
new file mode 100644
index 0000000..958b244
--- /dev/null
+++ b/tests/f_ea_bad_csum/name
@@ -0,0 +1 @@
+EA block with bad checksum (metadata_csum)


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

* [PATCH 14/19] tests: add tests for handling of corrupt extents
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (12 preceding siblings ...)
  2014-08-01 18:13 ` [PATCH 13/19] tests: add regression tests for EA blocks with bad checksums Darrick J. Wong
@ 2014-08-01 18:13 ` Darrick J. Wong
  2014-08-03  3:47   ` Theodore Ts'o
  2014-08-01 18:13 ` [PATCH 15/19] tests: add tests for directory entry blocks with checksum errors Darrick J. Wong
                   ` (4 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:13 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Add some regression tests to examine how e2fsck deals with (a) extent
blocks with only a bad checksum; (b) extent blocks with a bad magic
number; and (c) extent entries with corruption.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/f_extent_bad_node/name            |    2 +-
 tests/f_extent_int_bad_csum/expect.1    |   11 +++++++++++
 tests/f_extent_int_bad_csum/expect.2    |    7 +++++++
 tests/f_extent_int_bad_csum/image.gz    |  Bin
 tests/f_extent_int_bad_csum/name        |    1 +
 tests/f_extent_int_bad_extent/expect.1  |   24 ++++++++++++++++++++++++
 tests/f_extent_int_bad_extent/expect.2  |    7 +++++++
 tests/f_extent_int_bad_extent/image.gz  |  Bin
 tests/f_extent_int_bad_extent/name      |    1 +
 tests/f_extent_int_bad_magic/expect.1   |   23 +++++++++++++++++++++++
 tests/f_extent_int_bad_magic/expect.2   |    7 +++++++
 tests/f_extent_int_bad_magic/image.gz   |  Bin
 tests/f_extent_int_bad_magic/name       |    1 +
 tests/f_extent_leaf_bad_csum/expect.1   |   11 +++++++++++
 tests/f_extent_leaf_bad_csum/expect.2   |    7 +++++++
 tests/f_extent_leaf_bad_csum/image.gz   |  Bin
 tests/f_extent_leaf_bad_csum/name       |    1 +
 tests/f_extent_leaf_bad_extent/expect.1 |   24 ++++++++++++++++++++++++
 tests/f_extent_leaf_bad_extent/expect.2 |    7 +++++++
 tests/f_extent_leaf_bad_extent/image.gz |  Bin
 tests/f_extent_leaf_bad_extent/name     |    1 +
 tests/f_extent_leaf_bad_magic/expect.1  |   23 +++++++++++++++++++++++
 tests/f_extent_leaf_bad_magic/expect.2  |    7 +++++++
 tests/f_extent_leaf_bad_magic/image.gz  |  Bin
 tests/f_extent_leaf_bad_magic/name      |    1 +
 25 files changed, 165 insertions(+), 1 deletion(-)
 create mode 100644 tests/f_extent_int_bad_csum/expect.1
 create mode 100644 tests/f_extent_int_bad_csum/expect.2
 create mode 100644 tests/f_extent_int_bad_csum/image.gz
 create mode 100644 tests/f_extent_int_bad_csum/name
 create mode 100644 tests/f_extent_int_bad_extent/expect.1
 create mode 100644 tests/f_extent_int_bad_extent/expect.2
 create mode 100644 tests/f_extent_int_bad_extent/image.gz
 create mode 100644 tests/f_extent_int_bad_extent/name
 create mode 100644 tests/f_extent_int_bad_magic/expect.1
 create mode 100644 tests/f_extent_int_bad_magic/expect.2
 create mode 100644 tests/f_extent_int_bad_magic/image.gz
 create mode 100644 tests/f_extent_int_bad_magic/name
 create mode 100644 tests/f_extent_leaf_bad_csum/expect.1
 create mode 100644 tests/f_extent_leaf_bad_csum/expect.2
 create mode 100644 tests/f_extent_leaf_bad_csum/image.gz
 create mode 100644 tests/f_extent_leaf_bad_csum/name
 create mode 100644 tests/f_extent_leaf_bad_extent/expect.1
 create mode 100644 tests/f_extent_leaf_bad_extent/expect.2
 create mode 100644 tests/f_extent_leaf_bad_extent/image.gz
 create mode 100644 tests/f_extent_leaf_bad_extent/name
 create mode 100644 tests/f_extent_leaf_bad_magic/expect.1
 create mode 100644 tests/f_extent_leaf_bad_magic/expect.2
 create mode 100644 tests/f_extent_leaf_bad_magic/image.gz
 create mode 100644 tests/f_extent_leaf_bad_magic/name

diff --git a/tests/f_extent_bad_node/name b/tests/f_extent_bad_node/name
index 9c9d79f..0b4ab8c 100644
--- a/tests/f_extent_bad_node/name
+++ b/tests/f_extent_bad_node/name
@@ -1 +1 @@
-bad interior node in extent tree
+bad interior node in extent tree (metadata_csum)
diff --git a/tests/f_extent_int_bad_csum/expect.1 b/tests/f_extent_int_bad_csum/expect.1
new file mode 100644
index 0000000..57a2a61
--- /dev/null
+++ b/tests/f_extent_int_bad_csum/expect.1
@@ -0,0 +1,11 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 extent block passes checks, but checksum does not match extent
+	(logical block 698, invalid physical block 1788, len 1)
+Fix? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 12/128 files (16.7% non-contiguous), 1446/2048 blocks
+Exit status is 0
diff --git a/tests/f_extent_int_bad_csum/expect.2 b/tests/f_extent_int_bad_csum/expect.2
new file mode 100644
index 0000000..6f73d98
--- /dev/null
+++ b/tests/f_extent_int_bad_csum/expect.2
@@ -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: 12/128 files (16.7% non-contiguous), 1446/2048 blocks
+Exit status is 0
diff --git a/tests/f_extent_int_bad_csum/image.gz b/tests/f_extent_int_bad_csum/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..f3878981239804cbd7244abf21b7130a1129df41
GIT binary patch
literal 7202
zcmeHLe^e7^x~{cb+U+Xadb+f_Bz4=$acxaqMU;@FtgE2>h!m0tNFt@0YJ{kWk-<r7
zZKYjBv{+D(M1&B`5K`nv<VO-)ccHC9B+~&UgtSt?86c?45STcbJA41@x%ZrV|GDSf
zv!~x*-#6#`&UxoO&-=X3^RiDp_mpATK=RWIr`*BkQ$7WKKi%6Mz4OKAf7&j+`RL(G
z(#72an>K9QVEcCYC%@nHT-7socEmkoSH=F`6ur-+f5!A?|0~s9X>q?>Q~J`T(`&k3
z+E=uuKWC9hVOrC5rKSI+5&LhGvP8q4$zzfQ%eA)IqJ(^wm8%==y<J%#pSG@5?NKdV
zv`g7?WnQnWZoHg$CR@3#w12PbjQo}UrRC%P2VC_#{;crkh*qVJI-KsCKZ*Ew@~O5V
z_57Z{Rt}{N<R6NuJ~*u(a2%a}#EzUfx!I>_9q1BLjtpgYM`G$VyvNbA!0a!xadF9*
zGA*#G+MsHvJTPuqVfW9Ra1E{qCtKv}75qrc?7qX32LiLV)ddanmEoPHlZJxurA;a>
zwSWsoGzS!}p0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>XR*t
zmG;P~TCL0JyWT%~a+Cy4-`h<l2U&+e+jyAwFy)3lmiyO}6Qze9uMB%DXVTSvWo$0G
z?TNaFy8ryC5FOxrK2E@|Z<MVdW-G^($e4FRHb+clbKL>$ql@;v1sCXsu=FzePR^Jn
z7Ld;5kG<$}9qH5*{tTqe2(HOjc0!G}@R%M&0^R?4!H$5?QtI%n@T%uklY8eiyZqi#
zdZO088lLVbL{-+NaJ47HpnH^lXkJt@dtjc^lGAMnn+nYOhP(|cO*453`!hT*zUtc|
z5LEZu1LK-*v>3S7@}#{rJI4i6svWrjS^ntwkcKPN?60*8XC6KNZ>>~8<8MB(=F@bm
zcbw+=pNw_=6xOoFzJmIInO4Efw2C${Q-^+R0v4ET%c)~T5vmg@W9b5hbZ;@FYms;^
z<v`spTWShKo^o#nm=5SL7o3b;%RqaFy^^D^TSC{5b(B8+Z_pZl{e@pM@IPhX;Vm!y
PwD4$4;Zsk&_SAm>O7k`<

literal 0
HcmV?d00001

diff --git a/tests/f_extent_int_bad_csum/name b/tests/f_extent_int_bad_csum/name
new file mode 100644
index 0000000..87317e3
--- /dev/null
+++ b/tests/f_extent_int_bad_csum/name
@@ -0,0 +1 @@
+bad csum in internal extent (metadata_csum)
diff --git a/tests/f_extent_int_bad_extent/expect.1 b/tests/f_extent_int_bad_extent/expect.1
new file mode 100644
index 0000000..3d2fb58
--- /dev/null
+++ b/tests/f_extent_int_bad_extent/expect.1
@@ -0,0 +1,24 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 has an invalid extent
+	(logical block 0, invalid physical block 4294967295, len 168)
+Clear? yes
+
+Inode 12, i_blocks is 712, should be 542.  Fix? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences:  -(1090--1091) -1093 -1095 -1097 -1099 -1101 -1103 -1105 -1107 -1109 -1111 -1113 -1115 -1117 -1119 -1121 -1123 -1125 -1127 -1129 -1131 -1133 -1135 -1137 -1139 -1141 -1143 -1145 -1147 -1149 -1151 -1153 -1155 -1157 -1159 -1161 -1163 -1165 -1167 -1169 -1171 -1173 -1175 -1177 -1179 -1181 -1183 -1185 -1187 -1189 -1191 -1193 -1195 -1197 -1199 -1201 -1203 -1205 -1207 -1209 -1211 -1213 -1215 -1217 -1219 -1221 -1223 -1225 -1227 -1229 -1231 -1233 -1235 -1237 -1239 -1241 -1243 -1245 -1247 -1249 -1251 -1253 -1255 -1257
+Fix? yes
+
+Free blocks count wrong for group #0 (602, counted=687).
+Fix? yes
+
+Free blocks count wrong (602, counted=687).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/128 files (16.7% non-contiguous), 1361/2048 blocks
+Exit status is 1
diff --git a/tests/f_extent_int_bad_extent/expect.2 b/tests/f_extent_int_bad_extent/expect.2
new file mode 100644
index 0000000..4e72e41
--- /dev/null
+++ b/tests/f_extent_int_bad_extent/expect.2
@@ -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: 12/128 files (16.7% non-contiguous), 1361/2048 blocks
+Exit status is 0
diff --git a/tests/f_extent_int_bad_extent/image.gz b/tests/f_extent_int_bad_extent/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..e8745bff45f2a1f226ba59278bcaf7868e4533c8
GIT binary patch
literal 7205
zcmeHLeN+=?zOHMxcDJk9*0W2iC8_=5cCAJi5hNt3>nbQ8kwOvyNu*S%Vu%(oGB`=C
zRoeQ2RtpM}h!BDq!iancn8emDSQR3PlPC~UrHC_pL}iA+gvspe{jcZVbMF1;o^#Kh
z&R_G+dEay1`JLx^e$Vsc9C`7%vW2ds-^?C!vrZ=;0(}qeZ(Y6l<=;KnD7*gj$t$vX
zovt+z8zL+>7Jc!@H7`~?e`izd6HZ0UA5E)wnDoz^-f_NK*^wIihvmhutU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mR{A+VMB8E-|B?89QtS(%t02C9ih{I|@QC`e+9ktg#*!QDhHu19k1C1Osw<tljw
z{}a+#EtT5h<tcowxtg59#YjjsT&LB^(#&s|>wpZh6kCfD$Potvmi2NeHKb~B`e%iW
z(qq1;?JvDpz)S>HV|1U4QWtF3)<F*x<}}*5fAb|x+w_9(Ea;=BpHudQ7H3r3{bw6r
zyK}Q$s}y22+f?Nf8-0HV#-c1ep=x)(bLyfuU*X>)MPIXGnWm?l{*3*;p@QJNyO*2~
z#-s-K-P|;i?P}}4v{_!Xygg2XoiAy(`DT77ud^1Ae#z^qn?J@T2!_7+$1yNXdiQnV
zf0TIOR(Vv$(}zi-$PBczFl_Qx)quq@W9sb(sh6x4v%=8l2^CC)D_9dA;^UELoZhY(
z)_PmEz!vpULEmwo_rzvVb|8B4{X?oSCco9>n@~^WZq_Xtbv~OO_`%JkkMoz%teqbB
zGmRT}Z6!h9GOAA1+~I8>!9&%tORYQX?4`8cIW~n?xjg}GpF2#SXQ}(jG{SpxaNzN9
z)?Ly?&v+xKL{W3G+|}HrC}^YSWp~qy;hA%O<uF>*h5NP(WbEDc*9<J>sN=@;-g0%(
zp^}-$2nzEbepS)@*`;tV?Qv2w)-0W;KVqh8<s*hZwG4gQ82VVn@{)m65F`!%npnZi
z#Hs<Ci)!G3GwN2d8lS|<917yf!~Z@}QNLII+<d)bzw5()gYNk2FZ^18|FHt<`;^?e
N<Z{k)&%N>7KLJX2H(US!

literal 0
HcmV?d00001

diff --git a/tests/f_extent_int_bad_extent/name b/tests/f_extent_int_bad_extent/name
new file mode 100644
index 0000000..e22f6b4
--- /dev/null
+++ b/tests/f_extent_int_bad_extent/name
@@ -0,0 +1 @@
+bad extent in internal extent (metadata_csum)
diff --git a/tests/f_extent_int_bad_magic/expect.1 b/tests/f_extent_int_bad_magic/expect.1
new file mode 100644
index 0000000..0e82e2b
--- /dev/null
+++ b/tests/f_extent_int_bad_magic/expect.1
@@ -0,0 +1,23 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 has an invalid extent node (blk 1295, lblk 0)
+Clear? yes
+
+Inode 12, i_blocks is 712, should be 0.  Fix? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences:  -(1090--1093) -1095 -1097 -1099 -1101 -1103 -1105 -1107 -1109 -1111 -1113 -1115 -1117 -1119 -1121 -1123 -1125 -1127 -1129 -1131 -1133 -1135 -1137 -1139 -1141 -1143 -1145 -1147 -1149 -1151 -1153 -1155 -1157 -1159 -1161 -1163 -1165 -1167 -1169 -1171 -1173 -1175 -1177 -1179 -1181 -1183 -1185 -1187 -1189 -1191 -1193 -1195 -1197 -1199 -1201 -1203 -1205 -1207 -1209 -1211 -1213 -1215 -1217 -1219 -1221 -1223 -1225 -1227 -1229 -1231 -1233 -1235 -1237 -1239 -1241 -1243 -1245 -1247 -1249 -1251 -1253 -1255 -1257 -1259 -1261 -1263 -1265 -1267 -1269 -1271 -1273 -1275 -1277 -1279 -1281 -1283 -1285 -1287 -(1289--1298) -1300 -1302 -1304 -1306 -1308 -1310 -1312 -1314 -1316 -1318 -1320 -1322 -1324 -1326 -1328 -1330 -1332 -1334 -1336 -1338 -1340 -1342 -1344 -1346 -1348 -1350 -1352 
 -1354 -1356 -1358 -1360 -1362 -1364 -1366 -1368 -1370 -1372 -1374 -1376 -1378 -1380 -1382 -1384 -1386 -1388 -1390 -1392 -1394 -1396 -1398 -1400 -1402 -1404 -1406 -1408 -1410 -1412 -1414 -14!
 16 -1418 -1420 -1422 -1424 -1426 -1428 -1430 -1432 -1434 -1436 -1438 -1440 -1442 -1444 -1446 -1448 -1450 -1452 -1454 -1456 -1458 -1460 -1462 -1464 -1466 -1468 -1470 -1472 -1474 -1476 -1478 -1480 -1482 -1484 -1486 -1488 -1490 -1492 -1494 -1496 -1498 -1500 -1502 -1504 -1506 -1508 -1510 -1512 -1514 -1516 -1518 -1520 -1522 -1524 -1526 -1528 -1530 -1532 -1534 -1536 -1538 -1540 -1542 -1544 -1546 -1548 -1550 -1552 -1554 -1556 -1558 -1560 -1562 -1564 -1566 -1568 -1570 -1572 -1574 -1576 -1578 -1580 -1582 -1584 -1586 -1588 -1590 -1592 -1594 -1596 -1598 -1600 -1602 -1604 -1606 -1608 -1610 -1612 -1614 -1616 -1618 -1620 -1622 -1624 -1626 -1628 -1630 -1632 -1634 -1636 -1638 -1640 -1642 -1644 -1646 -1648 -1650 -1652 -1654 -1656 -1658 -1660 -1662 -1664 -1666 -1668 -1670 -1672 -1674 -1676 -1678 -1680 -168
 2 -1684 -1686 -1688 -1690 -1692 -1694 -1696 -1698 -1700 -1702 -1704 -1706 -1708 -1710 -1712 -1714 -1716 -1718 -1720 -1722 -1724 -1726 -1728 -1730 -1732 -1734 -1736 -1738 -1740 -1742 -1744 -!
 1746 -1748 -1750 -1752 -1754 -1756 -1758 -1760 -1762 -1764 -17!
 66 -1768 -1770 -1772 -1774 -1776 -1778 -1780 -1782 -1784 -1786 -1788
+Fix? yes
+
+Free blocks count wrong for group #0 (602, counted=958).
+Fix? yes
+
+Free blocks count wrong (602, counted=958).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/128 files (8.3% non-contiguous), 1090/2048 blocks
+Exit status is 1
diff --git a/tests/f_extent_int_bad_magic/expect.2 b/tests/f_extent_int_bad_magic/expect.2
new file mode 100644
index 0000000..283cc1f
--- /dev/null
+++ b/tests/f_extent_int_bad_magic/expect.2
@@ -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: 12/128 files (8.3% non-contiguous), 1090/2048 blocks
+Exit status is 0
diff --git a/tests/f_extent_int_bad_magic/image.gz b/tests/f_extent_int_bad_magic/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..e00f887cca9e8d6b139083ac51c54b46f0e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02`7oGynhq

literal 0
HcmV?d00001

diff --git a/tests/f_extent_int_bad_magic/name b/tests/f_extent_int_bad_magic/name
new file mode 100644
index 0000000..a451e9a
--- /dev/null
+++ b/tests/f_extent_int_bad_magic/name
@@ -0,0 +1 @@
+bad magic number in internal extent (metadata_csum)
diff --git a/tests/f_extent_leaf_bad_csum/expect.1 b/tests/f_extent_leaf_bad_csum/expect.1
new file mode 100644
index 0000000..0dc78ad
--- /dev/null
+++ b/tests/f_extent_leaf_bad_csum/expect.1
@@ -0,0 +1,11 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 extent block passes checks, but checksum does not match extent
+	(logical block 7, invalid physical block 1090, len 1)
+Fix? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 12/128 files (16.7% non-contiguous), 1099/2048 blocks
+Exit status is 0
diff --git a/tests/f_extent_leaf_bad_csum/expect.2 b/tests/f_extent_leaf_bad_csum/expect.2
new file mode 100644
index 0000000..a564763
--- /dev/null
+++ b/tests/f_extent_leaf_bad_csum/expect.2
@@ -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: 12/128 files (16.7% non-contiguous), 1099/2048 blocks
+Exit status is 0
diff --git a/tests/f_extent_leaf_bad_csum/image.gz b/tests/f_extent_leaf_bad_csum/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..6c778f699725e9db8d94c9c464f3a687a714d757
GIT binary patch
literal 5005
zcmeH}`%{xw8pr9jN~=Y*UO+BJmyQ)sBC8U)gmj^ndSQcH1O<~y)EI+AKnUUX)>6O%
z!nP7ngF&jGAST?AOA--6Dk!K35kiP0zMvq4B!mQ#yl2_j&g|^&U$8Tt@64Hb&JSmv
z`8?0_JqMNZsaf-CanPSWo|anVh78;=n>CEuF1PkRoxQvwvN(4=>363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XlP2lEUR|qs47vhFgut)eh&KvSOik~Xto{+10FKA!lJw_QK*nD?
zjHABJF4QGt2KSW!ROqdD`S>3c8sIt$A_gXa^3@mK0CZmNh%Z(WUu(e5!4M(Xy2;N-
z8xop=$~}_*%a=cd9|(LP@PWVw0{=e*NPa=GpWbIy#%{rf?&<Wp%^mL%*0+60bSZ<W
zYB;mLZ7<QfsF2%RWZSR)ErpSCj9<IO8&sj2iZmrvlS91One9}@TqxW&QGAtNCPE>w
z1Xd%+Xe@uuvto23rIk_B7M=D)c1UsxJ?&Iv2x0&P(+$5Pcc~}SRSRy>m$e)2Xot*e
zMws1kqp9~I_!uUptS!#y3~MDp401O;0yU*H`KBO9eHzIFVNVfUChB^#r_lZj@&ega
zHK%~?y+#sGb87Me$C^im*GL4a!Nj)vWRaRxF>3Cp#54N3_4>JMHD1mzR;V}T1U1LE
zvtJ>>ge&SS%T9%?p!<ecG<^iJ)42DLT0NUOV-0?;O1!pCssb^KLlodBGbrjoFu?;;
z=t;b+&5Ap}x%(K)+mvcCPNSfLIcL1u)1J4q?z)%uXt2rC91A8bVxY1GWic)wwN2B-
uBcvLci_9dZIxmOB^RY0bEqMLu|EEJfWcqIc4<}xOkDOebhRn=1oBado2k!U)

literal 0
HcmV?d00001

diff --git a/tests/f_extent_leaf_bad_csum/name b/tests/f_extent_leaf_bad_csum/name
new file mode 100644
index 0000000..62a2285
--- /dev/null
+++ b/tests/f_extent_leaf_bad_csum/name
@@ -0,0 +1 @@
+bad csum in leaf extent (metadata_csum)
diff --git a/tests/f_extent_leaf_bad_extent/expect.1 b/tests/f_extent_leaf_bad_extent/expect.1
new file mode 100644
index 0000000..f96a8a9
--- /dev/null
+++ b/tests/f_extent_leaf_bad_extent/expect.1
@@ -0,0 +1,24 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 has an invalid extent
+	(logical block 2, invalid physical block 4294967295, len 1)
+Clear? yes
+
+Inode 12, i_blocks is 18, should be 16.  Fix? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences:  -1096
+Fix? yes
+
+Free blocks count wrong for group #0 (949, counted=950).
+Fix? yes
+
+Free blocks count wrong (949, counted=950).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/128 files (16.7% non-contiguous), 1098/2048 blocks
+Exit status is 1
diff --git a/tests/f_extent_leaf_bad_extent/expect.2 b/tests/f_extent_leaf_bad_extent/expect.2
new file mode 100644
index 0000000..de1727c
--- /dev/null
+++ b/tests/f_extent_leaf_bad_extent/expect.2
@@ -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: 12/128 files (16.7% non-contiguous), 1098/2048 blocks
+Exit status is 0
diff --git a/tests/f_extent_leaf_bad_extent/image.gz b/tests/f_extent_leaf_bad_extent/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..d34d4d4d51d24e4de54f6b38beedc831d8c2d266
GIT binary patch
literal 5008
zcmeH}`BRhU7ROOLwJx|^DhMKhv5F|G77<yZPz6PA1O#MF0VyJzED}NpZynh*ELK@$
zFM_g(QGzH0NI^nus7X;E$dZ)AutQAJkc1@fbJN~?XRdSa{R2AVb7r2I^V@ko=lh)R
zK@h&s(9mLeu3fh@sTmbGjMw;}U?=GFQb#rS*KSJ>JG0H{#_>bipJ{DLzwK?9QEHf-
z{{9hlM_8?I_(k`xT<?9eFMa4jy{_I;uZ!`CyQhaQJ9%up<@ZhX*F#3%2bbN?vG9uY
z^{~Bn?tZegGr_=~mgE}piX={>%*rMbIPC&<0xyBx4y4MMqBW8$=VXHgVUyUl2L)jc
z*r58yziNBdv);a8wI4xIqpm(lKvxF{Ue4hw3L6WT9@h5m#jX%SiY6y+hjBQ`UW$=i
zLaD(-C#fcOX)9}Ys{YJmM@#r(bA)c&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E!`yDx}ub;BHt&TXG
zBC;oT*`HWEAgvW;7GTb?eS;|0g;j3yyvPt$7j%n>ygfoh(Kt8>fuG7~h*M>lpvy%I
z9_$LyV_GPA`80ndJjlFw{8*@h#rZP-`BLk}G_zrx4S$`9pv&6PF(Jv6c^VsQ<p{VJ
zV#tZ8DChvEQk1o&kH@)94`lT%dE>W<+Xq6)<RjF0n!*a<Dj`j(_qyqb2w=id@LIuz
zpko$A<e*y;7xCb?1<$M@r9#hibjYeUU@*Brbw3*8<E=`Mj!o3W!d?qp_{=7@edLqX
z<QY`TgH_o<$wA2h{_YuCN`~Hw>W>{~%^t(Qj!HgN`X2<UGQj$Jzy0nS8ipGG076{(
AwEzGB

literal 0
HcmV?d00001

diff --git a/tests/f_extent_leaf_bad_extent/name b/tests/f_extent_leaf_bad_extent/name
new file mode 100644
index 0000000..1bd8bd1
--- /dev/null
+++ b/tests/f_extent_leaf_bad_extent/name
@@ -0,0 +1 @@
+bad extent in leaf extent (metadata_csum)
diff --git a/tests/f_extent_leaf_bad_magic/expect.1 b/tests/f_extent_leaf_bad_magic/expect.1
new file mode 100644
index 0000000..7b6dbf1
--- /dev/null
+++ b/tests/f_extent_leaf_bad_magic/expect.1
@@ -0,0 +1,23 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 has an invalid extent node (blk 1604, lblk 0)
+Clear? yes
+
+Inode 12, i_blocks is 18, should be 0.  Fix? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences:  -(1090--1097) -1604
+Fix? yes
+
+Free blocks count wrong for group #0 (949, counted=958).
+Fix? yes
+
+Free blocks count wrong (949, counted=958).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/128 files (8.3% non-contiguous), 1090/2048 blocks
+Exit status is 1
diff --git a/tests/f_extent_leaf_bad_magic/expect.2 b/tests/f_extent_leaf_bad_magic/expect.2
new file mode 100644
index 0000000..283cc1f
--- /dev/null
+++ b/tests/f_extent_leaf_bad_magic/expect.2
@@ -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: 12/128 files (8.3% non-contiguous), 1090/2048 blocks
+Exit status is 0
diff --git a/tests/f_extent_leaf_bad_magic/image.gz b/tests/f_extent_leaf_bad_magic/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..7dd044ffc430e1e7f3750fa628984e750ede9006
GIT binary patch
literal 5008
zcmeH}YfzI{8pmmEi>*|kUZ4U-*4+Xs1_}tuB~_}nqM}@i0U_e0C<x&qn+5`}tw6X4
zXt@NrrB)4sKo&$(2uZBmG!dd8L5WEUkwl0|Od?4j$$K_!cRzG?W@l&iOFwwd%$Ygw
z%zNgX-}8U|&x0sgYB69l5&rfPx!}X|k>d>(uM9$~B~}Qpo#!Gv_YM|&9$%H8>Dd!+
z^ZDe-@0>jM9R2jP%$t|rDY)3?d@yyzQ~Qe1n$EA2?NB{MtGArueRtr7bKB+U5~t5U
z76@#3RBwLIL#r}+QKq&LH*(I`<J_I4*n$Pqy-OL~94RxKdtwAHg++C^n^yMCygbCQ
z&elNg?Z?N_yBqB`Z1f&jIhW~u=2rV~xTj2>9C*NW+;IG8R8n^$o}Sj6n%rpmvE~GB
z{OhMWU*VJ9O!0S~<;lYF(OX)gtSqREL!!R0CnT*YLwiw<;%8bzXrjPlkE&hP9^yUg
z)@$AJcZ6(V+9Q_9uPfW{CvKdx3)hs)UP7|R?9^x0p+ehC3RXwxsYICiFtlxQM}W(L
zeI(-m9<iUTkp#q|=YZ3KGRrt%RAe8E@$W2!>`(IfYw?QZ2{smg96<<1@Xq*DxqU`r
zUE6HF?Ir?kSl@b}cT<Td!z*axY9xJAE|J@f&QVcW^E4-~NmeGem`WV#d^uCQBmPqS
zih^6cNF`lKW_6@IJ7@wppAN7j0SB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3u(?#8!e7a8M-243jB~a9VCcRb#neOq<zsL-Ue$Ui
sCEJ~cxYxuu_<!}3h+N$S@%-68mlEFG=6@tWSPLWk*XX{quvlmDPgsKH9{>OV

literal 0
HcmV?d00001

diff --git a/tests/f_extent_leaf_bad_magic/name b/tests/f_extent_leaf_bad_magic/name
new file mode 100644
index 0000000..e9f756e
--- /dev/null
+++ b/tests/f_extent_leaf_bad_magic/name
@@ -0,0 +1 @@
+bad magic number in leaf extent (metadata_csum)


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

* [PATCH 15/19] tests: add tests for directory entry blocks with checksum errors
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (13 preceding siblings ...)
  2014-08-01 18:13 ` [PATCH 14/19] tests: add tests for handling of corrupt extents Darrick J. Wong
@ 2014-08-01 18:13 ` Darrick J. Wong
  2014-08-03  3:49   ` Theodore Ts'o
  2014-08-01 18:13 ` [PATCH 16/19] tests: add regression tests for MMP blocks with bad checksums Darrick J. Wong
                   ` (3 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:13 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Add some regression tests to examine how e2fsck handles directory
entry blocks and htree blocks with (a) malformed directory entries;
(b) incorrect checksums; or (c) obviously garbage entries.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/f_dir_bad_csum/expect.1   |   62 +++++++++++++++++++++++++++++++++++++++
 tests/f_dir_bad_csum/expect.2   |    7 ++++
 tests/f_dir_bad_csum/image.gz   |  Bin
 tests/f_dir_bad_csum/name       |    1 +
 tests/f_htree_bad_csum/expect.1 |   28 ++++++++++++++++++
 tests/f_htree_bad_csum/expect.2 |    7 ++++
 tests/f_htree_bad_csum/image.gz |  Bin
 tests/f_htree_bad_csum/name     |    1 +
 8 files changed, 106 insertions(+)
 create mode 100644 tests/f_dir_bad_csum/expect.1
 create mode 100644 tests/f_dir_bad_csum/expect.2
 create mode 100644 tests/f_dir_bad_csum/image.gz
 create mode 100644 tests/f_dir_bad_csum/name
 create mode 100644 tests/f_htree_bad_csum/expect.1
 create mode 100644 tests/f_htree_bad_csum/expect.2
 create mode 100644 tests/f_htree_bad_csum/image.gz
 create mode 100644 tests/f_htree_bad_csum/name

diff --git a/tests/f_dir_bad_csum/expect.1 b/tests/f_dir_bad_csum/expect.1
new file mode 100644
index 0000000..bbcbfcb
--- /dev/null
+++ b/tests/f_dir_bad_csum/expect.1
@@ -0,0 +1,62 @@
+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.
+Fix? yes
+
+Directory inode 13, block #0, offset 0: directory has no checksum.
+Fix? yes
+
+Directory inode 13, block #0, offset 1012: directory passes checks but fails checksum.
+Fix? yes
+
+Directory inode 14, block #0, offset 0: directory has no checksum.
+Fix? yes
+
+Directory inode 14, block #0, offset 12: directory passes checks but fails checksum.
+Fix? yes
+
+Directory inode 15, block #0, offset 0: directory has no checksum.
+Fix? yes
+
+Directory inode 15, block #0, offset 1000: directory corrupted
+Salvage? yes
+
+Directory inode 16, block #0, offset 0: directory has no checksum.
+Fix? yes
+
+Directory inode 16, block #0, offset 12: directory corrupted
+Salvage? yes
+
+Directory inode 17, block #0, offset 0: directory has no checksum.
+Fix? yes
+
+Directory inode 17, block #0, offset 0: directory corrupted
+Salvage? yes
+
+Missing '.' in directory inode 17.
+Fix? yes
+
+Setting filetype for entry '.' in ??? (17) to 2.
+Missing '..' in directory inode 17.
+Fix? yes
+
+Setting filetype for entry '..' in ??? (17) to 2.
+Entry 'file' in ??? (18) has invalid inode #: 4294967295.
+Clear? yes
+
+Pass 3: Checking directory connectivity
+'..' in /6 (17) is <The NULL inode> (0), should be / (2).
+Fix? yes
+
+Pass 3A: Optimizing directories
+Pass 4: Checking reference counts
+Unattached inode 19
+Connect to /lost+found? yes
+
+Inode 19 ref count is 2, should be 1.  Fix? yes
+
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 19/128 files (5.3% non-contiguous), 1098/2048 blocks
+Exit status is 1
diff --git a/tests/f_dir_bad_csum/expect.2 b/tests/f_dir_bad_csum/expect.2
new file mode 100644
index 0000000..f5a3e5f
--- /dev/null
+++ b/tests/f_dir_bad_csum/expect.2
@@ -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: 19/128 files (5.3% non-contiguous), 1098/2048 blocks
+Exit status is 0
diff --git a/tests/f_dir_bad_csum/image.gz b/tests/f_dir_bad_csum/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..4b581876f07c1ec989ef85977dc53741b6356130
GIT binary patch
literal 3499
zcmeH{=~Gi@6vk27(kdFKSc$SkIw-aXxQv2^a1}bGE)Yjh6dD;>6j>4=KvWDDi-5`!
z8Y+vTSBrqC5DN$rC8;2bS_#Xr3AwQ($exgd?BTwpAN>~`&dmAnd^mIF{GM|TA?s_C
zzRd%E%S~s6!4VXOjmeydq^b7ltvdixr?&)}SAOSxyteo_@$}SGIsL{3&G%79X4VCq
z+t3_nu=fe*Hw!nd#5LdjZG{E0_UETRJlhfF5bnl2sa|8|k!>EnYHPmF{_62UI+;PI
zbDGw?rd))OxoKHRKAkSr6dFk53}14J!xwk`eA-~HC*J3gvUN>c5BJFP=G@1xRCh#s
zD7>PAkO%&6=;`UIPV>Ws%45obDo*Ff?c*++?W~>CV;c=Li`F!QS&BYC03=9Q{7W2+
zIkG)zeo#?5NvXO2=!|~8%ZetmL80xcH}$nH6d}Fp$TNp|`yow;wNTl5<l#xEG6V64
z<Ke*FW#P^-74a>z8mF7XcT&FF@c7t|VKK{R=M{a!F44Zztn%;(JJ8<Djr__zB@%o6
zS8RO!P?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{5TFM5&knjO0yb|O!I}XPI2XrMbv60z1
zFggx?ZM=<u7eEuu6~2(jMH4av5{;5df>B0@U+LIc*hcJviN~_MTt051Lj8~IFqb+!
zF!dP)U6Xj=&Eo}%`3<dFevduIBH_ib^bHH+Dm53b4YO2{S7CT@SqAMf1&Rke4o{87
z6e_=MAWZkI0hU48U|+r#8C)wygt4-I6q5Ykz|n>;hqA$GBkq&?|3svMD*QUz%a+sw
zZ*S(2aLyj8L`opHx5gt(kSxqA$gxXC<AOWxFw8%xS`teHmI!=~1iGlCm1TM6<%#S9
z*Q^6O+#XOqY!(;>94l8Xe%$TAv0+xLxtWuw1G&b`TsKT`*ggJUgEKfQff9bgf-h(k
z(ZLiflWolO?Esd(CC|$@-KED=6EV$|87+acs&nn3^zIgK+unn*N*mzK-f7m}){e_T
eCi*vijx?8MS|ae75~%BgmvwK;FEcUOX!0LSB4$+p

literal 0
HcmV?d00001

diff --git a/tests/f_dir_bad_csum/name b/tests/f_dir_bad_csum/name
new file mode 100644
index 0000000..140ae45
--- /dev/null
+++ b/tests/f_dir_bad_csum/name
@@ -0,0 +1 @@
+dir block w/ missing/bad csum, no tail, or dir block corruption (metadata_csum)
diff --git a/tests/f_htree_bad_csum/expect.1 b/tests/f_htree_bad_csum/expect.1
new file mode 100644
index 0000000..258362b
--- /dev/null
+++ b/tests/f_htree_bad_csum/expect.1
@@ -0,0 +1,28 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Problem in HTREE directory inode 12: root node fails checksum.
+Clear HTree index? yes
+
+Problem in HTREE directory inode 18: root node fails checksum.
+Clear HTree index? yes
+
+Directory inode 24, block #0, offset 1020: directory corrupted
+Salvage? yes
+
+Problem in HTREE directory inode 24: root node fails checksum.
+Clear HTree index? yes
+
+Problem in HTREE directory inode 30: root node fails checksum.
+Clear HTree index? yes
+
+Problem in HTREE directory inode 36: root node fails checksum.
+Clear HTree index? yes
+
+Pass 3: Checking directory connectivity
+Pass 3A: Optimizing directories
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 47/128 files (2.1% non-contiguous), 1108/2048 blocks
+Exit status is 1
diff --git a/tests/f_htree_bad_csum/expect.2 b/tests/f_htree_bad_csum/expect.2
new file mode 100644
index 0000000..7e3523b
--- /dev/null
+++ b/tests/f_htree_bad_csum/expect.2
@@ -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: 47/128 files (2.1% non-contiguous), 1108/2048 blocks
+Exit status is 0
diff --git a/tests/f_htree_bad_csum/image.gz b/tests/f_htree_bad_csum/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..def571c7900f39bf236a52f0086fccb54049c8c2
GIT binary patch
literal 5462
zcmeHKX;c&0x^-y9;VCLA(oxebB3>180U^p%t?33MDz-xdGNfBXK!gAhkSTS&h)9EA
zBSVWqur;IwH6lY~vRZ+J83h3uBP2jWfDi&?s?>Qw?X}*0@2&NI-}S6jtJXTF>U?L{
z{`R-ODtyAS1+lw2PcB+K(YNyH`u5uk-e;F~elu0?@KP3Izh;fG_JOrQ=06MV)^2~k
zqu9jNcF~5IWTThM-aPWr6XYJcni|x;>*1Ngv)>jn<C&Z8Z+dL7<Ib8j>wi1sEZDth
zAh)`E)1zJ+@5!Rohu9ad)9$HMzgLZp-gb~OZqt<FwrJL^FLvgYO4!Y0Q=3yV;`X}K
z;~5tyfu|zl*;cgInGXw6Q%Xu6x*ksJJi08oEh87=P-kC0KW=mSSV{u!mXHZ?EVf$b
zcn#?ARl~#F4Bd)y0q}gs%xLOX`;<lhcyuIlDB+qh9ZMh5;dp@eoyjgi@}iT6nI}_n
zgH<$>Bx9=i_8aDGf>Ra22@KKi%`EeB@L@f)>Z8jhwr<&orG`%DaZg0v`NsZ?$;5ED
z4XKZq`b!!H8O&tNX%C0>q_4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J>QQ&IKO0SS!<4#@SNv~<
z@_Ftv1D_fAw`E{zAafV<RKV(x{i%;v4F%I^DjKty930~8x}qV08}Qu97AoJD^5pA&
zZfi+vZC7mCrIr3qEsI_jED4CYJExlUe@Sm|kzZegAWFsfgGis4`35vP@?Dph%_y0w
z*DpT}slMCFkGyK(V?^D3W3J1PmA*>Uy*W~OHCJ-04deR@1o@GZXE8i2_O~IRRl739
zV;b~M0*V}aUMR}|qLF*6A{xNT48S)(+t*Vm1a()Y;pM>#r68B_XguWgY6YCH05WCu
z*VF$L9#_BtGT`|l0!xh<0?Kfom?|NNZ2*RZyV7FP5U3mYw6^I^vwKK25GWa!SLYmx
z9^4szpw%8@^r+z$MsZ){1C#=3`@eR=D9=&2t+7NAEd*ppfqYT=4+TiK?KGYMUn}5>
zG1l)=@S#P0z}&gIV)z%wS}-epy>#)={J!imUrCUC1GshI)4q{sY&pjo{%z&*8Te-g
z{vR-K{9Fvl_weDN;o}*kuI}T;L?Q=r8oRsQDXy6Lw8CfnTDd@4n4qt>ZqR>^|Lz-i
z-JR=Rzh0V8!fkeaZ&7<cce@MR?}CpU`*qAa>f0-PiaIKET^#z+8e`X}0A`rg3;WC#
uQiPIdXP=mk>5^6-Ms)Cn|MI^u0rY<`x_orrD!#$gguQ&Ge8GaR7W^mWdKZ}h

literal 0
HcmV?d00001

diff --git a/tests/f_htree_bad_csum/name b/tests/f_htree_bad_csum/name
new file mode 100644
index 0000000..ebfc3ea
--- /dev/null
+++ b/tests/f_htree_bad_csum/name
@@ -0,0 +1 @@
+htree block w/ missing/bad csum, bad protective dirent, or htree index corruption (metadata_csum)


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

* [PATCH 16/19] tests: add regression tests for MMP blocks with bad checksums
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (14 preceding siblings ...)
  2014-08-01 18:13 ` [PATCH 15/19] tests: add tests for directory entry blocks with checksum errors Darrick J. Wong
@ 2014-08-01 18:13 ` Darrick J. Wong
  2014-08-03  3:49   ` Theodore Ts'o
  2014-08-01 18:13 ` [PATCH 17/19] tests: add regression tests for superblocks " Darrick J. Wong
                   ` (2 subsequent siblings)
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:13 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Add regression tests to examine how e2fsck deals with MMP blocks with
(a) a bad magic number; and (b) an incorrect checksum.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/unix.c                  |    4 +++-
 tests/m_mmp_bad_csum/expect    |    9 +++++++++
 tests/m_mmp_bad_csum/image.gz  |  Bin
 tests/m_mmp_bad_csum/name      |    1 +
 tests/m_mmp_bad_csum/script    |   30 ++++++++++++++++++++++++++++++
 tests/m_mmp_bad_magic/.log     |    9 +++++++++
 tests/m_mmp_bad_magic/expect   |    9 +++++++++
 tests/m_mmp_bad_magic/image.gz |  Bin
 tests/m_mmp_bad_magic/name     |    1 +
 tests/m_mmp_bad_magic/script   |   30 ++++++++++++++++++++++++++++++
 10 files changed, 92 insertions(+), 1 deletion(-)
 create mode 100644 tests/m_mmp_bad_csum/expect
 create mode 100644 tests/m_mmp_bad_csum/image.gz
 create mode 100644 tests/m_mmp_bad_csum/name
 create mode 100644 tests/m_mmp_bad_csum/script
 create mode 100644 tests/m_mmp_bad_magic/.log
 create mode 100644 tests/m_mmp_bad_magic/expect
 create mode 100644 tests/m_mmp_bad_magic/image.gz
 create mode 100644 tests/m_mmp_bad_magic/name
 create mode 100644 tests/m_mmp_bad_magic/script

diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index d883c9e..f71afbc 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1166,7 +1166,9 @@ check_error:
 			ext2fs_mmp_clear(fs);
 			retval = 0;
 		}
-	}
+	} else
+		com_err(ctx->program_name, retval, "%s",
+			_("while reading MMP block"));
 	return retval;
 }
 
diff --git a/tests/m_mmp_bad_csum/expect b/tests/m_mmp_bad_csum/expect
new file mode 100644
index 0000000..e15e7b4
--- /dev/null
+++ b/tests/m_mmp_bad_csum/expect
@@ -0,0 +1,9 @@
+Superblock MMP block checksum does not match MMP block.  Fix? yes
+
+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: 11/128 files (0.0% non-contiguous), 19/512 blocks
+Exit status is 0
diff --git a/tests/m_mmp_bad_csum/image.gz b/tests/m_mmp_bad_csum/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..c896ff60dbbdf68a566007262c54a99b0b912fde
GIT binary patch
literal 2594
zcmb2|=3qEtbUm1f`R!fX4B<cqh6m->JGQP}+o9CR^Xh@pHia(x6(L^Y2jyR^P-qG}
z5_V9{qj05&pdgo(hLr|~)((rV2LY_%?Bb#>EaHJ(&UclLo$e2E(#}}Ab?1BT_j~tD
z-~Hs??%l_$rz>+ZdaRyUB+@>?cT%TDi_==0b*-nEl(#+=S}Yy^wKYKNYi*~~7wve_
ztCy}trDadD$>w^PqSkWq{89d$%lD?|&A+?z_0y{dXa7ug{(1PXI$IwvFaO!l*zJ4j
zw<uL7`hUCj@1cM4^|F{Ar}B*M<=0-{Kc(8AHCu=4Z15>#&xcm+a-ZK6?pfuo&EW8B
zO8frPlQ(QL`lqk*(`RYT=a27`TLWrrFISZp>&s=>GB7YiNO*Z0J&eArbB!Iy`&a$+
z{r}reBIRwb_A=xu_E}r6{{CU#+l)?jKmMoJzt7j3WA!SE6R1$fBv)~db<N^h-|V}8
z{wKSa{^JLVnjHJHzheE5J%9dWw|@ij8{FppUoW$>=I$SPAn(k7Mxaou{eSxn<@p{?
zFQ5O9=YMuS=f<{|@9%HV{t&Y7^@%g<^)G$-5U=t7-|{e^4kEyUiBrU`KLr`w_Lz%<
z2o1QD)F+iZUcGOA;yOFy>hyoFZ8utXPV)`_zwAPc=jy`KDI!L}*SfX5&zxJ{uK488
zho!&%PMDVb?&0Z@`Nex%ORn!Pt>5+fzuK(-xe}K1T^`@P{G~o{?ep13|E)cJJ^cHF
zl%4;pi|p6_y??3prQN^kPcPT~pZfOme%{AVKl*<!c|6}@&A+oh)PuP<7rqPl`6vJX
qjBB4kAvOv|Ltr!nMnhmU1V%$(Gz4f70uA-=*?&|mS7u;PU;qF)f;ad8

literal 0
HcmV?d00001

diff --git a/tests/m_mmp_bad_csum/name b/tests/m_mmp_bad_csum/name
new file mode 100644
index 0000000..61c31d4
--- /dev/null
+++ b/tests/m_mmp_bad_csum/name
@@ -0,0 +1 @@
+mmp with bad csum (metadata_csum)
diff --git a/tests/m_mmp_bad_csum/script b/tests/m_mmp_bad_csum/script
new file mode 100644
index 0000000..d101294
--- /dev/null
+++ b/tests/m_mmp_bad_csum/script
@@ -0,0 +1,30 @@
+# use current directory instead of /tmp becase tmpfs doesn't support DIO
+rm -f $TMPFILE
+TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
+
+stat -f $TMPFILE | grep -q "Type: tmpfs"
+if [ $? = 0 ]; then
+	rm -f $TMPFILE
+	echo "$test_name: $test_description: skipped for tmpfs (no O_DIRECT)"
+	return 0
+fi
+gzip -dc < $test_dir/image.gz > $TMPFILE
+
+OUT=$test_dir.log
+EXP=$test_dir/expect
+$FSCK -fy $TMPFILE 2>&1 | sed -f $cmd_dir/filter.sed > $OUT
+echo Exit status is $? >> $OUT
+
+rm -f $TMPFILE
+cmp -s $OUT $EXP
+status=$?
+
+if [ "$status" = 0 ] ; then
+	echo "$test_name: $test_description: ok"
+	touch $test_name.ok
+else
+	echo "$test_name: $test_description: failed"
+	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
+	rm -f $test_name.tmp
+fi
+unset OUT EXP
diff --git a/tests/m_mmp_bad_magic/.log b/tests/m_mmp_bad_magic/.log
new file mode 100644
index 0000000..b5dfb89
--- /dev/null
+++ b/tests/m_mmp_bad_magic/.log
@@ -0,0 +1,9 @@
+Superblock has invalid MMP magic.  Fix? yes
+
+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: 11/128 files (0.0% non-contiguous), 19/512 blocks
+Exit status is 0
diff --git a/tests/m_mmp_bad_magic/expect b/tests/m_mmp_bad_magic/expect
new file mode 100644
index 0000000..b5dfb89
--- /dev/null
+++ b/tests/m_mmp_bad_magic/expect
@@ -0,0 +1,9 @@
+Superblock has invalid MMP magic.  Fix? yes
+
+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: 11/128 files (0.0% non-contiguous), 19/512 blocks
+Exit status is 0
diff --git a/tests/m_mmp_bad_magic/image.gz b/tests/m_mmp_bad_magic/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..2d57fbf5fa2ee4939a41f00ea1d3d0b096346d3e
GIT binary patch
literal 2597
zcmb2|=3rQDbUm1f`R!d_50O9yh6m=4+m<a8bmfp+<vjg_Ls#7jgCpJvta98cFWNOk
zi>6P|YjbfCxVmtKvtxjxtd-k^g-z>Z_k;)tmP~ZAx{<p$_uKLbN1K9-%J=10zJFV7
zz1jNx*)xy#-b^%SQCREN9Vp`zJ;}#S@rl;cLe(i^5^Hs)OT4bRD(<xK!gouqi|1=1
zLp*0|&D8b$v`4Sy@l1hbc2DiM*uS={e0`;F?&EN_ycB-^^xyq5)`b-nDL>+`mVW;2
ze){&gcX_*amOpuXboK4?t_!tIj$eLly8YH<_np3Ct!<f4XD%sN>)c=Y%_8pRT2Tgt
z+OEU*Q#~VsrT#ykRI@B(-^&-<yLV2g|GWC@yDj_otpCcuz>turp>wWfed*>1c_8n{
zd(r*>^Z5er2%h@RWYTW&?uEwv!@sv}HMBD{nG;){qG4WfVyh5PVMN9(=Zfp~ds9n;
zul}iDwAJQ6J5V$$`QQBgv+DzE{w)oy2J#)&p8Fr(6SpJnA3u=y>_3n=aA^L2@p|Th
z`275b$N$Ikr}(eCzw6`s`{joZB$ORK7{7m?$K}KIi9eVAVvk}3swWH@qJmbeKgA4G
zXnI^!fUtU;D*hdbc)og{{KNR#wA*iguK)gIol2Bd@ZZ-?&YHT%dxHZ{_(bb#=^9$g
z%eP&Sb2}IQzI}^KG5_()wdcM*xfJ_<+1{7y{?E?%w>|NTkC5%#SquMnYuVn{`IaBL
zZ`ZEh%e(&GpIn{!_W!gup5H&-pX*!xS3iID|J;fwng1ncP5yNrUUk2x-e{_U^m2ZY
s^Z%!HZkY!Pu2C==0;3@?8UmvsFd71*AwZK5IJ5Wt>VIch85k5800I{>HUIzs

literal 0
HcmV?d00001

diff --git a/tests/m_mmp_bad_magic/name b/tests/m_mmp_bad_magic/name
new file mode 100644
index 0000000..15a2d4d
--- /dev/null
+++ b/tests/m_mmp_bad_magic/name
@@ -0,0 +1 @@
+mmp with bad magic (metadata_csum)
diff --git a/tests/m_mmp_bad_magic/script b/tests/m_mmp_bad_magic/script
new file mode 100644
index 0000000..d101294
--- /dev/null
+++ b/tests/m_mmp_bad_magic/script
@@ -0,0 +1,30 @@
+# use current directory instead of /tmp becase tmpfs doesn't support DIO
+rm -f $TMPFILE
+TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
+
+stat -f $TMPFILE | grep -q "Type: tmpfs"
+if [ $? = 0 ]; then
+	rm -f $TMPFILE
+	echo "$test_name: $test_description: skipped for tmpfs (no O_DIRECT)"
+	return 0
+fi
+gzip -dc < $test_dir/image.gz > $TMPFILE
+
+OUT=$test_dir.log
+EXP=$test_dir/expect
+$FSCK -fy $TMPFILE 2>&1 | sed -f $cmd_dir/filter.sed > $OUT
+echo Exit status is $? >> $OUT
+
+rm -f $TMPFILE
+cmp -s $OUT $EXP
+status=$?
+
+if [ "$status" = 0 ] ; then
+	echo "$test_name: $test_description: ok"
+	touch $test_name.ok
+else
+	echo "$test_name: $test_description: failed"
+	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
+	rm -f $test_name.tmp
+fi
+unset OUT EXP


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

* [PATCH 17/19] tests: add regression tests for superblocks with bad checksums
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (15 preceding siblings ...)
  2014-08-01 18:13 ` [PATCH 16/19] tests: add regression tests for MMP blocks with bad checksums Darrick J. Wong
@ 2014-08-01 18:13 ` Darrick J. Wong
  2014-08-03  3:50   ` Theodore Ts'o
  2014-08-01 18:13 ` [PATCH 18/19] tests: add regression tests for group descriptors " Darrick J. Wong
  2014-08-01 18:13 ` [PATCH 19/19] tests: add regression tests for inodes " Darrick J. Wong
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:13 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Add regression tests to examine how e2fsck deals with random
superblock corruption such as obviously wrong fields and the checksum
itself being incorrect.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/f_super_bad_csum/expect.1  |   13 +++++++++++++
 tests/f_super_bad_csum/expect.2  |    7 +++++++
 tests/f_super_bad_csum/image.bz2 |  Bin
 tests/f_super_bad_csum/name      |    1 +
 tests/f_super_bad_csum/script    |   33 +++++++++++++++++++++++++++++++++
 5 files changed, 54 insertions(+)
 create mode 100644 tests/f_super_bad_csum/expect.1
 create mode 100644 tests/f_super_bad_csum/expect.2
 create mode 100644 tests/f_super_bad_csum/image.bz2
 create mode 100644 tests/f_super_bad_csum/name
 create mode 100755 tests/f_super_bad_csum/script

diff --git a/tests/f_super_bad_csum/expect.1 b/tests/f_super_bad_csum/expect.1
new file mode 100644
index 0000000..25ced5c
--- /dev/null
+++ b/tests/f_super_bad_csum/expect.1
@@ -0,0 +1,13 @@
+ext2fs_open2: Superblock checksum does not match superblock
+../e2fsck/e2fsck: Superblock invalid, trying backup blocks...
+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
+Inode bitmap differences: Group 1 inode bitmap does not match checksum.
+FIXED.
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/1024 files (0.0% non-contiguous), 1557/16384 blocks
+Exit status is 0
diff --git a/tests/f_super_bad_csum/expect.2 b/tests/f_super_bad_csum/expect.2
new file mode 100644
index 0000000..dd20919
--- /dev/null
+++ b/tests/f_super_bad_csum/expect.2
@@ -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: 11/1024 files (0.0% non-contiguous), 1557/16384 blocks
+Exit status is 0
diff --git a/tests/f_super_bad_csum/image.bz2 b/tests/f_super_bad_csum/image.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..cd80d4b837fd0e966595e70d4bb0854b8b63a78b
GIT binary patch
literal 1181
zcmZ>Y%CIzaj8qGbG&$qO$-t0W{~rU~v2+!vn5cJQvuwM{xqY@5Sn7D6eNd27s1g;G
zG&H%mOmO0|9?s6m$^s`+F1}FXIM61nHq$79!N)Db*=JUQ56k8MUtJw~W*SN{Ge}MH
zUBbY?_{xNrts&!t5d$1#fLXjO{$GPu<@&&dQ5jq-m-PobE;zyL?B?UZ);NKe&6h{O
z$b=zLO3LKo0uzP|Heacf%MKUVdKnlvrgRzwA6s!GagoX8REaB<raTTAQj81O8W@1e
zdVEbTNJ&-onk2E!GRffOHL98=w|sKY?nTd2FVB&=G2`3JBcZ7~_09$a9f+MOD#jg>
zZLq%H&hN|D(@j@i_Pq2JoHFIin{Q>N$HFG%*Y97o=tE~h!$lw7XKJ4gtxIW|<8$`;
zo_lp&;d57YXvpWdI7D}>(3<u@X;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YKC`bZuyzg$csS8j
hgn?P_V=I@(%tyK$eZ1yBZN&cn7cX+P2$%pWjsRs0<w^hm

literal 0
HcmV?d00001

diff --git a/tests/f_super_bad_csum/name b/tests/f_super_bad_csum/name
new file mode 100644
index 0000000..745562f
--- /dev/null
+++ b/tests/f_super_bad_csum/name
@@ -0,0 +1 @@
+bad csum in superblock (metadata_csum)
diff --git a/tests/f_super_bad_csum/script b/tests/f_super_bad_csum/script
new file mode 100755
index 0000000..cfd4189
--- /dev/null
+++ b/tests/f_super_bad_csum/script
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+FSCK_OPT=-fy
+IMAGE=$test_dir/image.bz2
+
+bzip2 -d < $IMAGE > $TMPFILE
+#e2label $TMPFILE test_filesys
+
+# Run fsck to fix things?
+EXP1=$test_dir/expect.1
+OUT1=$test_name.1.log
+rm -rf $test_name.failed $test_name.ok
+
+$FSCK $FSCK_OPT $TMPFILE 2>&1 | head -n 1000 | tail -n +2 > $OUT1
+echo "Exit status is $?" >> $OUT1
+
+# Run a second time
+EXP2=$test_dir/expect.2
+OUT2=$test_name.2.log
+
+$FSCK $FSCK_OPT $TMPFILE 2>&1 | head -n 1000 | tail -n +2 > $OUT2
+echo "Exit status is $?" >> $OUT2
+
+# Figure out what happened
+if cmp -s $EXP1 $OUT1 && cmp -s $EXP2 $OUT2; then
+	echo "$test_name: $test_description: ok"
+	touch $test_name.ok
+else
+	echo "$test_name: $test_description: failed"
+	diff -u $EXP1 $OUT1 >> $test_name.failed
+	diff -u $EXP2 $OUT2 >> $test_name.failed
+fi
+unset EXP1 OUT1 EXP2 OUT2 FSCK_OPT IMAGE


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

* [PATCH 18/19] tests: add regression tests for group descriptors with bad checksums
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (16 preceding siblings ...)
  2014-08-01 18:13 ` [PATCH 17/19] tests: add regression tests for superblocks " Darrick J. Wong
@ 2014-08-01 18:13 ` Darrick J. Wong
  2014-08-03  3:51   ` Theodore Ts'o
  2014-08-01 18:13 ` [PATCH 19/19] tests: add regression tests for inodes " Darrick J. Wong
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:13 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Add tests to examine how e2fsck deals with (a) the block bitmap being
corrupt; (b) the inode bitmap being corrupt; (c) the bitmap checksums
being incorrect (but the bitmaps are fine); and (d) the group
descriptor checksum itself is incorrect.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/f_bad_bbitmap/expect.1   |   15 +++++++++++++++
 tests/f_bad_bbitmap/expect.2   |    7 +++++++
 tests/f_bad_bbitmap/image.gz   |  Bin
 tests/f_bad_bbitmap/name       |    1 +
 tests/f_bad_bmap_csum/expect.1 |   16 ++++++++++++++++
 tests/f_bad_bmap_csum/expect.2 |    7 +++++++
 tests/f_bad_bmap_csum/image.gz |  Bin
 tests/f_bad_bmap_csum/name     |    1 +
 tests/f_bad_gdt_csum/expect.1  |   10 ++++++++++
 tests/f_bad_gdt_csum/expect.2  |    7 +++++++
 tests/f_bad_gdt_csum/image.gz  |  Bin
 tests/f_bad_gdt_csum/name      |    1 +
 tests/f_bad_ibitmap/expect.1   |   15 +++++++++++++++
 tests/f_bad_ibitmap/expect.2   |    7 +++++++
 tests/f_bad_ibitmap/image.gz   |  Bin
 tests/f_bad_ibitmap/name       |    1 +
 16 files changed, 88 insertions(+)
 create mode 100644 tests/f_bad_bbitmap/expect.1
 create mode 100644 tests/f_bad_bbitmap/expect.2
 create mode 100644 tests/f_bad_bbitmap/image.gz
 create mode 100644 tests/f_bad_bbitmap/name
 create mode 100644 tests/f_bad_bmap_csum/expect.1
 create mode 100644 tests/f_bad_bmap_csum/expect.2
 create mode 100644 tests/f_bad_bmap_csum/image.gz
 create mode 100644 tests/f_bad_bmap_csum/name
 create mode 100644 tests/f_bad_gdt_csum/expect.1
 create mode 100644 tests/f_bad_gdt_csum/expect.2
 create mode 100644 tests/f_bad_gdt_csum/image.gz
 create mode 100644 tests/f_bad_gdt_csum/name
 create mode 100644 tests/f_bad_ibitmap/expect.1
 create mode 100644 tests/f_bad_ibitmap/expect.2
 create mode 100644 tests/f_bad_ibitmap/image.gz
 create mode 100644 tests/f_bad_ibitmap/name

diff --git a/tests/f_bad_bbitmap/expect.1 b/tests/f_bad_bbitmap/expect.1
new file mode 100644
index 0000000..71ad1bb
--- /dev/null
+++ b/tests/f_bad_bbitmap/expect.1
@@ -0,0 +1,15 @@
+One or more block group descriptor checksums are invalid.  Fix? yes
+
+Group descriptor 0 checksum is 0x49ff, should be 0x4972.  FIXED.
+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
+Block bitmap differences:  -(8--10) -(12--17) -(19--31)
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 1
diff --git a/tests/f_bad_bbitmap/expect.2 b/tests/f_bad_bbitmap/expect.2
new file mode 100644
index 0000000..411e656
--- /dev/null
+++ b/tests/f_bad_bbitmap/expect.2
@@ -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: 11/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 0
diff --git a/tests/f_bad_bbitmap/image.gz b/tests/f_bad_bbitmap/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..c488ecd365b99c51a304597c0944444e0552c57d
GIT binary patch
literal 2546
zcmb2|=3tPuydKQN{Pvb@MzEs{!-wijhs@@wyEMdfSk)E#woVp}J#uhiFnj4n-m6LN
zCJUln-|8s!@wvWG>gZ_Vi<)y}mqv!`QAfeuKh{1_|M=8-q5x}dX3o9$;_vjz_e|gO
z|McF+@1C|Ys9dek^lsgtrWfa?D6;D9$}FvXgSfkTW|xg`%R6nn@n4JU;`u7q5Z&9W
zrur5Z+WwpH_oYCT-Tj%fX5aW#_UUI==y|?%wsvMS<Zm0B*ci>QpAx?&qTj}L>h3+2
zw|B0re*JxJ<%dKCu3E*(zf9M)UX|Rx$m;FO9fiBsxi{P9+%3Hq$<Xjb)3@IG(UsVF
z|HU6w?YeVs_TInC1iJRmU3Sl=x@!4mb_NCpZ)d}ATT|<PGXvTGw_p1If2P3FO$$Hi
zIH)ZNx|#D-@}B$KwJRrH{Bxsi;l)FZd*4k3syh%gne*XCm+-vu=(E4-*X`Z(4`kA;
z<iGd#zB@AY((mtY&w&I?UjO<Z_I|SE>v|w(156D+kV6dcjxCJzl?AHIuzJ@(j0PNP
zKA5LfrTwm7a`e}^KH1*>-$$oeL`UlXo3>$3OxUMu<$)gmH^qnCOR8)0Z@VC=mY!YT
zzU0f!#;YgyJ=2TvF8g!8Pu2QguW_$^+sDI&W_QEW|8%cXzP~?v^-6csufNT`9>>26
z4m!SH-+l7k|N3#hWq)>F2daH}>Cf`@_x`Ah?)qo&-!uGjP0g99>;CVaKB?+2D4<8d
iXb6mkz-S1JhQMeDjD`R$LSVy(eath088aCe6c_+dh#I*7

literal 0
HcmV?d00001

diff --git a/tests/f_bad_bbitmap/name b/tests/f_bad_bbitmap/name
new file mode 100644
index 0000000..923ddcb
--- /dev/null
+++ b/tests/f_bad_bbitmap/name
@@ -0,0 +1 @@
+corrupt block bitmap (metadata_csum)
diff --git a/tests/f_bad_bmap_csum/expect.1 b/tests/f_bad_bmap_csum/expect.1
new file mode 100644
index 0000000..ca8f77f
--- /dev/null
+++ b/tests/f_bad_bmap_csum/expect.1
@@ -0,0 +1,16 @@
+One or more block group descriptor checksums are invalid.  Fix? yes
+
+Group descriptor 0 checksum is 0x4972, should be 0x7074.  FIXED.
+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
+Inode bitmap differences: Group 0 inode bitmap does not match checksum.
+FIXED.
+Block bitmap differences: Group 0 block bitmap does not match checksum.
+FIXED.
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 1
diff --git a/tests/f_bad_bmap_csum/expect.2 b/tests/f_bad_bmap_csum/expect.2
new file mode 100644
index 0000000..411e656
--- /dev/null
+++ b/tests/f_bad_bmap_csum/expect.2
@@ -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: 11/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 0
diff --git a/tests/f_bad_bmap_csum/image.gz b/tests/f_bad_bmap_csum/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..70a0d1812b9c030959651bd068f1331e36330578
GIT binary patch
literal 2546
zcmb2|=3pqYxE{>J{Pvc0hKQpC!-Jb=8x<{WI(w522y75al3d%9p)4l0GH6BbNkLvV
zAEsNbSFR`}WeT>KG<9fXEIjDdGj)NWD7UN6V`ljWlZ)RkY<VnVqL`ky|NV@avlGAP
z{oi{tF)iPj;ZoL~8Alb@_;y_n<Vc?SZO0@p>7MXy-e*eAe`^cS__D9l>C5UkvCvc3
zyi$vU?s(ZfNl<H9rvH7}Gqr8|XV>g3`r57h+OPLpf6qH<37J>&mR6fWHp<o4nbqgM
z?&}WbH<PjW{~|eFq{_)`p8WMkS^jZ>z2AH;?FhcU_?+DKH#?u`FgW}YS-wBl^Oero
z|Hmg)ExQuu@#N6M`+mXiV=T7czRAqM(C~EOg*lw}XNhgFXJBCXa9{i1|M|RucSKK}
zXG(FFDKDKm|6%Q<?9TQ!cQ<oBo_^U|@8dXu3U$nH3e58>dGdW**xLWki=KW3>AoQG
z`v1AF%h!wFuRmca4-#1M`v30ed1oX4gKUDSsRzms10vpWX|H+(ROxWIke!7X9oW@0
z>^Hn@d;7Ps?$z>bZ&%gdS-(y7=BlWV=B>|yBF{zNb5}IZ-@jtZ(L+4*I2YRboD2KU
zm-(`|Hv3ZT+1PzE-~HG>->3Y~?6g<)Jdcl0%GtI2*bnhgw|({3qeA;vz2eUoKfeFZ
z^DTY#@%~G8|Bv4}@!gNl`LFAFE+75r@4xn^zl_yCga0Q(E;-el5?}xSclhP1zre5<
k1*0J_8UmvsFd71*Aut*OGzozXKk671F0Px-z@WeY0F<&6$N&HU

literal 0
HcmV?d00001

diff --git a/tests/f_bad_bmap_csum/name b/tests/f_bad_bmap_csum/name
new file mode 100644
index 0000000..df19fe3
--- /dev/null
+++ b/tests/f_bad_bmap_csum/name
@@ -0,0 +1 @@
+bad block/inode bitmap csum (metadata_csum)
diff --git a/tests/f_bad_gdt_csum/expect.1 b/tests/f_bad_gdt_csum/expect.1
new file mode 100644
index 0000000..e14c897
--- /dev/null
+++ b/tests/f_bad_gdt_csum/expect.1
@@ -0,0 +1,10 @@
+One or more block group descriptor checksums are invalid.  Fix? yes
+
+Group descriptor 0 checksum is 0xffff, should be 0x4972.  FIXED.
+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: 11/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 0
diff --git a/tests/f_bad_gdt_csum/expect.2 b/tests/f_bad_gdt_csum/expect.2
new file mode 100644
index 0000000..411e656
--- /dev/null
+++ b/tests/f_bad_gdt_csum/expect.2
@@ -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: 11/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 0
diff --git a/tests/f_bad_gdt_csum/image.gz b/tests/f_bad_gdt_csum/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..c3fdafe6627561f7de16ea09a6f02d52f6265b00
GIT binary patch
literal 2548
zcmb2|=3uC|xE{>J{Pvb@MzEs{!-wk31DC|KO9OQxxcr=CvemVBbu>FK=X;eTz3M1m
zro;BGTahj@vRxNk1q4}Tw^($R243juYE~-y7=6(H(dqUeCy^~nH&*VC-?977$GA`b
z^uPD*o-WQbA>{E<9nnL#c2tPAPFTNXxz@@p2P;x{-|#t~Q_s=r^#8Sn%l=oXflG7N
zhL{~c+WW(qZ;5lpucGp-yrkQ^Pl{`Y+uLt>cjQJwUe5aqA5J8^E67`!Wc%w)$+uI}
z-acRcF8@aTw};0YHNLcNyYgp;Sa|xMuB<J~A0Lz5C0F`wMe29fbVi0r%Ps!C?FcT<
z{5QY<^~<2@{AcHG*Vvr@f46S?xw$u=zF}lwIPfVT!>>Kxm-~i10|Ud4_oDy*=W_>Y
z37<O8w52sfYqF;O;om#<s+t<jlD=(WGRuC)`Mp9wg%NqToGOeiPQ80MYU{uG+4}4M
z1I=nU7V*D)y?y1@AOD<pe+CLL^zQn%|L*USbH6}_uYsvy26Bi12a3WY0z=t>Dy90Y
z6^PJ)OUa+!ne%S`o1eLI-{$1>zmMy7nw|^0+O=QPWcsP1d!OvMURM5gU8*aV_9KL2
zZer24U*#TN^Q9vuzsY|0=xfUH|9>ksJ-%-e{6AU3UMT%?t?9A-D~vw<-F<CURY+)k
z!DfqpsrKrne|}f#-2D6h($<vY^J{@>XXu@)|CM#NK4{@<{?GGERCSLm&-wUkf4Sw#
o>-M<ZIVwIH0;3@?8UmvsFd71*AwX#ebiZdekeYCofkA-*0GSvb(f|Me

literal 0
HcmV?d00001

diff --git a/tests/f_bad_gdt_csum/name b/tests/f_bad_gdt_csum/name
new file mode 100644
index 0000000..fe2c601
--- /dev/null
+++ b/tests/f_bad_gdt_csum/name
@@ -0,0 +1 @@
+bad group descriptor csum (metadata_csum)
diff --git a/tests/f_bad_ibitmap/expect.1 b/tests/f_bad_ibitmap/expect.1
new file mode 100644
index 0000000..ea17523
--- /dev/null
+++ b/tests/f_bad_ibitmap/expect.1
@@ -0,0 +1,15 @@
+One or more block group descriptor checksums are invalid.  Fix? yes
+
+Group descriptor 0 checksum is 0xffff, should be 0x4972.  FIXED.
+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
+Inode bitmap differences:  -(12--32)
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 1
diff --git a/tests/f_bad_ibitmap/expect.2 b/tests/f_bad_ibitmap/expect.2
new file mode 100644
index 0000000..411e656
--- /dev/null
+++ b/tests/f_bad_ibitmap/expect.2
@@ -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: 11/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 0
diff --git a/tests/f_bad_ibitmap/image.gz b/tests/f_bad_ibitmap/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..3a5239802dc3927db009d83b951f487033e528d6
GIT binary patch
literal 2548
zcmb2|=3rp7ydKQN{Pvb@MzEs{!-wk3wo7c<rGYvTTz*b6+3MQ6I+~rA^Sw%vUUif&
z(_wqptw<Lc*{%z&0)nivTP!+D121%SH7k{Uj6Uf9=ybc1BG;`;H}>4uzZ3heLcj9=
z^y=exPjfSRtm+J!#+B$Bv!};NBjk4Q)sTA$i+084Y%9-GXh|x35Gt~0{@1P*QQN|`
zXFqyW^+)mdWyLKu`;2YvcYb|)<+JGOd9pFpH8mRc`_d~?N;K*<_J?egtE|#0ul&5N
z`11E_@2x*SIGiBz%USJfc1-tb?K;=eTbBzTm&Nw8Ro~e5de3GChLgdw{*@hDx!mTz
z{*kXGJNN2W|Mpd!_xyj}{@LmN?@PWhFfb%kYHV9}`1&-~H~c`}pYLA(|ED`mIn{P*
zGsDaYUa6a>rdP<9ZdvMf{L^FUw&Psv-*$yF0TrJ1Rckpu`R>lUZ%tqS|Jirympo7~
zqwj0|`CY={UhnUhTYv;Eta<%Ey4L^M+W(9U3<qFp?13`G0G;xq5xKHJl^J^P8i>(=
zL(K>CwCd+<bxW51I(JUCxBvIiX%^9u`v0a~h|<%pyuDjvN&QWIt^AD!%IeN9xPptf
z?spFQb?3pWl=x!tb*k3?@{doF{eSG{G5Nzs9$L(Px!(An>(z<x?{B?+W$~<Ef2Egx
z)c>xz^6~xYi%-7$FTP&Q`rn<`K(#)Z|1QVp|C`Kpw|>U|C95+P?VfpE|9{upbMHT3
mSd4<v5Eu=C(GVC7fzc2c4FQ^jKt#=b#-EO-moqRZFaQ7#Mj2iJ

literal 0
HcmV?d00001

diff --git a/tests/f_bad_ibitmap/name b/tests/f_bad_ibitmap/name
new file mode 100644
index 0000000..76ec12d
--- /dev/null
+++ b/tests/f_bad_ibitmap/name
@@ -0,0 +1 @@
+corrupt inode bitmap (metadata_csum)


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

* [PATCH 19/19] tests: add regression tests for inodes with bad checksums
  2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
                   ` (17 preceding siblings ...)
  2014-08-01 18:13 ` [PATCH 18/19] tests: add regression tests for group descriptors " Darrick J. Wong
@ 2014-08-01 18:13 ` Darrick J. Wong
  2014-08-03  3:52   ` Theodore Ts'o
  18 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-01 18:13 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

From: Darrick J. Wong <darrick.wong@oracle.com>

Add regression tests to e2fsck to examine how it deals with inode
table blocks which (a) have been zero'd; (b) have been one'd; (c) have
corrupt inodes with obvious problems; and (d) have inodes with
non-obvious problems.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/f_bad_inode_csum/expect.1 |  126 +++++++++++++++++++++++++++++++++++++++
 tests/f_bad_inode_csum/expect.2 |    7 ++
 tests/f_bad_inode_csum/image.gz |  Bin
 tests/f_bad_inode_csum/name     |    1 
 4 files changed, 134 insertions(+)
 create mode 100644 tests/f_bad_inode_csum/expect.1
 create mode 100644 tests/f_bad_inode_csum/expect.2
 create mode 100644 tests/f_bad_inode_csum/image.gz
 create mode 100644 tests/f_bad_inode_csum/name

diff --git a/tests/f_bad_inode_csum/expect.1 b/tests/f_bad_inode_csum/expect.1
new file mode 100644
index 0000000..b3c628d
--- /dev/null
+++ b/tests/f_bad_inode_csum/expect.1
@@ -0,0 +1,126 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 33 has a extra size (65535) which is invalid
+Fix? yes
+
+Inode 49 passes checks, but checksum does not match inode.  Fix? yes
+
+Inode 65 passes checks, but checksum does not match inode.  Fix? yes
+
+Inode 81 passes checks, but checksum does not match inode.  Fix? yes
+
+Inode 97 seems to contain garbage.  Clear? yes
+
+Inode 98 seems to contain garbage.  Clear? yes
+
+Inode 99 seems to contain garbage.  Clear? yes
+
+Inode 100 seems to contain garbage.  Clear? yes
+
+Inode 101 seems to contain garbage.  Clear? yes
+
+Inode 102 seems to contain garbage.  Clear? yes
+
+Inode 103 seems to contain garbage.  Clear? yes
+
+Inode 104 seems to contain garbage.  Clear? yes
+
+Inode 105 seems to contain garbage.  Clear? yes
+
+Inode 106 seems to contain garbage.  Clear? yes
+
+Inode 107 seems to contain garbage.  Clear? yes
+
+Inode 108 seems to contain garbage.  Clear? yes
+
+Inode 109 seems to contain garbage.  Clear? yes
+
+Inode 110 seems to contain garbage.  Clear? yes
+
+Inode 111 seems to contain garbage.  Clear? yes
+
+Inode 112 seems to contain garbage.  Clear? yes
+
+Pass 2: Checking directory structure
+Extended attribute block for inode 49 (/38) is invalid (4294967295).
+Clear? yes
+
+Entry '86' in / (2) has deleted/unused inode 97.  Clear? yes
+
+Entry '87' in / (2) has deleted/unused inode 98.  Clear? yes
+
+Entry '88' in / (2) has deleted/unused inode 99.  Clear? yes
+
+Entry '89' in / (2) has deleted/unused inode 100.  Clear? yes
+
+Entry '90' in / (2) has deleted/unused inode 101.  Clear? yes
+
+Entry '91' in / (2) has deleted/unused inode 102.  Clear? yes
+
+Entry '92' in / (2) has deleted/unused inode 103.  Clear? yes
+
+Entry '93' in / (2) has deleted/unused inode 104.  Clear? yes
+
+Entry '94' in / (2) has deleted/unused inode 105.  Clear? yes
+
+Entry '95' in / (2) has deleted/unused inode 106.  Clear? yes
+
+Entry '96' in / (2) has deleted/unused inode 107.  Clear? yes
+
+Entry '97' in / (2) has deleted/unused inode 108.  Clear? yes
+
+Entry '98' in / (2) has deleted/unused inode 109.  Clear? yes
+
+Entry '99' in / (2) has deleted/unused inode 110.  Clear? yes
+
+Entry '100' in / (2) has deleted/unused inode 111.  Clear? yes
+
+Entry '101' in / (2) has deleted/unused inode 112.  Clear? yes
+
+Entry '102' in / (2) has deleted/unused inode 113.  Clear? yes
+
+Entry '103' in / (2) has deleted/unused inode 114.  Clear? yes
+
+Entry '104' in / (2) has deleted/unused inode 115.  Clear? yes
+
+Entry '105' in / (2) has deleted/unused inode 116.  Clear? yes
+
+Entry '106' in / (2) has deleted/unused inode 117.  Clear? yes
+
+Entry '107' in / (2) has deleted/unused inode 118.  Clear? yes
+
+Entry '108' in / (2) has deleted/unused inode 119.  Clear? yes
+
+Entry '109' in / (2) has deleted/unused inode 120.  Clear? yes
+
+Entry '110' in / (2) has deleted/unused inode 121.  Clear? yes
+
+Entry '111' in / (2) has deleted/unused inode 122.  Clear? yes
+
+Entry '112' in / (2) has deleted/unused inode 123.  Clear? yes
+
+Entry '113' in / (2) has deleted/unused inode 124.  Clear? yes
+
+Entry '114' in / (2) has deleted/unused inode 125.  Clear? yes
+
+Entry '115' in / (2) has deleted/unused inode 126.  Clear? yes
+
+Entry '116' in / (2) has deleted/unused inode 127.  Clear? yes
+
+Entry '117' in / (2) has deleted/unused inode 128.  Clear? yes
+
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Inode bitmap differences:  -(97--128)
+Fix? yes
+
+Free inodes count wrong for group #0 (0, counted=32).
+Fix? yes
+
+Free inodes count wrong (0, counted=32).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 96/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 1
diff --git a/tests/f_bad_inode_csum/expect.2 b/tests/f_bad_inode_csum/expect.2
new file mode 100644
index 0000000..b97a902
--- /dev/null
+++ b/tests/f_bad_inode_csum/expect.2
@@ -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: 96/128 files (0.0% non-contiguous), 18/512 blocks
+Exit status is 0
diff --git a/tests/f_bad_inode_csum/image.gz b/tests/f_bad_inode_csum/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..221920b04ad0b18949bd75680159390e7b05586a
GIT binary patch
literal 4613
zcmeHI`%_bQ7N=!ex?>B|c3ijRk-Ah_RuLpsKpuDP?n*6>v{0m!M-~)WMMxoHlmNFK
zJEBsImPdFLsDnl!0;YgKfZQt8j0DU`44^<#K@t-}0_27Fa_@J)4F1~b{sCm>COPMP
z?m3_HIp=#Xt>g`d(S@<tR~_dkx#eT&bxsSWH@|q}*x4FQW##*w-{!n`=IM0S7oY9D
zy<zJcn;WCg=59Pwa{hdFQ^E;xTFu_d&r@PDGxyt{iSvGriWqD6uCC3hZy#*h#Zk6q
zM$650YI@#TEiY{YS7TiYG52L?f{QeveD#XNO!&vWW{I1dDbqAR2{?vi;Zw3&S7F$H
z3gx4VhSBPrU2#)W^oFeF>8I=gvo33-*5zmjee*Hq22l2IQh2mY$Cso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VOTv>0YvzsoPDc8g+>d&
zMxK-+iaO^yE(ctTv%A3DTDX~VZ>t>)ju4oq0(^_xz}<x8O_J%#4n36$4@+MpXv@Ap
zh9|}619~nGxOot?omVqw+Oqer&Ve5bP8ub2Qmgd<kKZ9!T$8LHJSd`qbGuNUatvF^
z)RC(#S})?1DOHBqhFV@OQbIKq;L?mz^9S+)Bpsh8rF>jBA=bu;m*aa72{Ht~Qc3}&
zM(2=<77-|Q^7UALu2rnHy1}2kHa3QxSoz69X%FGFrH>6*x_pH2h4rvJ5#Tu|ge_4M
zie?sA-6%GlY<rPlP}|x^hz34Eatg_rX{v<LqrK3fZv!{sx&Pd_$iwksRE$}u5;hMd
z6AkJD>9msBM{g0M;}Lr7L;JE;Cjy=sa7&H|z>m0z8FCZVk^FR=78qzV8B<P@8s95x
zhfhW)<!<f-SO|r)KonpU$N64--##twD_GM%{uxC@6_SdnvIrCAZ#SV@DdiZ=Tz*D?
z&1)6a6$C*88wo~Daz2Qwref#j0L@+bVh{r{YY#bWj{@}JCbhx*FC94skBaz18`js$
zUas+dIpwj#I3w7{Mq4pHc&~)oxt18+D*%^~?@1aWu~3^1<7j^v0Qa@Q@k8n#))pT7
zn*zwJFTmvtz6wnipqSS|Al!Z8Sk;RP)kbwO6bwvH&LCDbQj5muNZ<PwaIX+rN9VhV
z@!tIS0@@vluUEeX-$CWs$6x#XSJ8T8U4eB4))iP+U|oTA1^yoeevyr^UU2|EqYe%q
GIQ$Pa(@%{6

literal 0
HcmV?d00001

diff --git a/tests/f_bad_inode_csum/name b/tests/f_bad_inode_csum/name
new file mode 100644
index 0000000..68bf7ce
--- /dev/null
+++ b/tests/f_bad_inode_csum/name
@@ -0,0 +1 @@
+inode table corruption (metadata_csum)


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

* Re: [PATCH 01/19] e2fuzz: fix fs handle cleanup when closing fails
  2014-08-01 18:11 ` [PATCH 01/19] e2fuzz: fix fs handle cleanup when closing fails Darrick J. Wong
@ 2014-08-03  2:22   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:22 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:11:46AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Fix the handling of 'fs' when closing the FS fails so that we don't
> dereference a NULL pointer.  Adapt to use ext2fs_close_free while
> we're at it.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Fixes-Coverity-Bug: 1229241

Applied, thanks.

						- Ted

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

* Re: [PATCH 02/19] e2fsck: never free critical metadata blocks in the block found map
  2014-08-01 18:11 ` [PATCH 02/19] e2fsck: never free critical metadata blocks in the block found map Darrick J. Wong
@ 2014-08-03  2:22   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:22 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:11:53AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Don't allow critical metadata blocks to be marked free in the block
> found map.  This can theoretically happen on an FS where a first
> inode's ETB/indirect map block is in the inode table, the first inode
> is itself unclonable (and thus gets deleted) and there are enough
> crosslinked files before and after the first inode to use up all the
> free blocks during pass 1b.
> 
> (I do actually have a test FS image but it's 256M and it proved very
> difficult to craft a bite-sized test case that actually hit this bug.)
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

						- Ted

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

* Re: [PATCH 03/19] e2fsck: use root dir for lost+found when really desperate
  2014-08-01 18:11 ` [PATCH 03/19] e2fsck: use root dir for lost+found when really desperate Darrick J. Wong
@ 2014-08-03  2:25   ` Theodore Ts'o
  2014-08-05  0:58     ` Darrick J. Wong
  0 siblings, 1 reply; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:25 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:11:59AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> If we're totally unable to allocate a lost+found directory, ask the
> user if he would like to dump orphaned files in the root directory.
> Hopefully this enables the user to delete enough files so that a
> subsequent run of e2fsck will make more progress.  Better to cram lost
> files in the rootdir than the current behavior, which is to fail at
> linking them in, thereby leaving them as lost files.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, although I changed:

> +		printf("Delete some files and re-run e2fsck.\n\n");

to:

		printf(_("Delete some files and re-run e2fsck.\n\n"));

for proper internationalization support.  Usually, I like to run all
messages through problem.c, like this:

	fix_problem(ctx, PR_3_PASS_HEADER, &pctx);

	{ PR_3_PASS_HEADER,
	  N_("Pass 3: Checking @d connectivity\n"),
	    PROMPT_NONE, 0 },

and I may change this over at some point, but I'll leave it as a
printf for now.

Thanks!!

						- Ted

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

* Re: [PATCH 04/19] dumpe2fs: complain when checksum verification fails
  2014-08-01 18:12 ` [PATCH 04/19] dumpe2fs: complain when checksum verification fails Darrick J. Wong
@ 2014-08-03  2:26   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:26 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:12:06AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Warn the user to run e2fsck if the superblock or bitmaps fails
> checksum verification.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

					- Ted

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

* Re: [PATCH 05/19] libext2fs: check EA block headers when reading in the block
  2014-08-01 18:12 ` [PATCH 05/19] libext2fs: check EA block headers when reading in the block Darrick J. Wong
@ 2014-08-03  2:33   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:33 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:12:14AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> When reading an EA block in from disk, do a quick sanity check of the
> block header, and return an error if we think we have garbage.  Teach
> e2fsck to ignore the new error code in favor of doing its own
> checking, and remove the strict_csums bits while we're at it.
> 
> (Also document some assumptions in the new ext_attr code.)
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

					- Ted

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

* Re: [PATCH 06/19] e2fsck: try to salvage extent blocks with bad checksums
  2014-08-01 18:12 ` [PATCH 06/19] e2fsck: try to salvage extent blocks with bad checksums Darrick J. Wong
@ 2014-08-03  2:33   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:33 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:12:21AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Remove the code that would zap an extent block immediately if the
> checksum failed (i.e. strict_csums).  Instead, we'll only do that if
> the extent block header shows obvious structural problems; if the
> header checks out, then we'll iterate the block and see if we can
> recover some extents.
> 
> Requires a minor modification to ext2fs_extent_get such that the
> extent block will be returned in the buffer even if the return code
> indicates a checksum error.  This brings its behavior in line with
> the rest of libext2fs.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

						- Ted

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

* Re: [PATCH 07/19] e2fsck: try to salvage corrupt directory entry blocks
  2014-08-01 18:12 ` [PATCH 07/19] e2fsck: try to salvage corrupt directory entry blocks Darrick J. Wong
@ 2014-08-03  2:33   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:33 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:12:28AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Remove the code that would prompt the user to zap directory entry
> blocks with bad checksums (i.e. strict_csums).  Instead, we'll run the
> directory entries through the usual repair routines in an attempt to
> save whatever we can.  At the same time, refactor the code that
> schedules the repair of missing dirblock checksum entries.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

						- Ted

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

* Re: [PATCH 08/19] e2fsck: offer to clear inode table blocks that are insane
  2014-08-01 18:12 ` [PATCH 08/19] e2fsck: offer to clear inode table blocks that are insane Darrick J. Wong
@ 2014-08-03  2:46   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:46 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4, Darrick J. Wong

On Fri, Aug 01, 2014 at 11:12:34AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add a new behavior flag to the inode scan functions; when specified,
> this flag will do some simple sanity checking of entire inode table
> blocks.  If all the checksums are ok, we can skip checksum
> verification on individual inodes later on.  If more than half of the
> inodes look "insane" (bad extent tree root or checksum failure) then
> ext2fs_get_next_inode_full() can return a special status code
> indicating that what's in the buffer is probably garbage.
> 
> When e2fsck' inode scan encounters the 'inode is garbage' return code
> it'll offer to zap the inode straightaway instead of trying to recover
> anything.  This replaces the previous behavior of asking to zap
> anything with a checksum error (strict_csum).
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@orale.com>

Applied, thanks!!

					- Ted

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

* Re: [PATCH 09/19] e2fsck: correctly preserve fs flags when modifying ignore-csum-error flag
  2014-08-01 18:12 ` [PATCH 09/19] e2fsck: correctly preserve fs flags when modifying ignore-csum-error flag Darrick J. Wong
@ 2014-08-03  2:48   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:48 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:12:41AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> When we need to modify the "ignore checksum error" behavior flag to
> get us past a library call, it's possible that the library call can
> result in other flag bits being changed.  Therefore, it is not correct
> to restore unconditionally the previous flags value, since this will
> have unintended side effects on the other fs->flags; nor is it correct
> to assume that we can unconditionally set (or clear) the "ignore csum
> error" flag bit.  Therefore, we must merge the previous value of the
> "ignore csum error" flag with the value of flags after the call.
> 
> Note that we want to leave checksum verification on as much as
> possible because doing so exposes e2fsck bugs where two metadata
> blocks are "sharing" the same disk block, and attempting to fix one
> before relocating the other causes major filesystem damage.  The
> damage is much more obvious when a previously checked piece of
> metadata suddenly fails in a subsequent pass.
> 
> The modifications to the pass 2, 3, and 3A code are justified as
> follows: When e2fsck encounters a block of directory entries and
> cannot find the placeholder entry at the end that contains the
> checksum, it will try to insert the placeholder.  If that fails, it
> will schedule the directory for a pass 3A reconstruction.  Until that
> happens, we don't want directory block writing (pass 2), block
> iteration (pass 3), or block reading (pass 3A) to fail due to checksum
> errors, because failing to find the placeholder is itself a checksum
> verification error, which causes e2fsck to abort without fixing
> anything.
> 
> The e2fsck call to ext2fs_read_bitmaps must never fail due to a
> checksum error because e2fsck subsequently (a) verifies the bitmaps
> itself; or (b) decides that they don't match what has been observed,
> and rewrites them.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

						- Ted

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

* Re: [PATCH 10/19] libext2fs: Don't cache inodes that fail checksum verification
  2014-08-01 18:12 ` [PATCH 10/19] libext2fs: Don't cache inodes that fail checksum verification Darrick J. Wong
@ 2014-08-03  2:50   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:50 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:12:47AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> If an inode fails checksum verification, don't stuff a copy of it in
> the inode cache, because this can cause the library to fail to return
> the "corrupt inode" error code.
> 
> In general, this happens if ext2fs_read_inode_full() is called twice
> on an inode with an incorrect checksum.  If fs->flags has
> EXT2_FLAG_IGNORE_CSUM_ERRORS set during the first call and *unset*
> during the second call, the cache hit during the second call fails to
> return EXT2_ET_INODE_CSUM_INVALID as you'd expect.  This happens
> during fsck because the first read_inode call happens as part of
> check_blocks and the second call happens during inode checksum
> revalidation.  A file system with a slightly corrupt non-extent inode
> will trigger this.
> 
> While we're at it, make the inode read function consistent with the
> rest of libext2fs -- copy the metadata object into the caller's buffer
> even if it fails checksum verification.  This will help e2fsck avoid a
> double re-read later on down the line.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

						- Ted

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

* Re: [PATCH 11/19] e2fsck: disable checksum verification in a few select places
  2014-08-01 18:12 ` [PATCH 11/19] e2fsck: disable checksum verification in a few select places Darrick J. Wong
@ 2014-08-03  2:51   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:51 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:12:54AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Selectively disable checksum verification in a couple more places:
> 
> In check_blocks, disable checksum verification when iterating a block
> map because the block map iterator function (re)reads the inode, which
> could be unchanged since the scan found that the checksum fails.  We
> don't want to abort here; we want to keep evaluating the inode, and we
> already know if the inode checksum doesn't match.
> 
> Further down in check_blocks when we're trying to see if i_size
> matches the amount of data stored in the inode, don't allow checksum
> errors when we go looking for the size of inline data.  If the
> required attribute is at all find-able in the EA block, we'll fix any
> other problems with the EA block later.  In the meantime, we don't
> want to be truncating files unnecessarily.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

					- Ted

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

* Re: [PATCH 12/19] e2fsck: always ask to fix an inode that fails checksum verification
  2014-08-01 18:13 ` [PATCH 12/19] e2fsck: always ask to fix an inode that fails checksum verification Darrick J. Wong
@ 2014-08-03  2:55   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  2:55 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:13:00AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> If an inode fails checksum verification during pass 1 and the user
> doesn't fix or clear the inode as part of the regular inode checks,
> ensure that e2fsck remembers to ask the user if he simply wants to
> correct the checksum.
> 
> We weren't capturing all the ways out of an interation of the inode
> scanning loop, which means that not all errors were caught.  Also,
> we might as well clear the 'failed csum' flag if we write the inode
> directly from the inode scanning loop.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

						- Ted

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

* Re: [PATCH 13/19] tests: add regression tests for EA blocks with bad checksums
  2014-08-01 18:13 ` [PATCH 13/19] tests: add regression tests for EA blocks with bad checksums Darrick J. Wong
@ 2014-08-03  3:42   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  3:42 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:13:07AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add regression tests for e2fsck dealing with (a) EA block with a bad
> checksum; (b) EA block with a bad magic number; and (c) EA block with
> damage that isn't otherwise noticeable.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Thanks, applied.

						- Ted

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

* Re: [PATCH 14/19] tests: add tests for handling of corrupt extents
  2014-08-01 18:13 ` [PATCH 14/19] tests: add tests for handling of corrupt extents Darrick J. Wong
@ 2014-08-03  3:47   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  3:47 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:13:14AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add some regression tests to examine how e2fsck deals with (a) extent
> blocks with only a bad checksum; (b) extent blocks with a bad magic
> number; and (c) extent entries with corruption.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

						- Ted

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

* Re: [PATCH 15/19] tests: add tests for directory entry blocks with checksum errors
  2014-08-01 18:13 ` [PATCH 15/19] tests: add tests for directory entry blocks with checksum errors Darrick J. Wong
@ 2014-08-03  3:49   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  3:49 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:13:23AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add some regression tests to examine how e2fsck handles directory
> entry blocks and htree blocks with (a) malformed directory entries;
> (b) incorrect checksums; or (c) obviously garbage entries.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

					- Ted

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

* Re: [PATCH 16/19] tests: add regression tests for MMP blocks with bad checksums
  2014-08-01 18:13 ` [PATCH 16/19] tests: add regression tests for MMP blocks with bad checksums Darrick J. Wong
@ 2014-08-03  3:49   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  3:49 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:13:29AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add regression tests to examine how e2fsck deals with MMP blocks with
> (a) a bad magic number; and (b) an incorrect checksum.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

					- Ted

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

* Re: [PATCH 17/19] tests: add regression tests for superblocks with bad checksums
  2014-08-01 18:13 ` [PATCH 17/19] tests: add regression tests for superblocks " Darrick J. Wong
@ 2014-08-03  3:50   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  3:50 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:13:36AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add regression tests to examine how e2fsck deals with random
> superblock corruption such as obviously wrong fields and the checksum
> itself being incorrect.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

					- Ted

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

* Re: [PATCH 18/19] tests: add regression tests for group descriptors with bad checksums
  2014-08-01 18:13 ` [PATCH 18/19] tests: add regression tests for group descriptors " Darrick J. Wong
@ 2014-08-03  3:51   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  3:51 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:13:42AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add tests to examine how e2fsck deals with (a) the block bitmap being
> corrupt; (b) the inode bitmap being corrupt; (c) the bitmap checksums
> being incorrect (but the bitmaps are fine); and (d) the group
> descriptor checksum itself is incorrect.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

					- Ted

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

* Re: [PATCH 19/19] tests: add regression tests for inodes with bad checksums
  2014-08-01 18:13 ` [PATCH 19/19] tests: add regression tests for inodes " Darrick J. Wong
@ 2014-08-03  3:52   ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-03  3:52 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Fri, Aug 01, 2014 at 11:13:49AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add regression tests to e2fsck to examine how it deals with inode
> table blocks which (a) have been zero'd; (b) have been one'd; (c) have
> corrupt inodes with obvious problems; and (d) have inodes with
> non-obvious problems.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

						- Ted

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

* Re: [PATCH 03/19] e2fsck: use root dir for lost+found when really desperate
  2014-08-03  2:25   ` Theodore Ts'o
@ 2014-08-05  0:58     ` Darrick J. Wong
  2014-08-05  2:06       ` Theodore Ts'o
  0 siblings, 1 reply; 41+ messages in thread
From: Darrick J. Wong @ 2014-08-05  0:58 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4

On Sat, Aug 02, 2014 at 10:25:53PM -0400, Theodore Ts'o wrote:
> On Fri, Aug 01, 2014 at 11:11:59AM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > If we're totally unable to allocate a lost+found directory, ask the
> > user if he would like to dump orphaned files in the root directory.
> > Hopefully this enables the user to delete enough files so that a
> > subsequent run of e2fsck will make more progress.  Better to cram lost
> > files in the rootdir than the current behavior, which is to fail at
> > linking them in, thereby leaving them as lost files.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Applied, although I changed:
> 
> > +		printf("Delete some files and re-run e2fsck.\n\n");
> 
> to:
> 
> 		printf(_("Delete some files and re-run e2fsck.\n\n"));

I don't see this in the tree on kernel.org, but I'm sending you a patch to
change it to a fix_problem anyway.

--D
> 
> for proper internationalization support.  Usually, I like to run all
> messages through problem.c, like this:
> 
> 	fix_problem(ctx, PR_3_PASS_HEADER, &pctx);
> 
> 	{ PR_3_PASS_HEADER,
> 	  N_("Pass 3: Checking @d connectivity\n"),
> 	    PROMPT_NONE, 0 },
> 
> and I may change this over at some point, but I'll leave it as a
> printf for now.
> 
> Thanks!!
> 
> 						- Ted
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 03/19] e2fsck: use root dir for lost+found when really desperate
  2014-08-05  0:58     ` Darrick J. Wong
@ 2014-08-05  2:06       ` Theodore Ts'o
  0 siblings, 0 replies; 41+ messages in thread
From: Theodore Ts'o @ 2014-08-05  2:06 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Mon, Aug 04, 2014 at 05:58:58PM -0700, Darrick J. Wong wrote:
> 
> I don't see this in the tree on kernel.org, but I'm sending you a patch to
> change it to a fix_problem anyway.

It's there; on the next branch:

http://git.kernel.org/cgit/fs/ext2/e2fsprogs.git/commit/?h=next&id=0991896720917b467e573a5fae38539d950d0617

I hadn't bumped up the master branch just yet, since I usually like to
give a few days lag before master gets promoted:

http://git.kernel.org/cgit/fs/ext2/e2fsprogs.git/log/?h=next

Cheers,

						- Ted

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

end of thread, other threads:[~2014-08-05  2:06 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-01 18:11 [PATCH 00/19] e2fsprogs patchbomb 7/14, part 2.1 Darrick J. Wong
2014-08-01 18:11 ` [PATCH 01/19] e2fuzz: fix fs handle cleanup when closing fails Darrick J. Wong
2014-08-03  2:22   ` Theodore Ts'o
2014-08-01 18:11 ` [PATCH 02/19] e2fsck: never free critical metadata blocks in the block found map Darrick J. Wong
2014-08-03  2:22   ` Theodore Ts'o
2014-08-01 18:11 ` [PATCH 03/19] e2fsck: use root dir for lost+found when really desperate Darrick J. Wong
2014-08-03  2:25   ` Theodore Ts'o
2014-08-05  0:58     ` Darrick J. Wong
2014-08-05  2:06       ` Theodore Ts'o
2014-08-01 18:12 ` [PATCH 04/19] dumpe2fs: complain when checksum verification fails Darrick J. Wong
2014-08-03  2:26   ` Theodore Ts'o
2014-08-01 18:12 ` [PATCH 05/19] libext2fs: check EA block headers when reading in the block Darrick J. Wong
2014-08-03  2:33   ` Theodore Ts'o
2014-08-01 18:12 ` [PATCH 06/19] e2fsck: try to salvage extent blocks with bad checksums Darrick J. Wong
2014-08-03  2:33   ` Theodore Ts'o
2014-08-01 18:12 ` [PATCH 07/19] e2fsck: try to salvage corrupt directory entry blocks Darrick J. Wong
2014-08-03  2:33   ` Theodore Ts'o
2014-08-01 18:12 ` [PATCH 08/19] e2fsck: offer to clear inode table blocks that are insane Darrick J. Wong
2014-08-03  2:46   ` Theodore Ts'o
2014-08-01 18:12 ` [PATCH 09/19] e2fsck: correctly preserve fs flags when modifying ignore-csum-error flag Darrick J. Wong
2014-08-03  2:48   ` Theodore Ts'o
2014-08-01 18:12 ` [PATCH 10/19] libext2fs: Don't cache inodes that fail checksum verification Darrick J. Wong
2014-08-03  2:50   ` Theodore Ts'o
2014-08-01 18:12 ` [PATCH 11/19] e2fsck: disable checksum verification in a few select places Darrick J. Wong
2014-08-03  2:51   ` Theodore Ts'o
2014-08-01 18:13 ` [PATCH 12/19] e2fsck: always ask to fix an inode that fails checksum verification Darrick J. Wong
2014-08-03  2:55   ` Theodore Ts'o
2014-08-01 18:13 ` [PATCH 13/19] tests: add regression tests for EA blocks with bad checksums Darrick J. Wong
2014-08-03  3:42   ` Theodore Ts'o
2014-08-01 18:13 ` [PATCH 14/19] tests: add tests for handling of corrupt extents Darrick J. Wong
2014-08-03  3:47   ` Theodore Ts'o
2014-08-01 18:13 ` [PATCH 15/19] tests: add tests for directory entry blocks with checksum errors Darrick J. Wong
2014-08-03  3:49   ` Theodore Ts'o
2014-08-01 18:13 ` [PATCH 16/19] tests: add regression tests for MMP blocks with bad checksums Darrick J. Wong
2014-08-03  3:49   ` Theodore Ts'o
2014-08-01 18:13 ` [PATCH 17/19] tests: add regression tests for superblocks " Darrick J. Wong
2014-08-03  3:50   ` Theodore Ts'o
2014-08-01 18:13 ` [PATCH 18/19] tests: add regression tests for group descriptors " Darrick J. Wong
2014-08-03  3:51   ` Theodore Ts'o
2014-08-01 18:13 ` [PATCH 19/19] tests: add regression tests for inodes " Darrick J. Wong
2014-08-03  3:52   ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.