Skip to content

Commit 9761070

Browse files
committed
Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 fixes from Ted Ts'o: "Fix a number of bugs, including some regressions, the most serious of which was one which would cause online resizes to fail with file systems with metadata checksums enabled. Also fix a warning caused by the newly added fortify string checker, plus some bugs that were found using fuzzed file systems" * tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: ext4: fix fortify warning in fs/ext4/fast_commit.c:1551 ext4: fix wrong return err in ext4_load_and_init_journal() ext4: fix warning in 'ext4_da_release_space' ext4: fix BUG_ON() when directory entry has invalid rec_len ext4: update the backup superblock's at the end of the online resize
2 parents 90153f9 + 0d04335 commit 9761070

File tree

6 files changed

+21
-7
lines changed

6 files changed

+21
-7
lines changed

fs/ext4/fast_commit.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,7 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl,
15211521
struct ext4_iloc iloc;
15221522
int inode_len, ino, ret, tag = tl->fc_tag;
15231523
struct ext4_extent_header *eh;
1524+
size_t off_gen = offsetof(struct ext4_inode, i_generation);
15241525

15251526
memcpy(&fc_inode, val, sizeof(fc_inode));
15261527

@@ -1548,8 +1549,8 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl,
15481549
raw_inode = ext4_raw_inode(&iloc);
15491550

15501551
memcpy(raw_inode, raw_fc_inode, offsetof(struct ext4_inode, i_block));
1551-
memcpy(&raw_inode->i_generation, &raw_fc_inode->i_generation,
1552-
inode_len - offsetof(struct ext4_inode, i_generation));
1552+
memcpy((u8 *)raw_inode + off_gen, (u8 *)raw_fc_inode + off_gen,
1553+
inode_len - off_gen);
15531554
if (le32_to_cpu(raw_inode->i_flags) & EXT4_EXTENTS_FL) {
15541555
eh = (struct ext4_extent_header *)(&raw_inode->i_block[0]);
15551556
if (eh->eh_magic != EXT4_EXT_MAGIC) {

fs/ext4/ioctl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,8 @@ static int ext4_update_backup_sb(struct super_block *sb,
145145
if (ext4_has_metadata_csum(sb) &&
146146
es->s_checksum != ext4_superblock_csum(sb, es)) {
147147
ext4_msg(sb, KERN_ERR, "Invalid checksum for backup "
148-
"superblock %llu\n", sb_block);
148+
"superblock %llu", sb_block);
149149
unlock_buffer(bh);
150-
err = -EFSBADCRC;
151150
goto out_bh;
152151
}
153152
func(es, arg);

fs/ext4/migrate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ int ext4_ext_migrate(struct inode *inode)
424424
* already is extent-based, error out.
425425
*/
426426
if (!ext4_has_feature_extents(inode->i_sb) ||
427-
(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
427+
ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS) ||
428+
ext4_has_inline_data(inode))
428429
return -EINVAL;
429430

430431
if (S_ISLNK(inode->i_mode) && inode->i_blocks == 0)

fs/ext4/namei.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2259,8 +2259,16 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
22592259
memset(de, 0, len); /* wipe old data */
22602260
de = (struct ext4_dir_entry_2 *) data2;
22612261
top = data2 + len;
2262-
while ((char *)(de2 = ext4_next_entry(de, blocksize)) < top)
2262+
while ((char *)(de2 = ext4_next_entry(de, blocksize)) < top) {
2263+
if (ext4_check_dir_entry(dir, NULL, de, bh2, data2, len,
2264+
(data2 + (blocksize - csum_size) -
2265+
(char *) de))) {
2266+
brelse(bh2);
2267+
brelse(bh);
2268+
return -EFSCORRUPTED;
2269+
}
22632270
de = de2;
2271+
}
22642272
de->rec_len = ext4_rec_len_to_disk(data2 + (blocksize - csum_size) -
22652273
(char *) de, blocksize);
22662274

fs/ext4/resize.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,7 @@ static void update_backups(struct super_block *sb, sector_t blk_off, char *data,
11581158
while (group < sbi->s_groups_count) {
11591159
struct buffer_head *bh;
11601160
ext4_fsblk_t backup_block;
1161+
struct ext4_super_block *es;
11611162

11621163
/* Out of journal space, and can't get more - abort - so sad */
11631164
err = ext4_resize_ensure_credits_batch(handle, 1);
@@ -1186,6 +1187,10 @@ static void update_backups(struct super_block *sb, sector_t blk_off, char *data,
11861187
memcpy(bh->b_data, data, size);
11871188
if (rest)
11881189
memset(bh->b_data + size, 0, rest);
1190+
es = (struct ext4_super_block *) bh->b_data;
1191+
es->s_block_group_nr = cpu_to_le16(group);
1192+
if (ext4_has_metadata_csum(sb))
1193+
es->s_checksum = ext4_superblock_csum(sb, es);
11891194
set_buffer_uptodate(bh);
11901195
unlock_buffer(bh);
11911196
err = ext4_handle_dirty_metadata(handle, NULL, bh);

fs/ext4/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4881,7 +4881,7 @@ static int ext4_load_and_init_journal(struct super_block *sb,
48814881
flush_work(&sbi->s_error_work);
48824882
jbd2_journal_destroy(sbi->s_journal);
48834883
sbi->s_journal = NULL;
4884-
return err;
4884+
return -EINVAL;
48854885
}
48864886

48874887
static int ext4_journal_data_mode_check(struct super_block *sb)

0 commit comments

Comments
 (0)