aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorPhillip Lougher <phillip@lougher.org.uk>2006-12-06 23:37:20 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-07 11:39:36 -0500
commit8bb0269160df2a60764013994d0bc5165406cf4a (patch)
tree1d91813ab99469213ee72afe90e7341a58a7fa79 /fs
parent2e591bbc0d563e12f5a260fbbca0df7d5810910e (diff)
[PATCH] corrupted cramfs filesystems cause kernel oops
Steve Grubb's fzfuzzer tool (http://people.redhat.com/sgrubb/files/ fsfuzzer-0.6.tar.gz) generates corrupt Cramfs filesystems which cause Cramfs to kernel oops in cramfs_uncompress_block(). The cause of the oops is an unchecked corrupted block length field read by cramfs_readpage(). This patch adds a sanity check to cramfs_readpage() which checks that the block length field is sensible. The (PAGE_CACHE_SIZE << 1) size check is intentional, even though the uncompressed data is not going to be larger than PAGE_CACHE_SIZE, gzip sometimes generates compressed data larger than the original source data. Mkcramfs checks that the compressed size is always less than or equal to PAGE_CACHE_SIZE << 1. Of course Cramfs could use the original uncompressed data in this case, but it doesn't. Signed-off-by: Phillip Lougher <phillip@lougher.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/cramfs/inode.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index a624c3ec8189..0509cedd415c 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -481,6 +481,8 @@ static int cramfs_readpage(struct file *file, struct page * page)
481 pgdata = kmap(page); 481 pgdata = kmap(page);
482 if (compr_len == 0) 482 if (compr_len == 0)
483 ; /* hole */ 483 ; /* hole */
484 else if (compr_len > (PAGE_CACHE_SIZE << 1))
485 printk(KERN_ERR "cramfs: bad compressed blocksize %u\n", compr_len);
484 else { 486 else {
485 mutex_lock(&read_mutex); 487 mutex_lock(&read_mutex);
486 bytes_filled = cramfs_uncompress_block(pgdata, 488 bytes_filled = cramfs_uncompress_block(pgdata,