Whamcloud - gitweb
e2fsck: don't clobber critical metadata during check_blocks
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 23 Jul 2014 16:11:23 +0000 (12:11 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 23 Jul 2014 16:11:23 +0000 (12:11 -0400)
commit35c8faaffcb9a1a75ad1210e605df21978c2b2ce
treeb930affdee5589dc07fdd782c8344dc0399857bb
parent7ba5cc744b842da7a7109fbf8f0c53dbc63bcae1
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>
12 files changed:
e2fsck/e2fsck.c
e2fsck/e2fsck.h
e2fsck/pass1.c
e2fsck/pass1b.c
e2fsck/pass5.c
e2fsck/problem.c
e2fsck/problem.h
tests/f_itable_collision/expect.1 [new file with mode: 0644]
tests/f_itable_collision/expect.2 [new file with mode: 0644]
tests/f_itable_collision/image.gz [new file with mode: 0644]
tests/f_itable_collision/name [new file with mode: 0644]
tests/f_itable_collision/script [new file with mode: 0755]