Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+21 -7
+3 -2
fs/ext4/fast_commit.c
··· 1521 1521 struct ext4_iloc iloc; 1522 1522 int inode_len, ino, ret, tag = tl->fc_tag; 1523 1523 struct ext4_extent_header *eh; 1524 + size_t off_gen = offsetof(struct ext4_inode, i_generation); 1524 1525 1525 1526 memcpy(&fc_inode, val, sizeof(fc_inode)); 1526 1527 ··· 1549 1548 raw_inode = ext4_raw_inode(&iloc); 1550 1549 1551 1550 memcpy(raw_inode, raw_fc_inode, offsetof(struct ext4_inode, i_block)); 1552 - memcpy(&raw_inode->i_generation, &raw_fc_inode->i_generation, 1553 - inode_len - offsetof(struct ext4_inode, i_generation)); 1551 + memcpy((u8 *)raw_inode + off_gen, (u8 *)raw_fc_inode + off_gen, 1552 + inode_len - off_gen); 1554 1553 if (le32_to_cpu(raw_inode->i_flags) & EXT4_EXTENTS_FL) { 1555 1554 eh = (struct ext4_extent_header *)(&raw_inode->i_block[0]); 1556 1555 if (eh->eh_magic != EXT4_EXT_MAGIC) {
+1 -2
fs/ext4/ioctl.c
··· 145 145 if (ext4_has_metadata_csum(sb) && 146 146 es->s_checksum != ext4_superblock_csum(sb, es)) { 147 147 ext4_msg(sb, KERN_ERR, "Invalid checksum for backup " 148 - "superblock %llu\n", sb_block); 148 + "superblock %llu", sb_block); 149 149 unlock_buffer(bh); 150 - err = -EFSBADCRC; 151 150 goto out_bh; 152 151 } 153 152 func(es, arg);
+2 -1
fs/ext4/migrate.c
··· 424 424 * already is extent-based, error out. 425 425 */ 426 426 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)) 428 429 return -EINVAL; 429 430 430 431 if (S_ISLNK(inode->i_mode) && inode->i_blocks == 0)
+9 -1
fs/ext4/namei.c
··· 2259 2259 memset(de, 0, len); /* wipe old data */ 2260 2260 de = (struct ext4_dir_entry_2 *) data2; 2261 2261 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 + } 2263 2270 de = de2; 2271 + } 2264 2272 de->rec_len = ext4_rec_len_to_disk(data2 + (blocksize - csum_size) - 2265 2273 (char *) de, blocksize); 2266 2274
+5
fs/ext4/resize.c
··· 1158 1158 while (group < sbi->s_groups_count) { 1159 1159 struct buffer_head *bh; 1160 1160 ext4_fsblk_t backup_block; 1161 + struct ext4_super_block *es; 1161 1162 1162 1163 /* Out of journal space, and can't get more - abort - so sad */ 1163 1164 err = ext4_resize_ensure_credits_batch(handle, 1); ··· 1187 1186 memcpy(bh->b_data, data, size); 1188 1187 if (rest) 1189 1188 memset(bh->b_data + size, 0, rest); 1189 + es = (struct ext4_super_block *) bh->b_data; 1190 + es->s_block_group_nr = cpu_to_le16(group); 1191 + if (ext4_has_metadata_csum(sb)) 1192 + es->s_checksum = ext4_superblock_csum(sb, es); 1190 1193 set_buffer_uptodate(bh); 1191 1194 unlock_buffer(bh); 1192 1195 err = ext4_handle_dirty_metadata(handle, NULL, bh);
+1 -1
fs/ext4/super.c
··· 4881 4881 flush_work(&sbi->s_error_work); 4882 4882 jbd2_journal_destroy(sbi->s_journal); 4883 4883 sbi->s_journal = NULL; 4884 - return err; 4884 + return -EINVAL; 4885 4885 } 4886 4886 4887 4887 static int ext4_journal_data_mode_check(struct super_block *sb)