lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 12 Jun 2018 11:53:23 +0200
From:   Jan Kara <jack@...e.cz>
To:     <linux-ext4@...r.kernel.org>
Cc:     Ted Tso <tytso@....edu>, Jan Kara <jack@...e.cz>
Subject: [PATCH 05/10] e2fsck: Allow to fix some superblock corruptions

Add a flag to ext2fs_open() which allows to open a filesystem even if
superblock is somewhat inconsistent. Use this flag from e2fsck as a last
resort to try to fix the superblok.

Currently, the flag does nothing. We'll relax checks in ext2fs_open()
once e2fsck is able to handle corresponding corruption gracefully.

Reviewed-by: Andreas Dilger <adilger@...ger.ca>
Signed-off-by: Jan Kara <jack@...e.cz>
---
 e2fsck/unix.c       | 22 +++++++++++++++++++++-
 lib/ext2fs/ext2fs.h |  1 +
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index cbe5ec5034cb..55e21ea0aeac 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1364,7 +1364,7 @@ int main (int argc, char *argv[])
 	const char	*lib_ver_date;
 	int		my_ver, lib_ver;
 	e2fsck_t	ctx;
-	blk64_t		orig_superblock;
+	blk64_t		orig_superblock = ~(blk64_t)0;
 	struct problem_context pctx;
 	int flags, run_result, was_changed;
 	int journal_size;
@@ -1571,6 +1571,26 @@ failure:
 					     "check of the device.\n"));
 #endif
 		else {
+			/*
+			 * Let's try once more will less consistency checking
+			 * so that we are able to recover from more errors
+			 * (e.g. some tool messing up some value in the sb).
+			 */
+			if (!(flags & EXT2_FLAG_IGNORE_SB_ERRORS)) {
+				if (fs)
+					ext2fs_close_free(&fs);
+				log_out(ctx, _("%s: Trying to load superblock "
+					"despite errors...\n"),
+					ctx->program_name);
+				flags |= EXT2_FLAG_IGNORE_SB_ERRORS;
+				/*
+				 * If we tried backup sb, revert to the
+				 * original one now.
+				 */
+				if (orig_superblock != ~(blk64_t)0)
+					ctx->superblock = orig_superblock;
+				goto restart;
+			}
 			fix_problem(ctx, PR_0_SB_CORRUPT, &pctx);
 			if (retval == EXT2_ET_BAD_MAGIC)
 				check_plausibility(ctx->filesystem_name,
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 6774e32c91c2..250fd174cd48 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -195,6 +195,7 @@ typedef struct ext2_file *ext2_file_t;
 #define EXT2_FLAG_DIRECT_IO		0x80000
 #define EXT2_FLAG_SKIP_MMP		0x100000
 #define EXT2_FLAG_IGNORE_CSUM_ERRORS	0x200000
+#define EXT2_FLAG_IGNORE_SB_ERRORS	0x400000
 
 /*
  * Special flag in the ext2 inode i_flag field that means that this is
-- 
2.13.7

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux - Powered by OpenVZ