diff options
author | Duane Griffin <duaneg@dghda.com> | 2008-07-25 04:46:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 13:53:32 -0400 |
commit | 3ccc3167b0e5d46ab3bf03e22fbdb7616ce038cd (patch) | |
tree | 2dcd2ebb5ffa7271541d23e721101fca57a0eb33 /fs/ext3 | |
parent | 95450f5a7e53d5752ce1a0d0b8282e10fe745ae0 (diff) |
ext3: handle deleting corrupted indirect blocks
While freeing indirect blocks we attach a journal head to the parent
buffer head, free the blocks, then journal the parent. If the indirect
block list is corrupted and points to the parent the journal head will be
detached when the block is cleared, causing an OOPS.
Check for that explicitly and handle it gracefully.
This patch fixes the third case (image hdb.20000057.nullderef.gz)
reported in http://bugzilla.kernel.org/show_bug.cgi?id=10882.
Immediately above the change, in the ext3_free_data function, we call
ext3_clear_blocks to clear the indirect blocks in this parent block. If
one of those blocks happens to actually be the parent block it will clear
b_private / BH_JBD.
I did the check at the end rather than earlier as it seemed more elegant.
I don't think there should be much practical difference, although it is
possible the FS may not be quite so badly corrupted if we did it the other
way (and didn't clear the block at all). To be honest, I'm not convinced
there aren't other similar failure modes lurking in this code, although I
couldn't find any with a quick review.
[akpm@linux-foundation.org: fix printk warning]
Signed-off-by: Duane Griffin <duaneg@dghda.com>
Cc: <linux-ext4@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext3')
-rw-r--r-- | fs/ext3/inode.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 36f74f17a11c..3bf07d70b914 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
@@ -2127,7 +2127,21 @@ static void ext3_free_data(handle_t *handle, struct inode *inode, | |||
2127 | 2127 | ||
2128 | if (this_bh) { | 2128 | if (this_bh) { |
2129 | BUFFER_TRACE(this_bh, "call ext3_journal_dirty_metadata"); | 2129 | BUFFER_TRACE(this_bh, "call ext3_journal_dirty_metadata"); |
2130 | ext3_journal_dirty_metadata(handle, this_bh); | 2130 | |
2131 | /* | ||
2132 | * The buffer head should have an attached journal head at this | ||
2133 | * point. However, if the data is corrupted and an indirect | ||
2134 | * block pointed to itself, it would have been detached when | ||
2135 | * the block was cleared. Check for this instead of OOPSing. | ||
2136 | */ | ||
2137 | if (bh2jh(this_bh)) | ||
2138 | ext3_journal_dirty_metadata(handle, this_bh); | ||
2139 | else | ||
2140 | ext3_error(inode->i_sb, "ext3_free_data", | ||
2141 | "circular indirect block detected, " | ||
2142 | "inode=%lu, block=%llu", | ||
2143 | inode->i_ino, | ||
2144 | (unsigned long long)this_bh->b_blocknr); | ||
2131 | } | 2145 | } |
2132 | } | 2146 | } |
2133 | 2147 | ||