1 ext4: check for zero length extent explicitly
3 From: Eryu Guan <guaneryu@gmail.com>
5 The following commit introduced a bug when checking for zero length extent
7 5946d08 ext4: check for overlapping extents in ext4_valid_extent_entries()
9 Zero length extent could pass the check if lblock is zero.
11 Adding the explicit check for zero length back.
13 Signed-off-by: Eryu Guan <guaneryu@gmail.com>
14 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
15 Cc: stable@vger.kernel.org
18 This is uncovered by recent updates for encryption, catting a file with zero
19 length extent results in infinite loop ext4_mpage_readpages(), and process
20 cannot be killed either.
22 Tested with corrupted ext4 image in e2fsprogs sources, cat returned EIO
25 tests/f_ext_zero_len/image.gz
27 fs/ext4/extents.c | 2 +-
28 1 file changed, 1 insertion(+), 1 deletion(-)
30 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
31 index d74e0802..451b92a 100644
32 --- a/fs/ext4/extents.c
33 +++ b/fs/ext4/extents.c
34 @@ -377,7 +377,7 @@ static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext)
35 ext4_lblk_t lblock = le32_to_cpu(ext->ee_block);
36 ext4_lblk_t last = lblock + len - 1;
39 + if (len == 0 || lblock > last)
41 return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len);