From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (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 B88B336308A for ; Mon, 1 Jun 2026 08:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780304184; cv=none; b=CtRfA6ACk4uHbr4B2bGWaD9QoEydSg9LpMIuBMetae1xo1WipnT1empMGljsHFmzzMdx+EMgmkfw/du6bKw15Yd8n6D3BG85bnUD/m4h2ZE5RH3lmqWKaTkgln6FQ9pIKs82emkxlzanLA6Bty8ZgcXFCfI4N4YxmsiWILvrMtU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780304184; c=relaxed/simple; bh=Aq4lA8BI4MYCAinAojqZQiKZ68ZOCqgTTRa2XvjmHd4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IxM9PJBLT8d2lBGQzkrbRqUX6VSyfnMjOHZ/n4IDxZ/D6ALRWDDrto5liN9ZUJJffuC+fUXRxR6zX+K/qL6c3Ar4O+3m4wlN+lDgcgf5S0QlYT0ZpQr2mLc10V47g0Ai136tEWEEymZKJ673RDQxkNlva27fIzKHmml+iHxZk2s= 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=rIuA6C9E; arc=none smtp.client-ip=115.124.30.133 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="rIuA6C9E" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1780304172; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=S50cbF5GdF1Ec4BU613DRERbnvUgvosr3ljF6SUv9P0=; b=rIuA6C9E8ndedfwR7g8riEv3liwNhOhB1CxUmd6fxIwjw9WVIzC7orVuFRsNkkXP3x5lKGg0eOeRm/Zgn9ejRVoYO1LZvce3nADX+heTaRHYmwfCRXK7tkQVg0H2RLhC5+xCcUjR4qKwNQWWXmBceXePNiuodUHoaGIB/ErdGk0= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R461e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0X3zZ2B2_1780304171; Received: from 30.120.66.214(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0X3zZ2B2_1780304171 cluster:ay36) by smtp.aliyun-inc.com; Mon, 01 Jun 2026 16:56:12 +0800 Message-ID: Date: Mon, 1 Jun 2026 16:56:11 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] erofs: fix EFSCORRUPTED on multi-algorithm images in z_erofs_map_sanity_check() To: Zhan Xusheng , Gao Xiang Cc: linux-kernel@vger.kernel.org, Zhan Xusheng References: <20260601085136.3124646-1-zhanxusheng@xiaomi.com> From: Gao Xiang In-Reply-To: <20260601085136.3124646-1-zhanxusheng@xiaomi.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026/6/1 16:51, Zhan Xusheng wrote: > Commit a5242d37c83a ("erofs: error out obviously illegal extents in > advance") changed the per-extent algorithm presence check from "is the > bit set" to "is the only bit set": > - !(sbi->available_compr_algs & (1 << map->m_algorithmformat)) > + (sbi->available_compr_algs ^ BIT(map->m_algorithmformat)) > > `available_compr_algs` is a bitmap of every compression algorithm > available in the image (z_erofs_parse_cfgs() iterates it with > for_each_set_bit()), so an image that enables more than one algorithm > has multiple bits set. XOR is zero only when the bitmap is exactly > BIT(map->m_algorithmformat); for any image with two or more algorithms > the test is non-zero for every extent and the read fails with > -EFSCORRUPTED ("inconsistent algorithmtype %u"). > > Reproducer (mkfs.erofs from erofs-utils 1.7.1): > $ mkdir src > $ yes A | head -c 100K > src/a > $ head -c 64K /dev/zero > src/b > $ mkfs.erofs -zlz4:deflate multi.erofs src > $ mount -t erofs -o loop multi.erofs /mnt > $ cat /mnt/a >/dev/null > cat: /mnt/a: Structure needs cleaning > $ dmesg | tail > erofs (device loop0): inconsistent algorithmtype 0 for nid 46 > erofs (device loop0): read error -117 @ 0 of nid 46 > > The erofs on-disk format (Z_EROFS_COMPRESSION_MAX = 4 with LZ4, LZMA, > DEFLATE, ZSTD) and the kernel parser explicitly support > multi-algorithm images, and erofs-utils 1.7.1 generates them via the > "-z X:Y" syntax. > > Restore the original per-bit presence check. > > Fixes: a5242d37c83a ("erofs: error out obviously illegal extents in advance") > Signed-off-by: Zhan Xusheng Thanks, that is an awkward regression: Reviewed-by: Gao Xiang Thanks, Gao Xiang