]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.17.12/ext4-fix-false-negatives-and-false-positives-in-ext4_check_descriptors.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.17.12 / ext4-fix-false-negatives-and-false-positives-in-ext4_check_descriptors.patch
1 From 44de022c4382541cebdd6de4465d1f4f465ff1dd Mon Sep 17 00:00:00 2001
2 From: Theodore Ts'o <tytso@mit.edu>
3 Date: Sun, 8 Jul 2018 19:35:02 -0400
4 Subject: ext4: fix false negatives *and* false positives in ext4_check_descriptors()
5
6 From: Theodore Ts'o <tytso@mit.edu>
7
8 commit 44de022c4382541cebdd6de4465d1f4f465ff1dd upstream.
9
10 Ext4_check_descriptors() was getting called before s_gdb_count was
11 initialized. So for file systems w/o the meta_bg feature, allocation
12 bitmaps could overlap the block group descriptors and ext4 wouldn't
13 notice.
14
15 For file systems with the meta_bg feature enabled, there was a
16 fencepost error which would cause the ext4_check_descriptors() to
17 incorrectly believe that the block allocation bitmap overlaps with the
18 block group descriptor blocks, and it would reject the mount.
19
20 Fix both of these problems.
21
22 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
23 Cc: stable@vger.kernel.org
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26 ---
27 fs/ext4/super.c | 5 ++---
28 1 file changed, 2 insertions(+), 3 deletions(-)
29
30 --- a/fs/ext4/super.c
31 +++ b/fs/ext4/super.c
32 @@ -2307,7 +2307,7 @@ static int ext4_check_descriptors(struct
33 struct ext4_sb_info *sbi = EXT4_SB(sb);
34 ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
35 ext4_fsblk_t last_block;
36 - ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0) + 1;
37 + ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0);
38 ext4_fsblk_t block_bitmap;
39 ext4_fsblk_t inode_bitmap;
40 ext4_fsblk_t inode_table;
41 @@ -4050,14 +4050,13 @@ static int ext4_fill_super(struct super_
42 goto failed_mount2;
43 }
44 }
45 + sbi->s_gdb_count = db_count;
46 if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
47 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
48 ret = -EFSCORRUPTED;
49 goto failed_mount2;
50 }
51
52 - sbi->s_gdb_count = db_count;
53 -
54 timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
55
56 /* Register extent status tree shrinker */