]> git.baikalelectronics.ru Git - kernel.git/commit
ext4: check if directory block is within i_size
authorLukas Czerner <lczerner@redhat.com>
Mon, 4 Jul 2022 14:27:20 +0000 (16:27 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:27 +0000 (14:24 +0200)
commita8bd18be975700daa501e494f8ff80e6107435c9
treef1a22aec1dffcaecf5c0b376df2b28190a905a32
parentbe1caa794a994e18180cc3549dccea7e107bf5a1
ext4: check if directory block is within i_size

[ Upstream commit 6e16f834248735920ee51dfe650c59915e38c5ac ]

Currently ext4 directory handling code implicitly assumes that the
directory blocks are always within the i_size. In fact ext4_append()
will attempt to allocate next directory block based solely on i_size and
the i_size is then appropriately increased after a successful
allocation.

However, for this to work it requires i_size to be correct. If, for any
reason, the directory inode i_size is corrupted in a way that the
directory tree refers to a valid directory block past i_size, we could
end up corrupting parts of the directory tree structure by overwriting
already used directory blocks when modifying the directory.

Fix it by catching the corruption early in __ext4_read_dirblock().

Addresses Red-Hat-Bugzilla: #2070205
CVE: CVE-2022-1184
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Cc: stable@vger.kernel.org
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Link: https://lore.kernel.org/r/20220704142721.157985-1-lczerner@redhat.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ext4/namei.c