From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: kernel@kyup.com, bp@alien8.de, Theodore Ts'o <tytso@mit.edu>,
stable@vger.kernel.org
Subject: [PATCH 3/3] ext4: use more strict checks for inodes_per_block on mount
Date: Thu, 17 Nov 2016 23:26:10 -0500 [thread overview]
Message-ID: <20161118042610.13464-3-tytso@mit.edu> (raw)
In-Reply-To: <20161118042610.13464-1-tytso@mit.edu>
Centralize the checks for inodes_per_block and be more strict to make
sure the inodes_per_block_group can't end up being zero.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
---
fs/ext4/super.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 3009c03220d6..6638a0415997 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3666,12 +3666,16 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
- if (EXT4_INODE_SIZE(sb) == 0 || EXT4_INODES_PER_GROUP(sb) == 0)
- goto cantfind_ext4;
sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb);
if (sbi->s_inodes_per_block == 0)
goto cantfind_ext4;
+ if (sbi->s_inodes_per_group < sbi->s_inodes_per_block ||
+ sbi->s_inodes_per_group > blocksize * 8) {
+ ext4_msg(sb, KERN_ERR, "invalid inodes per group: %lu\n",
+ sbi->s_blocks_per_group);
+ goto failed_mount;
+ }
sbi->s_itb_per_group = sbi->s_inodes_per_group /
sbi->s_inodes_per_block;
sbi->s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb);
@@ -3754,13 +3758,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
}
sbi->s_cluster_ratio = clustersize / blocksize;
- if (sbi->s_inodes_per_group > blocksize * 8) {
- ext4_msg(sb, KERN_ERR,
- "#inodes per group too big: %lu",
- sbi->s_inodes_per_group);
- goto failed_mount;
- }
-
/* Do we have standard group size of clustersize * 8 blocks ? */
if (sbi->s_blocks_per_group == clustersize << 3)
set_opt2(sb, STD_GROUP_SIZE);
--
2.11.0.rc0.7.gbe5a750
next prev parent reply other threads:[~2016-11-18 4:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 7:57 ext4 corruption causing a crash Nikolay Borisov
2016-11-16 8:12 ` Nikolay Borisov
2016-11-16 13:03 ` Nikolay Borisov
2016-11-16 18:17 ` Theodore Ts'o
2016-11-17 7:12 ` Nikolay Borisov
2016-11-18 4:26 ` [PATCH 1/3] ext4: sanity check the block and cluster size at mount time Theodore Ts'o
2016-11-18 4:26 ` [PATCH 2/3] ext4: fix in-superblock mount options processing Theodore Ts'o
2016-11-18 9:38 ` Andreas Dilger
2016-11-18 18:06 ` Theodore Ts'o
2016-11-18 4:26 ` Theodore Ts'o [this message]
2016-11-18 9:42 ` [PATCH 3/3] ext4: use more strict checks for inodes_per_block on mount Andreas Dilger
2016-11-18 7:40 ` [PATCH 1/3] ext4: sanity check the block and cluster size at mount time Nikolay Borisov
2016-11-18 17:58 ` Theodore Ts'o
2016-11-18 23:25 ` Nikolay Borisov
2016-11-19 2:36 ` Theodore Ts'o
2016-11-21 7:46 ` Nikolay Borisov
2016-11-21 15:24 ` Theodore Ts'o
2016-11-18 8:38 ` Andreas Dilger
2016-11-18 18:00 ` Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161118042610.13464-3-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=bp@alien8.de \
--cc=kernel@kyup.com \
--cc=linux-ext4@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).