linux/fs/ext3
Eric Sandeen 40b851348f [PATCH] handle ext3 directory corruption better
I've been using Steve Grubb's purely evil "fsfuzzer" tool, at
http://people.redhat.com/sgrubb/files/fsfuzzer-0.4.tar.gz

Basically it makes a filesystem, splats some random bits over it, then
tries to mount it and do some simple filesystem actions.

At best, the filesystem catches the corruption gracefully.  At worst,
things spin out of control.

As you might guess, we found a couple places in ext3 where things spin out
of control :)

First, we had a corrupted directory that was never checked for
consistency...  it was corrupt, and pointed to another bad "entry" of
length 0.  The for() loop looped forever, since the length of
ext3_next_entry(de) was 0, and we kept looking at the same pointer over and
over and over and over...  I modeled this check and subsequent action on
what is done for other directory types in ext3_readdir...

(adding this check adds some computational expense; I am testing a followup
patch to reduce the number of times we check and re-check these directory
entries, in all cases.  Thanks for the idea, Andreas).

Next we had a root directory inode which had a corrupted size, claimed to
be > 200M on a 4M filesystem.  There was only really 1 block in the
directory, but because the size was so large, readdir kept coming back for
more, spewing thousands of printk's along the way.

Per Andreas' suggestion, if we're in this read error condition and we're
trying to read an offset which is greater than i_blocks worth of bytes,
stop trying, and break out of the loop.

With these two changes fsfuzz test survives quite well on ext3.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Cc: <linux-ext4@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-07 08:39:33 -08:00
..
acl.c [PATCH] fs: Removing useless casts 2006-09-27 08:26:10 -07:00
acl.h [PATCH] Remove leftover ext3 acl declarations 2006-07-10 13:24:26 -07:00
balloc.c [PATCH] more ext3 16T overflow fixes 2006-09-27 08:26:10 -07:00
bitmap.c [PATCH] ext3 and jbd cleanup: remove whitespace 2006-09-27 08:26:09 -07:00
dir.c [PATCH] handle ext3 directory corruption better 2006-12-07 08:39:33 -08:00
file.c [PATCH] Remove readv/writev methods and use aio_read/aio_write instead 2006-10-01 00:39:28 -07:00
fsync.c [PATCH] ext3 and jbd cleanup: remove whitespace 2006-09-27 08:26:09 -07:00
hash.c [PATCH] ext3: More whitespace cleanups 2006-09-27 08:26:10 -07:00
ialloc.c [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
inode.c [PATCH] ext3: make meta data reads use READ_META 2006-09-30 20:29:42 +02:00
ioctl.c [PATCH] BLOCK: Move the Ext3 device ioctl compat stuff to the Ext3 driver [try #6] 2006-09-30 20:52:29 +02:00
Makefile Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
namei.c [PATCH] handle ext3 directory corruption better 2006-12-07 08:39:33 -08:00
namei.h [PATCH] ext3: sparse fixes 2005-10-30 17:37:25 -08:00
resize.c [PATCH] fs: Removing useless casts 2006-09-27 08:26:10 -07:00
super.c [PATCH] ext3: fsid for statvfs 2006-12-07 08:39:31 -08:00
symlink.c Fix nasty ncpfs symlink handling bug. 2005-08-19 18:02:56 -07:00
xattr_security.c [PATCH] ext3: Enable atomic inode security labeling 2005-09-09 13:57:28 -07:00
xattr_trusted.c [PATCH] capable/capability.h (fs/) 2006-01-11 18:42:13 -08:00
xattr_user.c [PATCH] remove ext3 xattr permission checks 2006-01-10 08:01:30 -08:00
xattr.c [PATCH] Remove superfluous lock_super() in extN xattr code 2006-12-07 08:39:32 -08:00
xattr.h Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00