]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ext4: don't allow r/w mounts if metadata blocks overlap the superblock
authorTheodore Ts'o <tytso@mit.edu>
Fri, 30 Mar 2018 02:10:35 +0000 (22:10 -0400)
committerSasha Levin <alexander.levin@microsoft.com>
Wed, 23 May 2018 01:36:34 +0000 (21:36 -0400)
[ 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 <tytso@mit.edu>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
fs/ext4/super.c

index c67056a8c90117f6d0fdddab1c12f4938f8950a1..1f506222242518acb948564a57f880b97176521d 100644 (file)
@@ -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) {