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>
Thu, 25 Aug 2022 09:11:14 +0000 (11:11 +0200)
commit0bcdc31094a12b4baf59e241feabc9787cf635fa
tree0943d635fd505e1a8da4b163aa437e61d7d1af2c
parent9d5fec6ba2e4117d196a8259ab54615ffe562460
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