From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379903; b=qvWRCx3FYxj/RpfksQvNV5WzbH6rXH8mL2KNye4CDfmCifhmUpZPQOxa7rv5SscZIeNi W12Z6HcA4PeodFM3jxsfxnb1vTIU/PT4NNocBFgCLon27C8sw1X1j7p2qqWOMn4QPzEey Hwr0TKNZAOavswyBB8IfA8Az5iwyZdSDppT1mxUSrgZ8BqFkugO92n0j7x7bSJmCcx/D3 9GRWwFzSA6D1rDZmn3pMqp/nfScNLlC3oNMGvGyojv7ybAQgJs644Z3cj361UMvDjkp2Z MsPU5KPM+Mf87RbSoPx0vWp/Ez69D8aDuuJDlOKXLf6G1BncQC50MMndVstBKTsTJBg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379903; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=kD+EBDy31lfWS4wBlAPfr5+06fI1qVusiruPSWVEvkw=; b=oAIaxwT1TDn9Cldf4FBPCf5RsegxwFr+t0qYbkFIGMyBJicPLucc9c+FBD2du1lctGsM ZkLym3ATG9G2JZZfXB6VqFmafa0oc6TUwPkQzUOgmsu6oEYEGMGOkU2Zr16zamQQbWdbw 21RhhzBfaQu7R+9XV/6s+uU3sq0jPrfKJVrNui2/oqqu+SwfyUeWddTPqBO4f/+SIZcEc evT3Tug2QKhM9ImryATmIkIlu6VWU372Z4cdTzwLST1AQYJRvNHli5BiwMB1bvbWjRF8R uf8ZB5LdPBfZp7FBMIU4qHzgrcl8k/SGcpdLKMwBpjIr14Mx1WQZEi2ZooVN2E1VxOQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=2InfHuCW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EE9C606A32F; Fri, 4 Dec 2026 10:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=2InfHuCW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DF301F000CE; Fri, 4 Dec 2026 10:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379903; bh=kD+EBDy31lfWS4wBlAPfr5+06fI1qVusiruPSWVEvkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2InfHuCWqiF21OEGFiO09BcLQt1REcPEPJzhYOZmtwAOTnQ28HtT6lD72DDaFydJd OeIilbu7Or7z+Ceni4Lr7MzI0A6QmTq+PZ7KdF3rFB13xsvMn+1zmSQWA1dycpekNw NhjPqaDZdU0m0Pmb65vS0AIdL28gGQsu17CBdC+4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Roger=20Alas=C3=A0?= , Eric Biggers , Tito Duarte , Qu Wenruo , David Sterba , Sasha Levin Subject: [PATCH 7.3 044/742] btrfs: fix the fsverity callback where unexpected range is verified Date: Fri, 4 Dec 2026 18:58:28 +0900 Message-ID: <20261204100636.238257764@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qu Wenruo [ Upstream commit 254e15591ee4590064e0c55285cdcb4f4519133c ] [BUG] There is a bug report that on v7.2 kernel, compressed extents with fsverity enabled can lead to warnings like the following: fs-verity (dm-3, inode 257): FILE CORRUPTED! pos=7471104, level=-1, want_hash=sha256:bedf0e7bc93b48694db719001a8d3e79229cc58ee638b41d4149193505090774, real_hash=sha256:ad7facb2586fc6e966c004d7d1d16b024f5805ff7cb47c7a85dabd8b48892ca7 The read itself eventually succeeds, and no read error is returned to user space. [CAUSE] Since v7.2 btrfs has enabled large data folio support, now a folio can contain multiple blocks even if the page size matches the fs block size. And even before that, btrfs already has block size < page size support, thus all involved code should assume a folio can contain multiple blocks. However the function btrfs_verify_folio() calls fsverity_verify_folio(), which verifies the whole folio, even if the read range only covers part of the folio. This forces fsverity to verify garbage data that is not yet read from disk, and causes verification failure. This is a long-standing bug, but previously it only affected bs < ps cases which is not that common. Now with the large folio support, it's much easier to trigger with bs == ps cases. [FIX] Instead of calling fsverity_verify_folio(), call fsverity_verify_blocks() to verify only the read range. Reported-by: Roger Alasà Link: https://lore.kernel.org/linux-btrfs/CAELqY9==Ter2XQPRp=gjW5T75T+7kcZCXpn5roF2L6tY6mQNxw@mail.gmail.com/ Fixes: 146054090b08 ("btrfs: initial fsverity support") Tested-by: Roger Alasà Reviewed-by: Eric Biggers Tested-by: Tito Duarte Signed-off-by: Qu Wenruo Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/extent_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index d7600e5fa3d95..fe4c87dc61ba8 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -504,7 +504,7 @@ static bool btrfs_verify_folio(struct fsverity_info *vi, struct folio *folio, if (!vi || btrfs_folio_test_uptodate(fs_info, folio, start, len)) return true; - return fsverity_verify_folio(vi, folio); + return fsverity_verify_blocks(vi, folio, len, offset_in_folio(folio, start)); } static void end_folio_read(struct fsverity_info *vi, struct folio *folio, -- 2.53.0