[PATCH] erofs-utils: validate the extent length for uncompressed pclusters

Yue Hu zbestahu at gmail.com
Fri Mar 3 19:07:43 AEDT 2023


From: Yue Hu <huyue2 at coolpad.com>

Keep in sync with the kernel commit c505feba4c0d ("erofs: validate the
extent length for uncompressed pclusters"), so that we can catch the
issue as well in fuse.

Signed-off-by: Yue Hu <huyue2 at coolpad.com>
---
 lib/zmap.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/zmap.c b/lib/zmap.c
index 89e9da1..69b468d 100644
--- a/lib/zmap.c
+++ b/lib/zmap.c
@@ -647,6 +647,11 @@ static int z_erofs_do_map_blocks(struct erofs_inode *vi,
 	}
 
 	if (m.headtype == Z_EROFS_VLE_CLUSTER_TYPE_PLAIN) {
+		if (map->m_llen > map->m_plen) {
+			DBG_BUGON(1);
+			err = -EFSCORRUPTED;
+			goto out;
+		}
 		if (vi->z_advise & Z_EROFS_ADVISE_INTERLACED_PCLUSTER)
 			map->m_algorithmformat =
 				Z_EROFS_COMPRESSION_INTERLACED;
-- 
2.17.1



More information about the Linux-erofs mailing list