From nobody Mon Jun 8 06:38:17 2026 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45B6A366541 for ; Mon, 1 Jun 2026 08:51:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780303909; cv=none; b=ewxBYXfBgd4N3bsZmYAKZdQhS1/MgkymVczyPNRpm5g/gdnP9DvZsmkmhVQlGdToF1N02Pz/MjmY7DiOo3XDdxnfeCMjpKItvE2Ph/DkDWdNEuanreOc0lKNTp2cgEKjzW0UqOa9FFB12onknskJh+NRPgfF244V1OYE3Ln1Rts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780303909; c=relaxed/simple; bh=+mE+EEqMmGOKwzBpmMI34L6Tofp0ySe5iFjkhJakABs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Tneod82uVOsJRAmwAQT78sycCDU1rEbZQUIiqn3Fk9pPRTe+SGwatr5/q1ERMdhr/e98+T23AWEWfwLMG5pOzsI7saLCmcEwlDw0pPy3K5DHaZN+gqYXd8tBDnxaGxdGUdH1jjMYJRMIC2D7KAK5Smd3lSRoR9J1PWNI38nMBMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UpJkEwWR; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UpJkEwWR" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2c0c2c7e0c5so7244455ad.1 for ; Mon, 01 Jun 2026 01:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780303903; x=1780908703; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=4w1SFdXb8tpZEWv3UVP73p3KmOFacimJSRcPtEosSBY=; b=UpJkEwWR5gbngg9at1NjSH9iSYIeYQQsvtkUJwZr/TVY+7PU1qiU2o2e1pdK2kt3R2 9S9Zvy+G8KnR/gcS0HnRJm8/RgVcKJyZEJSK1Py75sjga5iPul1jHeJ7eQmUqNXeF1O9 lH7yP8ua7AHJlYHR6YeQ8t22w0cmZTL3SYdxtZjEBEcGTrs03OKmvwxr2Mteqs6cYdUf wrt5O8KX/X13Fqs8Ly3Ko4xfy2raGmQOn3wMdXr5vTRtc8Nsh+BIppeaoLHu4gNCuENe v8k6SszyuaUeNJppN5ZyHI813WwYhOU1OJYCwQdj79MzhA9Mis14h3Q2VA60pINkjxhZ 51TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780303903; x=1780908703; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4w1SFdXb8tpZEWv3UVP73p3KmOFacimJSRcPtEosSBY=; b=j4jWOocLNFxZFD4nPJe3RI82WiEGfzzGoCVpI7QWlSVQztguPsbNkXLCzXq8gzjzkx jSl+bDX12/DqJOaEmf9iWOmh20LcxqEVT8GihHzUkP+g6jQi6/aw1wQIaltumyRrhYor by3Tqq2bx+hoDL0kzt6gx0M0WkWpKa/QhViyyruUcKFgE/lJD9R2I+dyPqUiNbjiE6RY icRm4pXnkT8d2VP14eKf+yZzaKfJML7ZvbC6bVS6HzHjrxatmOq1H3hzy/5l42/S88OD SR7TA2Fs4FUP+aXB8I7FfGlfdGDFFJcF+2+SkRCP1vcqIl8dbAYa9VgoA4kJ8eY1dwWj jvUQ== X-Gm-Message-State: AOJu0Yx4EgUw4FK33bit0jIMDBle4ri07YKNt2NlZYQFQqnSM5bnh0PZ Dhd6NWJ2NUnrl6Jn7u2aApG7D7AFi3lv59bKT10ptPRSsG2+84xbh6llsAdiJzrb X-Gm-Gg: Acq92OGxgrFgpUNx/3L8cQoOJWcbDwiGBAxObxBPH5+OPuX7PodY5sbrebubZs8b8a7 r9jUrqTfw/Jhe+k3KPDPA/m23A9ToSYMfPRnIsN7ZMvGH0kS559AXXMY/Tb0pIq4DS9uIQ88e+I 85Hgxya9+yg95+qmmNmPU5n5/3OhicscPjfRHSE3lF3oAkhWp8boxGcn1UyIaqYulOz1jkjHX2P g6Z5hSG/pm8VTqGkerMFHkApCIDfkOzkCFvCFujtkBnI8hLShz0VdbAYyc+FlKV1N7y+s19HTko U1DSWSkqRDecujwxmu80UdwhR3uhpWPLTB2Clx2mBJtdNS8IdouV2oG/jJNQJLPehnfWOVbFdZN tSFTrs2Vppr6qy0VAUpfz8ww4XFhNCG2wzxPKWW+9iNTBD4759G0IBAtoANzUtaIPR+0bKNslht XOU8AwwAH1VtgQ11Wc/Uddcu3LjttvcjlJrdYKQCb9gZKr X-Received: by 2002:a17:902:ef49:b0:2c0:db23:4c9 with SMTP id d9443c01a7336-2c0db23074dmr41922335ad.20.1780303903162; Mon, 01 Jun 2026 01:51:43 -0700 (PDT) Received: from osman.mioffice.cn ([43.224.245.178]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2bf23b01727sm102924595ad.53.2026.06.01.01.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2026 01:51:42 -0700 (PDT) From: Zhan Xusheng X-Google-Original-From: Zhan Xusheng To: Gao Xiang Cc: linux-kernel@vger.kernel.org, Zhan Xusheng Subject: [PATCH] erofs: fix EFSCORRUPTED on multi-algorithm images in z_erofs_map_sanity_check() Date: Mon, 1 Jun 2026 16:51:36 +0800 Message-ID: <20260601085136.3124646-1-zhanxusheng@xiaomi.com> X-Mailer: git-send-email 2.43.0 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" 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 =3D 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 Reviewed-by: Gao Xiang --- fs/erofs/zmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c index a72db36096ca..e1a02a2c8406 100644 --- a/fs/erofs/zmap.c +++ b/fs/erofs/zmap.c @@ -716,7 +716,7 @@ static int z_erofs_map_sanity_check(struct inode *inode, } =20 if (map->m_algorithmformat < Z_EROFS_COMPRESSION_MAX) { - if (sbi->available_compr_algs ^ BIT(map->m_algorithmformat)) { + if (!(sbi->available_compr_algs & BIT(map->m_algorithmformat))) { erofs_err(inode->i_sb, "inconsistent algorithmtype %u for nid %llu", map->m_algorithmformat, EROFS_I(inode)->nid); return -EFSCORRUPTED; --=20 2.43.0