ext4: check for zero length extent explicitly
PATCH 1/1 ext4: check for zero length extent explicitly
The following commit introduced a bug when checking for zero length extent
5946d08 ext4: check for overlapping extents in ext4_valid_extent_entries()
Zero length extent could pass the check if lblock is zero.
Adding the explicit check for zero length back.
---
This is uncovered by recent updates for encryption, catting a file with zero length extent results in infinite loop ext4_mpage_readpages(), and process cannot be killed either.
Tested with corrupted ext4 image in e2fsprogs sources, cat returned EIO correctly
tests/f_ext_zero_len/image.gz
fs/ext4/extents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/extents.c +1 -1
@@ -377,7 +377,7 @@ static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext)ext4_lblk_t lblock =le32_to_cpu (ext->ee_block);ext4_lblk_t last = lblock + len -1 ; -if (lblock > last) +if (len ==0 || lblock > last)return 0 ;return ext4_data_block_valid (EXT4_SB (inode->i_sb), block, len); }
Signature · 1 line
1.8.3.1
Quoted 9 lines · Eryu Guan
The following commit introduced a bug when checking for zero length extent
5946d08 ext4: check for overlapping extents in
ext4_valid_extent_entries()Zero length extent could pass the check if lblock is zero.
Adding the explicit check for zero length back.
Signed-off-by Eryu Guan <[email protected]>
Thanks, applied.
- Ted