android_kernel_xiaomi_sm8350/fs/ext4
Eric Sandeen e6c4021190 [PATCH] handle ext4 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 ext4 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
ext4_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 ext4_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 ext4.

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] ext4 whitespace cleanups 2006-10-11 11:14:19 -07:00
acl.h [PATCH] ext4: rename ext4 symbols to avoid duplication of ext3 symbols 2006-10-11 11:14:15 -07:00
balloc.c [PATCH] ext4 64 bit divide fix 2006-10-11 11:14:18 -07:00
bitmap.c [PATCH] jbd2: enable building of jbd2 and have ext4 use it rather than jbd 2006-10-11 11:14:16 -07:00
dir.c [PATCH] handle ext4 directory corruption better 2006-12-07 08:39:33 -08:00
extents.c [PATCH] ext4 whitespace cleanups 2006-10-11 11:14:19 -07:00
file.c [PATCH] jbd2: enable building of jbd2 and have ext4 use it rather than jbd 2006-10-11 11:14:16 -07:00
fsync.c [PATCH] jbd2: enable building of jbd2 and have ext4 use it rather than jbd 2006-10-11 11:14:16 -07:00
hash.c [PATCH] jbd2: enable building of jbd2 and have ext4 use it rather than jbd 2006-10-11 11:14:16 -07:00
ialloc.c [PATCH] ext4 64 bit divide fix 2006-10-11 11:14:18 -07:00
inode.c [PATCH] ext4: move block number hi bits 2006-10-11 11:14:18 -07:00
ioctl.c [PATCH] ext3: add extent map support 2006-10-11 11:14:16 -07:00
Makefile [PATCH] ext3: add extent map support 2006-10-11 11:14:16 -07:00
namei.c [PATCH] handle ext4 directory corruption better 2006-12-07 08:39:33 -08:00
namei.h [PATCH] ext4: rename ext4 symbols to avoid duplication of ext3 symbols 2006-10-11 11:14:15 -07:00
resize.c [PATCH] ext4: fix printk format warnings 2006-10-28 11:30:51 -07:00
super.c [PATCH] ext4: fsid for statvfs 2006-12-07 08:39:31 -08:00
symlink.c [PATCH] jbd2: enable building of jbd2 and have ext4 use it rather than jbd 2006-10-11 11:14:16 -07:00
xattr_security.c [PATCH] jbd2: enable building of jbd2 and have ext4 use it rather than jbd 2006-10-11 11:14:16 -07:00
xattr_trusted.c [PATCH] jbd2: enable building of jbd2 and have ext4 use it rather than jbd 2006-10-11 11:14:16 -07:00
xattr_user.c [PATCH] jbd2: enable building of jbd2 and have ext4 use it rather than jbd 2006-10-11 11:14:16 -07:00
xattr.c [PATCH] Remove superfluous lock_super() in extN xattr code 2006-12-07 08:39:32 -08:00
xattr.h [PATCH] ext4: rename ext4 symbols to avoid duplication of ext3 symbols 2006-10-11 11:14:15 -07:00