* [PATCH] ext4: check for zero length extent explicitly
@ 2015-05-04 10:14 Eryu Guan
2015-05-14 23:02 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Eryu Guan @ 2015-05-04 10:14 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, 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 <guaneryu@gmail.com>
---
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(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index d74e0802..451b92a 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -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);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ext4: check for zero length extent explicitly
2015-05-04 10:14 [PATCH] ext4: check for zero length extent explicitly Eryu Guan
@ 2015-05-14 23:02 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2015-05-14 23:02 UTC (permalink / raw)
To: Eryu Guan; +Cc: linux-ext4
On Mon, May 04, 2015 at 06:14:28PM +0800, Eryu Guan wrote:
> 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 <guaneryu@gmail.com>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-14 23:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-04 10:14 [PATCH] ext4: check for zero length extent explicitly Eryu Guan
2015-05-14 23:02 ` Theodore Ts'o
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).