diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-09 16:42:05 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-09 16:42:05 -0700 |
commit | 54f93b74cf8c575bb89f9bf32a40a39b83ace1e9 (patch) | |
tree | 3d91292c328e5e93922c2815b0fde943c9d07fad /fs | |
parent | 3b3809ac5375f614bbf8671cddeae3c693aa584e (diff) | |
parent | 0f2ddca66d70c8ccba7486cf2d79c6b60e777abd (diff) | |
download | kernel_samsung_aries-54f93b74cf8c575bb89f9bf32a40a39b83ace1e9.zip kernel_samsung_aries-54f93b74cf8c575bb89f9bf32a40a39b83ace1e9.tar.gz kernel_samsung_aries-54f93b74cf8c575bb89f9bf32a40a39b83ace1e9.tar.bz2 |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
ext4: check block device size on mount
ext4: Fix off-by-one-error in ext4_valid_extent_idx()
ext4: Fix big-endian problem in __ext4_check_blockref()
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/extents.c | 2 | ||||
-rw-r--r-- | fs/ext4/inode.c | 8 | ||||
-rw-r--r-- | fs/ext4/super.c | 9 |
3 files changed, 14 insertions, 5 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index ac77d8b..6132353 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -342,7 +342,7 @@ static int ext4_valid_extent_idx(struct inode *inode, ext4_fsblk_t block = idx_pblock(ext_idx); struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es; if (unlikely(block < le32_to_cpu(es->s_first_data_block) || - (block > ext4_blocks_count(es)))) + (block >= ext4_blocks_count(es)))) return 0; else return 1; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index a2e7952..c6bd6ce 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -372,16 +372,16 @@ static int ext4_block_to_path(struct inode *inode, } static int __ext4_check_blockref(const char *function, struct inode *inode, - unsigned int *p, unsigned int max) { + __le32 *p, unsigned int max) { unsigned int maxblocks = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es); - unsigned int *bref = p; + __le32 *bref = p; while (bref < p+max) { - if (unlikely(*bref >= maxblocks)) { + if (unlikely(le32_to_cpu(*bref) >= maxblocks)) { ext4_error(inode->i_sb, function, "block reference %u >= max (%u) " "in inode #%lu, offset=%d", - *bref, maxblocks, + le32_to_cpu(*bref), maxblocks, inode->i_ino, (int)(bref-p)); return -EIO; } diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 9987bba..2958f4e 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2508,6 +2508,15 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) if (EXT4_BLOCKS_PER_GROUP(sb) == 0) goto cantfind_ext4; + /* check blocks count against device size */ + blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; + if (blocks_count && ext4_blocks_count(es) > blocks_count) { + printk(KERN_WARNING "EXT4-fs: bad geometry: block count %llu " + "exceeds size of device (%llu blocks)\n", + ext4_blocks_count(es), blocks_count); + goto failed_mount; + } + /* * It makes no sense for the first data block to be beyond the end * of the filesystem. |