aboutsummaryrefslogtreecommitdiffstats
path: root/e2fsck/pass1b.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2014-07-23 12:11:23 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-07-23 12:11:23 -0400
commit35c8faaffcb9a1a75ad1210e605df21978c2b2ce (patch)
treeb930affdee5589dc07fdd782c8344dc0399857bb /e2fsck/pass1b.c
parent7ba5cc744b842da7a7109fbf8f0c53dbc63bcae1 (diff)
downloadandroid_external_e2fsprogs-35c8faaffcb9a1a75ad1210e605df21978c2b2ce.tar.gz
android_external_e2fsprogs-35c8faaffcb9a1a75ad1210e605df21978c2b2ce.tar.bz2
android_external_e2fsprogs-35c8faaffcb9a1a75ad1210e605df21978c2b2ce.zip
e2fsck: don't clobber critical metadata during check_blocks
If we encounter an inode with IND/DIND/TIND blocks or internal extent tree blocks that point into critical FS metadata such as the superblock, the group descriptors, the bitmaps, or the inode table, it's quite possible that the validation code for those blocks is not going to like what it finds, and it'll ask to try to fix the block. Unfortunately, this happens before duplicate block processing (pass 1b), which means that we can end up doing stupid things like writing extent blocks into the inode table, which multiplies e2fsck' destructive effect and can render a filesystem unfixable. To solve this, create a bitmap of all the critical FS metadata. If before pass1b runs (basically check_blocks) we find a metadata block that points into these critical regions, continue processing that block, but avoid making any modifications, because we could be misinterpreting inodes as block maps. Pass 1b will find the multiply-owned blocks and fix that situation, which means that we can then restart e2fsck from the beginning and actually fix whatever problems we find. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'e2fsck/pass1b.c')
-rw-r--r--e2fsck/pass1b.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c
index b4041d18..c2a3cf30 100644
--- a/e2fsck/pass1b.c
+++ b/e2fsck/pass1b.c
@@ -389,7 +389,7 @@ static int process_pass1b_block(ext2_filsys fs EXT2FS_ATTR((unused)),
p->dup_blocks++;
ext2fs_mark_inode_bitmap2(inode_dup_map, p->ino);
- if (lc != p->cur_cluster)
+ if (blockcnt < 0 || lc != p->cur_cluster)
add_dupe(ctx, p->ino, EXT2FS_B2C(fs, *block_nr), p->inode);
finish: