Commit cdface52 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4

Pull ext4 fixes from Ted Ts'o:
 "Fix misc bugs and a regression for ext4"

* tag 'for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
  ext4: add MODULE_SOFTDEP to ensure crc32c is included in the initramfs
  ext4: fix bitmap position validation
  ext4: set h_journal if there is a failure starting a reserved handle
  ext4: prevent right-shifting extents beyond EXT_MAX_BLOCKS
parents 19b9ad67 7ef79ad5
...@@ -321,6 +321,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb, ...@@ -321,6 +321,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
struct ext4_sb_info *sbi = EXT4_SB(sb); struct ext4_sb_info *sbi = EXT4_SB(sb);
ext4_grpblk_t offset; ext4_grpblk_t offset;
ext4_grpblk_t next_zero_bit; ext4_grpblk_t next_zero_bit;
ext4_grpblk_t max_bit = EXT4_CLUSTERS_PER_GROUP(sb);
ext4_fsblk_t blk; ext4_fsblk_t blk;
ext4_fsblk_t group_first_block; ext4_fsblk_t group_first_block;
...@@ -338,7 +339,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb, ...@@ -338,7 +339,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
/* check whether block bitmap block number is set */ /* check whether block bitmap block number is set */
blk = ext4_block_bitmap(sb, desc); blk = ext4_block_bitmap(sb, desc);
offset = blk - group_first_block; offset = blk - group_first_block;
if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize || if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data)) !ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
/* bad block bitmap */ /* bad block bitmap */
return blk; return blk;
...@@ -346,7 +347,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb, ...@@ -346,7 +347,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
/* check whether the inode bitmap block number is set */ /* check whether the inode bitmap block number is set */
blk = ext4_inode_bitmap(sb, desc); blk = ext4_inode_bitmap(sb, desc);
offset = blk - group_first_block; offset = blk - group_first_block;
if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize || if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data)) !ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
/* bad block bitmap */ /* bad block bitmap */
return blk; return blk;
...@@ -354,8 +355,8 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb, ...@@ -354,8 +355,8 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
/* check whether the inode table block number is set */ /* check whether the inode table block number is set */
blk = ext4_inode_table(sb, desc); blk = ext4_inode_table(sb, desc);
offset = blk - group_first_block; offset = blk - group_first_block;
if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize || if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
EXT4_B2C(sbi, offset + sbi->s_itb_per_group) >= sb->s_blocksize) EXT4_B2C(sbi, offset + sbi->s_itb_per_group) >= max_bit)
return blk; return blk;
next_zero_bit = ext4_find_next_zero_bit(bh->b_data, next_zero_bit = ext4_find_next_zero_bit(bh->b_data,
EXT4_B2C(sbi, offset + sbi->s_itb_per_group), EXT4_B2C(sbi, offset + sbi->s_itb_per_group),
......
...@@ -5329,8 +5329,9 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle, ...@@ -5329,8 +5329,9 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
stop = le32_to_cpu(extent->ee_block); stop = le32_to_cpu(extent->ee_block);
/* /*
* In case of left shift, Don't start shifting extents until we make * For left shifts, make sure the hole on the left is big enough to
* sure the hole is big enough to accommodate the shift. * accommodate the shift. For right shifts, make sure the last extent
* won't be shifted beyond EXT_MAX_BLOCKS.
*/ */
if (SHIFT == SHIFT_LEFT) { if (SHIFT == SHIFT_LEFT) {
path = ext4_find_extent(inode, start - 1, &path, path = ext4_find_extent(inode, start - 1, &path,
...@@ -5350,9 +5351,14 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle, ...@@ -5350,9 +5351,14 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
if ((start == ex_start && shift > ex_start) || if ((start == ex_start && shift > ex_start) ||
(shift > start - ex_end)) { (shift > start - ex_end)) {
ext4_ext_drop_refs(path); ret = -EINVAL;
kfree(path); goto out;
return -EINVAL; }
} else {
if (shift > EXT_MAX_BLOCKS -
(stop + ext4_ext_get_actual_len(extent))) {
ret = -EINVAL;
goto out;
} }
} }
......
...@@ -5886,5 +5886,6 @@ static void __exit ext4_exit_fs(void) ...@@ -5886,5 +5886,6 @@ static void __exit ext4_exit_fs(void)
MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
MODULE_DESCRIPTION("Fourth Extended Filesystem"); MODULE_DESCRIPTION("Fourth Extended Filesystem");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_SOFTDEP("pre: crc32c");
module_init(ext4_init_fs) module_init(ext4_init_fs)
module_exit(ext4_exit_fs) module_exit(ext4_exit_fs)
...@@ -532,6 +532,7 @@ int jbd2_journal_start_reserved(handle_t *handle, unsigned int type, ...@@ -532,6 +532,7 @@ int jbd2_journal_start_reserved(handle_t *handle, unsigned int type,
*/ */
ret = start_this_handle(journal, handle, GFP_NOFS); ret = start_this_handle(journal, handle, GFP_NOFS);
if (ret < 0) { if (ret < 0) {
handle->h_journal = journal;
jbd2_journal_free_reserved(handle); jbd2_journal_free_reserved(handle);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment