linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: catch integer overflow in ext4_cache_extents
@ 2020-07-13 12:58 Jan Kara
  2020-07-13 13:44 ` Ritesh Harjani
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kara @ 2020-07-13 12:58 UTC (permalink / raw)
  To: Ted Tso; +Cc: linux-ext4, Wolfgang Frisch, Jan Kara

From: Wolfgang Frisch <wolfgang.frisch@suse.com>

When extent tree is corrupted we can hit BUG_ON in
ext4_es_cache_extent(). Check for this and abort caching instead of
crashing the machine.

Signed-off-by: Wolfgang Frisch <wolfgang.frisch@suse.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/extents.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 221f240eae60..e76d00fda104 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -471,6 +471,10 @@ static void ext4_cache_extents(struct inode *inode,
 		ext4_lblk_t lblk = le32_to_cpu(ex->ee_block);
 		int len = ext4_ext_get_actual_len(ex);
 
+		/* Corrupted extent tree? Stop caching... */
+		if (lblk + len < lblk || lblk + len > EXT4_MAX_LOGICAL_BLOCK)
+			return;
+
 		if (prev && (prev != lblk))
 			ext4_es_cache_extent(inode, prev, lblk - prev, ~0,
 					     EXTENT_STATUS_HOLE);
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-15 17:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-13 12:58 [PATCH] ext4: catch integer overflow in ext4_cache_extents Jan Kara
2020-07-13 13:44 ` Ritesh Harjani
2020-07-14 12:31   ` Jan Kara
2020-07-15 11:53     ` Jan Kara
2020-07-15 17:25     ` Wolfgang Frisch

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).