erofs: fix validation in z_erofs_do_map_blocks()
PATCH 1/1 erofs: fix validation in z_erofs_do_map_blocks()
In case of reading fragment data, map->m_plen is invalid.
Fixes c505feba4c0d ("erofs: validate the extent length for uncompressed pclusters")
Signed-off-by Noboru Asai <[email protected]>
--- fs/erofs/zmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/zmap.c +1 -1
@@ -572,7 +572,7 @@ static int z_erofs_do_map_blocks(struct inode *inode, }if (m.headtype ==Z_EROFS_VLE_CLUSTER_TYPE_PLAIN ) { -if (map->m_llen > map->m_plen) { + if (!(map->m_flags & EROFS_MAP_FRAGMENT) && (map->m_llen > map->m_plen) {DBG_BUGON (1 ); err = -EFSCORRUPTED ; goto unmap_out;
Signature · 1 line
2.39.2
Hi Noboru,
Quoted 4 lines · Noboru Asai
In case of reading fragment data,
map->m_plenis invalid.Fixes c505feba4c0d ("erofs: validate the extent length for uncompressed pclusters")Signed-off-by Noboru Asai <[email protected]>
Thanks for the report and patch!
I've already found this issue and I think it's actually a misuse to Z_EROFS_VLE_CLUSTER_TYPE_PLAIN for fragment pclusters in mkfs.erofs.
So I fixed in erofs-utils:
https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/commit/?id=ef74e215647e0d602d5e24039acbcfb18e55e516
Since erofs-utils v1.6 is not released yet, so it won't impact anything at all.
Thanks,
Gao Xiang
Quoted 17 lines
--- fs/erofs/zmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/erofs/zmap.c +1
-1@@ -572,7 +572,7 @@ static int z_erofs_do_map_blocks(struct inode *inode, }if (m.headtype ==Z_EROFS_VLE_CLUSTER_TYPE_PLAIN ) { -if (map->m_llen > map->m_plen) { + if (!(map->m_flags & EROFS_MAP_FRAGMENT) && (map->m_llen > map->m_plen) {DBG_BUGON (1 ); err = -EFSCORRUPTED ; goto unmap_out;