erofs-utils: lib: fix small compressed files inlining
authorYue Hu <huyue2@coolpad.com>
Tue, 11 Jul 2023 03:25:08 +0000 (11:25 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 11 Jul 2023 03:35:33 +0000 (11:35 +0800)
Keep in sync with kernel commit 24331050a3e6 ("erofs: fix small
compressed files inlining") to avoid corruption due to m_llen > m_plen
for uncompressed pclusters.

Fixes: 41790d24329d ("erofs-utils: validate the extent length for uncompressed pclusters")
Signed-off-by: Yue Hu <huyue2@coolpad.com>
Link: https://lore.kernel.org/r/20230711032508.6892-1-zbestahu@gmail.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
lib/zmap.c

index 7492e5d4cc8175d45675dd31bd7e7bd68a63613f..209b5d7829585a4ffb83560053cf55af8d10809e 100644 (file)
@@ -597,6 +597,13 @@ static int z_erofs_do_map_blocks(struct erofs_inode *vi,
                if (endoff >= m.clusterofs) {
                        m.headtype = m.type;
                        map->m_la = (m.lcn << lclusterbits) | m.clusterofs;
+                       /*
+                        * For ztailpacking files, in order to inline data more
+                        * effectively, special EOF lclusters are now supported
+                        * which can have three parts at most.
+                        */
+                       if (ztailpacking && end > vi->i_size)
+                               end = vi->i_size;
                        break;
                }
                /* m.lcn should be >= 1 if endoff < m.clusterofs */