hfs: handle more on-disk corruptions without oopsing
authorEric Sandeen <sandeen@redhat.com>
Tue, 8 Jan 2008 23:33:20 +0000 (15:33 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 9 Jan 2008 00:10:36 +0000 (16:10 -0800)
commitcf0594625083111ae522496dc1c256f7476939c2
treef83641f74c89fa4fb17adb2f216b074f2352639c
parent467bc461d2845f6a04b124bca1ae6ecc554e1ee5
hfs: handle more on-disk corruptions without oopsing

hfs seems prone to bad things when it encounters on disk corruption.  Many
values are read from disk, and used as lengths to memcpy, as an example.
This patch fixes up several of these problematic cases.

o sanity check the on-disk maximum key lengths on mount
  (these are set to a defined value at mkfs time and shouldn't differ)
o check on-disk node keylens against the maximum key length for each tree
o fix hfs_btree_open so that going out via free_tree: doesn't wind
  up in hfs_releasepage, which wants to follow the very pointer
  we were trying to set up:
HFS_SB(sb)->cat_tree = hfs_btree_open()
...
failure gets to hfs_releasepage and tries
to follow HFS_SB(sb)->cat_tree

Tested with the fsfuzzer; it survives more than it used to.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/hfs/bfind.c
fs/hfs/brec.c
fs/hfs/btree.c
fs/hfs/hfs.h