From 5feba711f9d9a1463e0989ab8d71b93f368953de Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 26 Mar 2018 00:49:40 -0400 Subject: [PATCH] add patch dont-allow-rw-mounts-of-metadata-blocks-over-lap-sb --- ...-allow-rw-mounts-of-metadata-blocks-over-lap-sb | 44 ++++++++++++++++++++++ series | 1 + timestamps | 7 ++-- 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 dont-allow-rw-mounts-of-metadata-blocks-over-lap-sb diff --git a/dont-allow-rw-mounts-of-metadata-blocks-over-lap-sb b/dont-allow-rw-mounts-of-metadata-blocks-over-lap-sb new file mode 100644 index 00000000..d4232a0e --- /dev/null +++ b/dont-allow-rw-mounts-of-metadata-blocks-over-lap-sb @@ -0,0 +1,44 @@ +ext4: don't allow r/w mounts if metadata blocks overlap the superblock + +If some metadata block, such as an allocation bitmap, overlaps the +superblock, it's very likely that if the file system is mounted +read/write, the results will not be pretty. So disallow r/w mounts +for file systems corrupted in this particular way. + +Signed-off-by: Theodore Ts'o +Cc: stable@vger.kernel.org +--- + fs/ext4/super.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/fs/ext4/super.c b/fs/ext4/super.c +index 7cd022c344d1..edcfe6956eba 100644 +--- a/fs/ext4/super.c ++++ b/fs/ext4/super.c +@@ -2335,6 +2335,8 @@ static int ext4_check_descriptors(struct super_block *sb, + ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " + "Block bitmap for group %u overlaps " + "superblock", i); ++ if (!sb_rdonly(sb)) ++ return 0; + } + if (block_bitmap < first_block || block_bitmap > last_block) { + ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " +@@ -2347,6 +2349,8 @@ static int ext4_check_descriptors(struct super_block *sb, + ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " + "Inode bitmap for group %u overlaps " + "superblock", i); ++ if (!sb_rdonly(sb)) ++ return 0; + } + if (inode_bitmap < first_block || inode_bitmap > last_block) { + ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " +@@ -2359,6 +2363,8 @@ static int ext4_check_descriptors(struct super_block *sb, + ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " + "Inode table for group %u overlaps " + "superblock", i); ++ if (!sb_rdonly(sb)) ++ return 0; + } + if (inode_table < first_block || + inode_table + sbi->s_itb_per_group - 1 > last_block) { diff --git a/series b/series index e7a559e5..e88504e6 100644 --- a/series +++ b/series @@ -18,6 +18,7 @@ add-bitmap-block-validity-checks add-better-range-checking-for-xattr-value-sizes fail-unalloc-root-dir-in-ext4_iget always-load-checksum-driver +dont-allow-rw-mounts-of-metadata-blocks-over-lap-sb #################################################### # unstable patches diff --git a/timestamps b/timestamps index 45773037..7e1aabbe 100755 --- a/timestamps +++ b/timestamps @@ -49,7 +49,8 @@ touch -d @1521734340 dont-complain-about-incorrect-features-when-probing touch -d @1521870514 add-bitmap-block-validity-checks touch -d @1521961124 add-better-range-checking-for-xattr-value-sizes touch -d @1522028592 fail-unalloc-root-dir-in-ext4_iget -touch -d @1522038156 series touch -d @1522038278 always-load-checksum-driver -touch -d @1522038278 status -touch -d @1522038293 timestamps +touch -d @1522039196 series +touch -d @1522039710 dont-allow-rw-mounts-of-metadata-blocks-over-lap-sb +touch -d @1522039719 status +touch -d @1522039773 timestamps -- 2.11.4.GIT