Skip to content

Commit c505feb

Browse files
committed
erofs: validate the extent length for uncompressed pclusters
syzkaller reported a KASAN use-after-free: https://syzkaller.appspot.com/bug?extid=2ae90e873e97f1faf6f2 The referenced fuzzed image actually has two issues: - m_pa == 0 as a non-inlined pcluster; - The logical length is longer than its physical length. The first issue has already been addressed. This patch addresses the second issue by checking the extent length validity. Reported-by: [email protected] Fixes: 02827e1 ("staging: erofs: add erofs_map_blocks_iter") Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d5d188b commit c505feb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/erofs/zmap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,11 @@ static int z_erofs_do_map_blocks(struct inode *inode,
698698
}
699699

700700
if (m.headtype == Z_EROFS_VLE_CLUSTER_TYPE_PLAIN) {
701+
if (map->m_llen > map->m_plen) {
702+
DBG_BUGON(1);
703+
err = -EFSCORRUPTED;
704+
goto unmap_out;
705+
}
701706
if (vi->z_advise & Z_EROFS_ADVISE_INTERLACED_PCLUSTER)
702707
map->m_algorithmformat =
703708
Z_EROFS_COMPRESSION_INTERLACED;

0 commit comments

Comments
 (0)