ext2: Add more validity checks for inode counts
authorJan Kara <jack@suse.cz>
Tue, 26 Jul 2022 11:13:50 +0000 (13:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:23:00 +0000 (14:23 +0200)
commit96b18d3a1be0354ccce43f0ef61b5a3d7e432552
treea41c0761c8aee4ee109cf80f31f1e0c49cdd52ba
parentadd4bc9281e8704e5ab15616b429576c84f453a2
ext2: Add more validity checks for inode counts

[ Upstream commit fa78f336937240d1bc598db817d638086060e7e9 ]

Add checks verifying number of inodes stored in the superblock matches
the number computed from number of inodes per group. Also verify we have
at least one block worth of inodes per group. This prevents crashes on
corrupted filesystems.

Reported-by: syzbot+d273f7d7f58afd93be48@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ext2/super.c