]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
erofs: relax sanity check for tail pclusters due to ztailpacking
authorGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 8 Jul 2026 03:18:45 +0000 (11:18 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 8 Jul 2026 07:07:41 +0000 (15:07 +0800)
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.

Reported-and-tested-by: Yifan Zhao <zhaoyifan28@huawei.com>
Reported-by: Alberto Salvia Novella <es20490446e@gmail.com>
Closes: https://github.com/erofs/erofs-utils/issues/51
Fixes: a5242d37c83a ("erofs: error out obviously illegal extents in advance")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/zmap.c

index bab52161355247c122d673216f2a869fd69d3cd6..5811556a7b71fbfd54b0430d2ae69ca16adf60a4 100644 (file)
@@ -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;