Skip to contentSkip to conversation

hfsplus oops on image without extends

PATCH In review Eric Sesterhenn 2 participants 3 messages May 7, 2008 – May 9, 2008 Hfsplus filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hfsplus oops on image without extends

hi,

the following patch fixes an oops with a corrupted hfs+ image. see http://bugzilla.kernel.org/show_bug.cgi?id=10548 for details.

Problem is that we call hfs_btree_open() from hfsplus_fill_super() to set HFSPLUS_SB(sb).[ext_tree|cat_tree]
Both trees are still NULL at this moment. If hfs_btree_open() fails for any reason it calls iput() on the page, which
gets to hfsplus_releasepage() which tries to access HFSPLUS_SB(sb).* which is still NULL and oopses while dereferencing it.

fs/hfsplus/inode.c renamed from fs/hfsplus/inode.c.orig +2 -0
@@ -65,6 +65,8 @@ static int hfsplus_releasepage(struct pa
 		BUG();
 		return 0;
 	}
+	it (!tree)
+		return 0;
 	if (tree->node_size >= PAGE_CACHE_SIZE) {
 		nidx = page->index >> (tree->node_size_shift - PAGE_CACHE_SHIFT);
 		spin_lock(&tree->hash_lock);
#1 lore raw
Quoted 18 lines · Eric Sesterhenn

hi,

the following patch fixes an oops with a corrupted hfs+ image. see http://bugzilla.kernel.org/show_bug.cgi?id=10548 for details.

Problem is that we call hfs_btree_open() from hfsplus_fill_super() to set HFSPLUS_SB(sb).[ext_tree|cat_tree]
Both trees are still NULL at this moment. If hfs_btree_open() fails for any reason it calls iput() on the page, which
gets to hfsplus_releasepage() which tries to access HFSPLUS_SB(sb).* which is still NULL and oopses while dereferencing it.

fs/hfsplus/inode.c static int hfsplus_releasepage(struct pa · line 69

Quoted 5 lines
fs/hfsplus/inode.c renamed from fs/hfsplus/inode.c.orig +2 -0
@@ -65,6 +65,8 @@ static int hfsplus_releasepage(struct pa
 		BUG();
 		return 0;
 	}
+	it (!tree)
+		return 0;

Erm, I presume this is meant to be 'if', checkpatch whined about the space as it thought it was a function. I guess this hasn't been compile tested?

fs/hfsplus/inode.c static int hfsplus_releasepage(struct pa · line 72

Quoted 3 lines
fs/hfsplus/inode.c renamed from fs/hfsplus/inode.c.orig +0 -0
 	if (tree->node_size >= PAGE_CACHE_SIZE) {
 		nidx = page->index >> (tree->node_size_shift - PAGE_CACHE_SHIFT);
 		spin_lock(&tree->hash_lock);

-apw

#2 lore raw
Quoted 13 lines · * Andy Whitcroft ([email protected]) wrote:
Quoted 11 lines · Eric Sesterhenn

hi,

the following patch fixes an oops with a corrupted hfs+ image. see http://bugzilla.kernel.org/show_bug.cgi?id=10548 for details.

Problem is that we call hfs_btree_open() from hfsplus_fill_super() to set HFSPLUS_SB(sb).[ext_tree|cat_tree]
Both trees are still NULL at this moment. If hfs_btree_open() fails for any reason it calls iput() on the page, which
gets to hfsplus_releasepage() which tries to access HFSPLUS_SB(sb).* which is still NULL and oopses while dereferencing it.

Quoted 3 lines

Erm, I presume this is meant to be 'if', checkpatch whined about the space as it thought it was a function. I guess this hasn't been compile tested?

sorry, i messed this up, didnt have the original patch anymore and quickly recreated it. Andrew already put a fix in -mm

Greetings, Eric