* [PATCH] erofs: fix interlaced ztailpacking pclusters
@ 2026-08-14 6:59 Gao Xiang
2026-08-17 8:07 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Gao Xiang @ 2026-08-14 6:59 UTC (permalink / raw)
To: linux-erofs; +Cc: LKML, Gao Xiang, Haiyang Huang
On-disk sizes of interlaced pclusters should be block-aligned, and
ztailpacking interlaced pclusters should be invalid at all.
Currently, mkfs.erofs won't generate any interlaced pcluster with
ztailpacking enabled, so this doesn't affect any existing valid
filesystems.
However, crafted images can contain invalid interlaced ztailpacking
pclusters, resulting in an out-of-bounds read from a kmap'd page and
copying irrelevant kernel memory into userspace-visible page cache.
Reported-by: Haiyang Huang <huanghaiyang83@gmail.com>
Closes: https://lore.kernel.org/r/20260806065253.1083865-1-huanghaiyang83@gmail.com
Fixes: fdffc091e6f9 ("erofs: support interlaced uncompressed data for compressed files")
Signed-off-by: Gao Xiang <xiang@kernel.org>
---
fs/erofs/decompressor.c | 1 +
fs/erofs/zmap.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 3c54e95964c9..27caf4bebddc 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -299,6 +299,7 @@ static const char *z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
return ERR_PTR(-EOPNOTSUPP);
if (rq->alg == Z_EROFS_COMPRESSION_INTERLACED) {
cur = bs - (rq->pageofs_out & (bs - 1));
+ DBG_BUGON(rq->pageofs_in & (bs - 1));
pi = (rq->pageofs_in + rq->inputsize - cur) & ~PAGE_MASK;
cur = min(cur, rq->outputsize);
if (cur && rq->out[0]) {
diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
index 5811556a7b71..331a231dfe13 100644
--- a/fs/erofs/zmap.c
+++ b/fs/erofs/zmap.c
@@ -483,7 +483,8 @@ static int z_erofs_map_blocks_fo(struct inode *inode,
}
if (m.headtype == Z_EROFS_LCLUSTER_TYPE_PLAIN) {
- if (vi->z_advise & Z_EROFS_ADVISE_INTERLACED_PCLUSTER)
+ if (vi->z_advise & Z_EROFS_ADVISE_INTERLACED_PCLUSTER &&
+ !(map->m_flags & EROFS_MAP_META))
map->m_algorithmformat = Z_EROFS_COMPRESSION_INTERLACED;
else
map->m_algorithmformat = Z_EROFS_COMPRESSION_SHIFTED;
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] erofs: fix interlaced ztailpacking pclusters
2026-08-14 6:59 [PATCH] erofs: fix interlaced ztailpacking pclusters Gao Xiang
@ 2026-08-17 8:07 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2026-08-17 8:07 UTC (permalink / raw)
To: Gao Xiang, linux-erofs; +Cc: chao, LKML, Haiyang Huang
On 8/14/26 14:59, Gao Xiang wrote:
> On-disk sizes of interlaced pclusters should be block-aligned, and
> ztailpacking interlaced pclusters should be invalid at all.
>
> Currently, mkfs.erofs won't generate any interlaced pcluster with
> ztailpacking enabled, so this doesn't affect any existing valid
> filesystems.
>
> However, crafted images can contain invalid interlaced ztailpacking
> pclusters, resulting in an out-of-bounds read from a kmap'd page and
> copying irrelevant kernel memory into userspace-visible page cache.
Nitpick, if this can only happen in a fuzz case, we can add unlikely for
!(map->m_flags & EROFS_MAP_META)?
>
> Reported-by: Haiyang Huang <huanghaiyang83@gmail.com>
> Closes: https://lore.kernel.org/r/20260806065253.1083865-1-huanghaiyang83@gmail.com
> Fixes: fdffc091e6f9 ("erofs: support interlaced uncompressed data for compressed files")
> Signed-off-by: Gao Xiang <xiang@kernel.org>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-17 8:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-14 6:59 [PATCH] erofs: fix interlaced ztailpacking pclusters Gao Xiang
2026-08-17 8:07 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®