Skip to contentSkip to conversation

erofs: relax sanity check for tail pclusters on ztailpacking images

PATCH Superseded Gao Xiang 2 participants 3 messages Jul 7 – Jul 8 EROFS file system

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs: relax sanity check for tail pclusters on ztailpacking images

If the tail data can be inlined into the inode meta block, it should be converted into a regular tail pcluster.

In principle, it should be converted into an uncompressed pcluster if there is not enough gain to use compression (map->m_llen < map->m_plen); but since there are various shipped images, relax the condition for ztailpacking tail pclusters instead of reporting corruption incorrectly.

Fixes a5242d37c83a ("erofs: error out obviously illegal extents in advance")
---
 fs/erofs/zmap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/erofs/zmap.c +3 -1
index bab521613552..f6b0172a6acc 100644
@@ -732,7 +732,9 @@ static int z_erofs_map_sanity_check(struct inode *inode,
 				  map->m_algorithmformat, EROFS_I(inode)->nid);
 			return -EFSCORRUPTED;
 		}
-		if (EROFS_MAP_FULL(map->m_flags) && map->m_llen < map->m_plen) {
+		if (EROFS_MAP_FULL(map->m_flags) && map->m_llen < map->m_plen &&
+		    (map->m_la + map->m_llen < inode->i_size ||
+		     !erofs_sb_has_ztailpacking(sbi))) {
 			erofs_err(inode->i_sb, "too much compressed data @ la %llu of nid %llu",
 				  map->m_la, EROFS_I(inode)->nid);
 			return -EFSCORRUPTED;
Signature · 1 line
2.43.5
author
#1 lore raw

PATCH v2 1/1 erofs: relax sanity check for tail pclusters due to ztailpacking

If the tail data can be inlined into the inode meta block, it should be converted into a regular tail pcluster.

In principle, it should be converted into an uncompressed pcluster if there is not enough gain to use compression (map->m_llen < map->m_plen); but since there are various shipped images, relax the condition for ztailpacking tail pcluster fallback instead of reporting corruption incorrectly.

Fixes a5242d37c83a ("erofs: error out obviously illegal extents in advance")

---
v2:
- Drop ztailpacking sb feature check since it might not be set for single-file ztailpacking fallback images.

 fs/erofs/zmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/zmap.c +2 -1
index bab521613552..5811556a7b71 100644
@@ -732,7 +732,8 @@ static int z_erofs_map_sanity_check(struct inode *inode,
 				  map->m_algorithmformat, EROFS_I(inode)->nid);
 			return -EFSCORRUPTED;
 		}
-		if (EROFS_MAP_FULL(map->m_flags) && map->m_llen < map->m_plen) {
+		if (EROFS_MAP_FULL(map->m_flags) && map->m_llen < map->m_plen &&
+		    map->m_la + map->m_llen < inode->i_size) {
 			erofs_err(inode->i_sb, "too much compressed data @ la %llu of nid %llu",
 				  map->m_la, EROFS_I(inode)->nid);
 			return -EFSCORRUPTED;
Signature · 1 line
2.43.5
Tested-by on v2 1/1
#2 lore raw

Re: [PATCH v2] erofs: relax sanity check for tail pclusters due to ztailpacking

Quoted 36 lines · Gao Xiang

If the tail data can be inlined into the inode meta block, it should be converted into a regular tail pcluster.

In principle, it should be converted into an uncompressed pcluster if there is not enough gain to use compression (map->m_llen < map->m_plen); but since there are various shipped images, relax the condition for ztailpacking tail pcluster fallback instead of reporting corruption incorrectly.

Fixes a5242d37c83a ("erofs: error out obviously illegal extents in advance")

---
v2:
- Drop ztailpacking sb feature check since it might not be set for single-file ztailpacking fallback images.

  fs/erofs/zmap.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/zmap.c +2 -1
index bab521613552..5811556a7b71 100644
@@ -732,7 +732,8 @@ static int z_erofs_map_sanity_check(struct inode *inode,
  				  map->m_algorithmformat, EROFS_I(inode)->nid);
  			return -EFSCORRUPTED;
  		}
-		if (EROFS_MAP_FULL(map->m_flags) && map->m_llen < map->m_plen) {
+		if (EROFS_MAP_FULL(map->m_flags) && map->m_llen < map->m_plen &&
+		    map->m_la + map->m_llen < inode->i_size) {
  			erofs_err(inode->i_sb, "too much compressed data @ la %llu of nid %llu",
  				  map->m_la, EROFS_I(inode)->nid);
  			return -EFSCORRUPTED;