From nobody Fri Apr 17 01:43:27 2026 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4C231EB5E1 for ; Tue, 24 Feb 2026 10:31:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771929095; cv=none; b=bImZRq7F9aLOxHpKovaZcfGJgf6nM7dA/FP90aT8w2YlQGT2GpAM0kRb/Zx5rqjuU6/ZL1maslKNS/wOP0pGnSuvzYJBIQIds2mXXozjswpbnWga7ntCvv7yiDY8rEEuUV25q0FvGvxHgGeTfHfCJ6s+VeqEM4BX96aewDPJ9cw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771929095; c=relaxed/simple; bh=Ivpy5PT++L7xlPEjKrL7B1KZ0bKyesmVFTf9rohqMFk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JyaYJwlwipwKyP1ghO4quDJdw6k6unqaktLn+x7coTJTbzVwDWANBQ8LWdraYWn8s22SW29cUZaHiVHj0u8NXq5gYbWcrMxZKOb9ydzxs7sV2iU3J9fccNzhFWzdEVFwig+EaPlzyu1T8TkAzwvSrgQHk1/uZmh2UymsY3Em21A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=lDYuybBM; arc=none smtp.client-ip=115.124.30.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="lDYuybBM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1771929090; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=5yDnhlZmVf0Zsv8d6JHtyUTkDwhpm8Vy4AX0FB6ZXRo=; b=lDYuybBM+KnjgORv/OicXgymyqDRO4IRsIVAB0DrBG4dRjncH14z0wg51Q33UVcavmj12sotp5SAaK4c+PPOfwRuqAdnqZPqPyRU8DiQnr6pJju/zY8dc4A9uRtD4msRCM1enLR6sPn+QP6W8LWNDK41dHbiSTKOrSzjg6vLF5c= Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0WzjF-0J_1771929085 cluster:ay36) by smtp.aliyun-inc.com; Tue, 24 Feb 2026 18:31:29 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , oliver.yang@linux.alibaba.com, Gao Xiang , syzbot+d988dc155e740d76a331@syzkaller.appspotmail.com Subject: [PATCH] erofs: fix interlaced plain identification for encoded extents Date: Tue, 24 Feb 2026 18:31:25 +0800 Message-ID: <20260224103125.2656548-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <699d5714.050a0220.cdd3c.03e7.GAE@google.com> References: <699d5714.050a0220.cdd3c.03e7.GAE@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Only plain data whose start position and on-disk physical length are both aligned to the block size should be classified as interlaced plain extents. Otherwise, it must be treated as shifted plain extents. This issue was found by syzbot using a crafted compressed image containing plain extents with unaligned physical lengths, which can cause OOB read in z_erofs_transform_plain(). Reported-by: syzbot+d988dc155e740d76a331@syzkaller.appspotmail.com Closes: https://lore.kernel.org/r/699d5714.050a0220.cdd3c.03e7.GAE@google.c= om Fixes: 1d191b4ca51d ("erofs: implement encoded extent metadata") Signed-off-by: Gao Xiang --- fs/erofs/zmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c index c8d8e129eb4b..30775502b56d 100644 --- a/fs/erofs/zmap.c +++ b/fs/erofs/zmap.c @@ -513,6 +513,7 @@ static int z_erofs_map_blocks_ext(struct inode *inode, unsigned int recsz =3D z_erofs_extent_recsize(vi->z_advise); erofs_off_t pos =3D round_up(Z_EROFS_MAP_HEADER_END(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize), recsz); + unsigned int bmask =3D sb->s_blocksize - 1; bool in_mbox =3D erofs_inode_in_metabox(inode); erofs_off_t lend =3D inode->i_size; erofs_off_t l, r, mid, pa, la, lstart; @@ -596,17 +597,17 @@ static int z_erofs_map_blocks_ext(struct inode *inode, map->m_flags |=3D EROFS_MAP_MAPPED | EROFS_MAP_FULL_MAPPED | EROFS_MAP_ENCODED; fmt =3D map->m_plen >> Z_EROFS_EXTENT_PLEN_FMT_BIT; + if (map->m_plen & Z_EROFS_EXTENT_PLEN_PARTIAL) + map->m_flags |=3D EROFS_MAP_PARTIAL_REF; + map->m_plen &=3D Z_EROFS_EXTENT_PLEN_MASK; if (fmt) map->m_algorithmformat =3D fmt - 1; - else if (interlaced && !erofs_blkoff(sb, map->m_pa)) + else if (interlaced && !((map->m_pa | map->m_plen) & bmask)) map->m_algorithmformat =3D Z_EROFS_COMPRESSION_INTERLACED; else map->m_algorithmformat =3D Z_EROFS_COMPRESSION_SHIFTED; - if (map->m_plen & Z_EROFS_EXTENT_PLEN_PARTIAL) - map->m_flags |=3D EROFS_MAP_PARTIAL_REF; - map->m_plen &=3D Z_EROFS_EXTENT_PLEN_MASK; } } map->m_llen =3D lend - map->m_la; --=20 2.43.5