Skip to content

Commit 18db4b4

Browse files
committed
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 <tytso@mit.edu> Cc: stable@vger.kernel.org
1 parent a45403b commit 18db4b4

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎fs/ext4/super.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,8 @@ static int ext4_check_descriptors(struct super_block *sb,
23352335
ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
23362336
"Block bitmap for group %u overlaps "
23372337
"superblock", i);
2338+
if (!sb_rdonly(sb))
2339+
return 0;
23382340
}
23392341
if (block_bitmap < first_block || block_bitmap > last_block) {
23402342
ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
@@ -2347,6 +2349,8 @@ static int ext4_check_descriptors(struct super_block *sb,
23472349
ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
23482350
"Inode bitmap for group %u overlaps "
23492351
"superblock", i);
2352+
if (!sb_rdonly(sb))
2353+
return 0;
23502354
}
23512355
if (inode_bitmap < first_block || inode_bitmap > last_block) {
23522356
ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
@@ -2359,6 +2363,8 @@ static int ext4_check_descriptors(struct super_block *sb,
23592363
ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
23602364
"Inode table for group %u overlaps "
23612365
"superblock", i);
2366+
if (!sb_rdonly(sb))
2367+
return 0;
23622368
}
23632369
if (inode_table < first_block ||
23642370
inode_table + sbi->s_itb_per_group - 1 > last_block) {

0 commit comments

Comments
 (0)