Skip to content

Commit cdface5

Browse files
committed
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
2 parents 19b9ad6 + 7ef79ad commit cdface5

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

fs/ext4/balloc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
321321
struct ext4_sb_info *sbi = EXT4_SB(sb);
322322
ext4_grpblk_t offset;
323323
ext4_grpblk_t next_zero_bit;
324+
ext4_grpblk_t max_bit = EXT4_CLUSTERS_PER_GROUP(sb);
324325
ext4_fsblk_t blk;
325326
ext4_fsblk_t group_first_block;
326327

@@ -338,24 +339,24 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
338339
/* check whether block bitmap block number is set */
339340
blk = ext4_block_bitmap(sb, desc);
340341
offset = blk - group_first_block;
341-
if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize ||
342+
if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
342343
!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
343344
/* bad block bitmap */
344345
return blk;
345346

346347
/* check whether the inode bitmap block number is set */
347348
blk = ext4_inode_bitmap(sb, desc);
348349
offset = blk - group_first_block;
349-
if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize ||
350+
if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
350351
!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
351352
/* bad block bitmap */
352353
return blk;
353354

354355
/* check whether the inode table block number is set */
355356
blk = ext4_inode_table(sb, desc);
356357
offset = blk - group_first_block;
357-
if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize ||
358-
EXT4_B2C(sbi, offset + sbi->s_itb_per_group) >= sb->s_blocksize)
358+
if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
359+
EXT4_B2C(sbi, offset + sbi->s_itb_per_group) >= max_bit)
359360
return blk;
360361
next_zero_bit = ext4_find_next_zero_bit(bh->b_data,
361362
EXT4_B2C(sbi, offset + sbi->s_itb_per_group),

fs/ext4/extents.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5329,8 +5329,9 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
53295329
stop = le32_to_cpu(extent->ee_block);
53305330

53315331
/*
5332-
* In case of left shift, Don't start shifting extents until we make
5333-
* sure the hole is big enough to accommodate the shift.
5332+
* For left shifts, make sure the hole on the left is big enough to
5333+
* accommodate the shift. For right shifts, make sure the last extent
5334+
* won't be shifted beyond EXT_MAX_BLOCKS.
53345335
*/
53355336
if (SHIFT == SHIFT_LEFT) {
53365337
path = ext4_find_extent(inode, start - 1, &path,
@@ -5350,9 +5351,14 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
53505351

53515352
if ((start == ex_start && shift > ex_start) ||
53525353
(shift > start - ex_end)) {
5353-
ext4_ext_drop_refs(path);
5354-
kfree(path);
5355-
return -EINVAL;
5354+
ret = -EINVAL;
5355+
goto out;
5356+
}
5357+
} else {
5358+
if (shift > EXT_MAX_BLOCKS -
5359+
(stop + ext4_ext_get_actual_len(extent))) {
5360+
ret = -EINVAL;
5361+
goto out;
53565362
}
53575363
}
53585364

fs/ext4/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5886,5 +5886,6 @@ static void __exit ext4_exit_fs(void)
58865886
MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
58875887
MODULE_DESCRIPTION("Fourth Extended Filesystem");
58885888
MODULE_LICENSE("GPL");
5889+
MODULE_SOFTDEP("pre: crc32c");
58895890
module_init(ext4_init_fs)
58905891
module_exit(ext4_exit_fs)

fs/jbd2/transaction.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ int jbd2_journal_start_reserved(handle_t *handle, unsigned int type,
532532
*/
533533
ret = start_this_handle(journal, handle, GFP_NOFS);
534534
if (ret < 0) {
535+
handle->h_journal = journal;
535536
jbd2_journal_free_reserved(handle);
536537
return ret;
537538
}

0 commit comments

Comments
 (0)