diff mbox series

[2/2] ext4: don't allow r/w mounts if metadata blocks overlap the superblock

Message ID 20180326044906.13286-2-tytso@mit.edu
State Accepted, archived
Headers show
Series None | expand

Commit Message

Theodore Ts'o March 26, 2018, 4:49 a.m. UTC
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
---
 fs/ext4/super.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Sasha Levin March 30, 2018, 4:16 p.m. UTC | #1
Hi EXT4 ML!

I'm working on a project to perform automatic patch selection for
stable, and automate the testing being done for patches going in
various stable tree.

I got some input from the XFS folks so far, and wanted to get some
input from the EXT4 folks as well.

Below is a mail that would be sent as a response for ext4 patches
tagged for stable and sent to the mailing list. Since this one is
already tagged for stable, these results should be useful for people
to understand if the patch properly applies to various stable trees
and passes testing.

For EXT4, at this point testing is the xfstests tree at
https://github.com/tytso/xfstests , running with "./check -g auto".
Complete build and test logs are available in the links embedded in
the mail.

I'd be happy to get feedback for this. Thanks!

===

Hi Theodore Ts'o,

[This is an automated email]

This commit has been processed because it contains a -stable tag.
The stable tag indicates that it's relevant for the following trees: all

The bot has also determined it's probably a bug fixing patch. (score: 90.6059)

The bot has tested the following trees: v4.15.12, v4.14.29, v4.9.89, v4.4.123, v4.1.50, v3.18.101.

v4.15.12: Build OK!
v4.14.29: Build OK!
v4.9.89: Build failed! Errors:
    fs/ext4/super.c:2263:9: error: implicit declaration of function ‘sb_rdonly’ [-Werror=implicit-function-declaration]

v4.4.123: Build failed! Errors:
    fs/ext4/super.c:2134:9: error: implicit declaration of function ‘sb_rdonly’ [-Werror=implicit-function-declaration]

v4.1.50: Build failed! Errors:
    fs/ext4/super.c:2129:9: error: implicit declaration of function ‘sb_rdonly’ [-Werror=implicit-function-declaration]

v3.18.101: Build failed! Errors:
    fs/ext4/super.c:2096:9: error: implicit declaration of function ‘sb_rdonly’ [-Werror=implicit-function-declaration]


EXT4 Specific tests:

v4.15.12 (http://stable-bot.westus2.cloudapp.azure.com/ext4-patch/v4.15.12/tests/):
    Tests complete.
v4.14.29 (http://stable-bot.westus2.cloudapp.azure.com/ext4-patch/v4.14.29/tests/):
    Tests complete.
v4.9.89 (http://stable-bot.westus2.cloudapp.azure.com/ext4-patch/v4.9.89/tests/):
    No tests completed!
v4.4.123 (http://stable-bot.westus2.cloudapp.azure.com/ext4-patch/v4.4.123/tests/):
    No tests completed!
v4.1.50 (http://stable-bot.westus2.cloudapp.azure.com/ext4-patch/v4.1.50/tests/):
    No tests completed!
v3.18.101 (http://stable-bot.westus2.cloudapp.azure.com/ext4-patch/v3.18.101/tests/):
    No tests completed!

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks,
Sasha
diff mbox series

Patch

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) {