From: Theodore Ts'o Date: Fri, 30 Mar 2018 02:10:35 +0000 (-0400) Subject: ext4: don't allow r/w mounts if metadata blocks overlap the superblock X-Git-Tag: v4.1.52~98 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=176df3e2add7cd7029a3493ea825e5582cb84ef0;p=users%2Fdwmw2%2Flinux.git ext4: don't allow r/w mounts if metadata blocks overlap the superblock [ Upstream commit 18db4b4e6fc31eda838dd1c1296d67dbcb3dc957 ] 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 Signed-off-by: Sasha Levin --- diff --git a/fs/ext4/super.c b/fs/ext4/super.c index c67056a8c9011..1f50622224251 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2126,6 +2126,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->s_flags & MS_RDONLY)) + return 0; } if (block_bitmap < first_block || block_bitmap > last_block) { ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " @@ -2138,6 +2140,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->s_flags & MS_RDONLY)) + return 0; } if (inode_bitmap < first_block || inode_bitmap > last_block) { ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " @@ -2150,6 +2154,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->s_flags & MS_RDONLY)) + return 0; } if (inode_table < first_block || inode_table + sbi->s_itb_per_group - 1 > last_block) {