From patchwork Fri Oct 2 12:36:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZEweSho/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=f/bm=hy=vger.kernel.org=linux-ext4+bounces-19942-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNw80tzTz1xyX for ; Sat, 03 Oct 2026 08:38:00 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNvW3SRdz4w1S for ; Sat, 03 Oct 2026 08:37:27 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNvW3QhMz4w9g; Sat, 03 Oct 2026 08:37:27 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c0a:e001:db::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980647; cv=pass; b=mUcMJxCo8dpFAxH7a66Krsfrf/39UOB5mq8ehIC9etlK5laFFsA417MOg16qk9OdsDUbtGU+Vi/QD/XY70K9CG2kHJFFTtqVPifQkpIfUvCU3JsUKbA7VXYnmuJ6Gyhh00OSGleOoWXsLtCKjppL55Sp9GKFjNY3r7UKijuDvLvxVMc+3HyY+omLivE42slTyxXi8Lf6VtkHa1n+uh+ylWkaNe10F9N77Ib6kMZtjUQWT70Y652nDi5k7wjsFNfGw51DbxHvpiWGmJrHaPh7whry6LwPuxExTE+NEXOWYJ74nX4WyqiUk3e416TlTr0ftR/3bx/xCzgu37aroqtS8w== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980647; c=relaxed/relaxed; bh=DLKRiRyzKQ3SHGS6qPdEtB2Y8TKgDvD/nkziuhY4NXk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cXrw9C2pjxZk4oRX4l6dfTpUcEI9VAsrq03YQCkRNfQxXKk+J+8mySj8aahjGGqtRzbE8RtLlKdLIU+bgdiXG7PeENJCWAadAASdsj9ZUhKy0EA1UPtP6ORSDEJba/pU6r4a+p65AHHw0ee+3iXa6vT62AmCSjMI0ECNaSFGfvtfuiJ035J7/UhUnGyxEzLqAElRp7o2Cz23KIPBZDJyIeXN4gMjarPfpSNfHgYdtBwlUyNwGCDpAHjNQ8gG7aNwX2xxhHXIqo/l5JR4DMJiwAcnlXGijSQGsY8urvbWzR7Etsvx4b6GYN1Il/OkRyNlIpo1G4cTD+jXwgrXCPzPxA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZEweSho/; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19942-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZEweSho/; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19942-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [IPv6:2600:3c0a:e001:db::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNvR6nrMz4w1S for ; Sat, 03 Oct 2026 08:37:23 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id C454F3E48B for ; Fri, 2 Oct 2026 22:37:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00EB2455605; Fri, 2 Oct 2026 22:37:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZEweSho/" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 A35283C4555; Fri, 2 Oct 2026 22:37:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980637; cv=none; b=GH73VVQOPRoKHsiPH+3LXnggZOIcsq6Svd2GRE+WQUUbbRiJIP6oQdOQTWF2Scd08ox1YpY3n5xoIKTB3ICtbcCOUn7lDDuoF68ab9aTzyZE3vQPI+S45Gl9HTWznH4e80PBoulRmurq4FrOwX02gx72F67DNY4wlEZOmMG+9j8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980637; c=relaxed/simple; bh=gNzjl4zWpkZJaicQjAemkaolWXKfIV765MdaOnGpKBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UXPLdHZl5HS9kUSzsctWzRoNG3WwVMfuOzFsJS75NYPZK0udEx3Nj9cGDm/9QY4ABgUx8jNdPJp7ez00jqdiR1B2mCTGNKd1wROHj5hJtZUsfRrBs241LW5WiNDSiDuIlOIhVCy8YEgHxKn/ugkTbZ3u7vffX2e89eNkKowMnj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZEweSho/; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 481D41F00898; Fri, 2 Oct 2026 22:37:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980636; bh=DLKRiRyzKQ3SHGS6qPdEtB2Y8TKgDvD/nkziuhY4NXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZEweSho/Cwzs8/LsKlvQTc806l+Oz7mlND6yQYJfioYraHnXayhEJgpZNG/TvL5Jx rnK1B9nLtK47IFPwqo20gBoXEhnyzaisrJxQQR7QObLFPHT4rLn3EC+OXQb5aHlux6 mQADUBJU1Zl31qTt0XipmQlRk8Y2uerVbwMdp+3+bYDkxlUK+dOVVSdaACWBqjXw7n mEnUl/XSJhF5xW0LUgQNu3h8/j8K4o0OeRgEDJ07v+1PLu3we1BdHqSCE4HUsL7r1f DCtunj5aVzhn/Fe60RABJvgfGYuCIiVnIZCJMvC2abqh6LXBdWmfkDYfR5SrawG/Pb tUEVRYEwcmCbA== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 01/21] fsverity: report validation errors through fserror to fsnotify Date: Sat, 3 Oct 2026 00:36:42 +0200 Message-ID: <20261002223705.2175542-2-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org Reported verification errors to fsnotify through recently added fserror interface. Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Acked-by: Eric Biggers Signed-off-by: Andrey Albershteyn --- fs/verity/verify.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/verity/verify.c b/fs/verity/verify.c index 4004a1d42875..db8c350234bb 100644 --- a/fs/verity/verify.c +++ b/fs/verity/verify.c @@ -9,6 +9,7 @@ #include #include +#include #define FS_VERITY_MAX_PENDING_BLOCKS 2 @@ -205,6 +206,8 @@ static bool verify_data_block(struct fsverity_info *vi, if (memchr_inv(dblock->data, 0, params->block_size)) { fsverity_err(inode, "FILE CORRUPTED! Data past EOF is not zeroed"); + fserror_report_data_lost(inode, data_pos, + params->block_size, GFP_NOFS); return false; } return true; @@ -312,6 +315,7 @@ static bool verify_data_block(struct fsverity_info *vi, data_pos, level - 1, params->hash_alg->name, hsize, want_hash, params->hash_alg->name, hsize, level == 0 ? dblock->real_hash : real_hash); + fserror_report_data_lost(inode, data_pos, params->block_size, GFP_NOFS); error: for (; level > 0; level--) { kunmap_local(hblocks[level - 1].addr); From patchwork Fri Oct 2 12:36:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315390 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KQeQfOxw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=lene=hy=vger.kernel.org=linux-ext4+bounces-19943-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNvh5TVxz1xyX for ; Sat, 03 Oct 2026 08:37:36 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNv40gBmz4w1S for ; Sat, 03 Oct 2026 08:37:04 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNv40cJQz4w9g; Sat, 03 Oct 2026 08:37:04 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.105.105.114 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980624; cv=pass; b=ATiMOcGZiSPG8dCN2WLKdOd3qSyucfiHH/D4JNAnkZEIbD2hO0ogjaCoIqjL6zXrxOKuMnMelxwlxeT/Eh3kXR02m5VRcocafCgrrJHAd4e9Iq0hU5BpE4aLID9ZiyYkND7BLgIEkiD+8d3ZLA7IWBk9MLulW0dY53VWJWwR9Sc0mq/CX667OQWDNEKqTa12px8yUMGetOPEDtAaoMQFxrN+5DuRhVq1V6yiVjncN3gL4VjjCjmKPwd7lHqOrnfXsA8UyHNEFr0BTKwM5JjKnRYs30UVy2i//PTXfTRJtyVrq15uqPaKTF3ardZdnMv5vB2nZU6Jeam2xeMtFLf+Dw== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980624; c=relaxed/relaxed; bh=Go/Ag71QhxLYREjmSa7sE9PXLYovh2VY8xtfSqyB6bM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FSK+aph+m2jzzJXvRcn2y7gyIYxQq7Eg5MEsfaaxqi6uoLoj5JWnJcC9mkJ6nuIeCdE21IZFz4Uwlm0rLgOmzR3WWIuXMY6jMNcl5OB0wdek54UfrrdikS6mhAesq+4KBLSM1k43T2+6viMj0hivnq+pZdkTm5Psughdezs1Z/nf7sS7W8zWhU4QKe/1Vx/KA2+IFi01nu+ATXPtELPmrbnfMQvSU/0QJ2/suQFCcbzDyj/tptwPE8qv6xP9/3oYFfEzQ/tzUX4q2PlMFZRuUQmQVGnq/VWXpGtOuThB2rQfcXpRL1H8KavZVbjP0O0ZiMUEP4RF8QOUJ4EKctkksg== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KQeQfOxw; dkim-atps=neutral; spf=pass (client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19943-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KQeQfOxw; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19943-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNv03nHnz4w1S for ; Sat, 03 Oct 2026 08:37:00 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 3581130A4D for ; Fri, 2 Oct 2026 22:37:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76F7D46EC7F; Fri, 2 Oct 2026 22:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KQeQfOxw" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 14AC144BC82; Fri, 2 Oct 2026 22:37:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980641; cv=none; b=OamrnWirLUUv9q+gWx0SClfItpssP3rEGSOoqvJSpfxtdkWj34vVwqCl/e3JB4BC8AsZwQsO+3Zg4+d0mIpGUDKEpGz0y0QEz6QJ2ImhO7ffqbfNyRDZ0WX1WTvC2W2JJiGyxLw8v//nqISd2xfyA2sLKjJtTLZElBGNr1NFG6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980641; c=relaxed/simple; bh=t9D5Xw8hj+Uk1PVc2axoFXJ85aUK4MBkI/u0Mp4xXAk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ToQgbk5ZmC8+gtlWQOlCJjZDWhxVEwZjCDKcWjn4LuSboS1sQrRVugaDgoi/CTVn69jndr2dhYuLw/c6R/jXFZftuHCahvMfS+OSaBBz7iZymas3b/TMavndaBTsKkIAviXspj9Z/tf3TREGOYxJdL9/8ETIjp7gojhKS0UtN5U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KQeQfOxw; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C192D1F000FF; Fri, 2 Oct 2026 22:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980639; bh=Go/Ag71QhxLYREjmSa7sE9PXLYovh2VY8xtfSqyB6bM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KQeQfOxwJZheNDgj3MBzcCDhdO9+2GCFbyJVpaN4QfqE5cIiARsjvhwnNSMcEilMG HM1dp+7aO7rmMVfTLe83YKGMVnYEuTW5IphABRqd3RjTFzorh+A9Mi5tZgcVBjeKAX HN629SNhasBxwvp2t1cdY9wEMfKiCB/W/9obUgs2euROFHUT5lDVUgacu6uTTyniTF q9moLupx4Li5kOLk4OPcUMbZKsI2x0EZ/Wg30ckN+qNq9glqSAouHegVkAJt3Hxnr1 C0BxZRzn2SPYHBv9PmlqMwQa6EuRE3HgwCu7tFeSGF1U5w7LTkM/LaVLF18zfQSEPh 6rx0MZF3hPa6A== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 02/21] fsverity: expose ensure_fsverity_info() Date: Sat, 3 Oct 2026 00:36:43 +0200 Message-ID: <20261002223705.2175542-3-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org This function will be used by XFS's scrub to force fsverity activation, therefore, to read fsverity context. Reviewed-by: Darrick J. Wong Acked-by: Eric Biggers Signed-off-by: Andrey Albershteyn Reviewed-by: Christoph Hellwig --- fs/verity/open.c | 26 ++++++++++++++++++++++++-- include/linux/fsverity.h | 2 ++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/fs/verity/open.c b/fs/verity/open.c index d0c56a7faa3b..4f06697f5bf4 100644 --- a/fs/verity/open.c +++ b/fs/verity/open.c @@ -347,7 +347,28 @@ int fsverity_get_descriptor(struct inode *inode, return 0; } -static int ensure_verity_info(struct inode *inode) +/** + * fsverity_ensure_verity_info() - cache verity info if it's not already cached + * @inode: the inode for which verity info should be cached + * + * Ensure this inode has verity info attached to it, it's assumed the inode + * already has fsverity enabled. Read fsverity descriptor and creates verity + * based on that. + * + * This needs to be called at least once before any of the inode's data + * can be verified (and thus read at all) or the inode's fsverity digest + * retrieved. fsverity_file_open() calls this already, which handles + * normal file accesses. If a filesystem does any internal (i.e. not + * associated with a file descriptor) reads of the file's data or + * fsverity digest, it must call this explicitly before doing so. + * + * In case filesystem supports both fscrypt and fsverity, this should be called + * after fscrypt's encryption key is set up. Otherwise, the fsverity metadata is + * still encrypted. See fscrypt_file_open(). + * + * Return: 0 on success, -errno on failure + */ +int fsverity_ensure_verity_info(struct inode *inode) { struct fsverity_info *vi = fsverity_get_info(inode), *found; struct fsverity_descriptor *desc; @@ -383,12 +404,13 @@ static int ensure_verity_info(struct inode *inode) kfree(desc); return err; } +EXPORT_SYMBOL_GPL(fsverity_ensure_verity_info); int __fsverity_file_open(struct inode *inode, struct file *filp) { if (filp->f_mode & FMODE_WRITE) return -EPERM; - return ensure_verity_info(inode); + return fsverity_ensure_verity_info(inode); } EXPORT_SYMBOL_GPL(__fsverity_file_open); diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h index 6c467ded9751..3c3250f6f272 100644 --- a/include/linux/fsverity.h +++ b/include/linux/fsverity.h @@ -317,6 +317,8 @@ static inline int fsverity_file_open(struct inode *inode, struct file *filp) return 0; } +int fsverity_ensure_verity_info(struct inode *inode); + void fsverity_cleanup_inode(struct inode *inode); struct page *generic_read_merkle_tree_page(struct inode *inode, pgoff_t index); From patchwork Fri Oct 2 12:36:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315396 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YFnGtyyB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=n7mi=hy=vger.kernel.org=linux-ext4+bounces-19944-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1 raw public key) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNxH06Zkz1xyX for ; Sat, 03 Oct 2026 08:38:59 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNwf0HPnz4wCt for ; Sat, 03 Oct 2026 08:38:26 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNwf00dLz4w9g; Sat, 03 Oct 2026 08:38:26 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.234.253.10 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980705; cv=pass; b=ULLQCCRoemJSU8XFdI4sY8jJagaF6k0rUru8Dg6ackxWmgOUnyJTrUCh9qOusjx1On93CC7hfgHbnfG1HNnSX0B+5+caW9r11xSGrB7uAej7ceNGZtAKbFn2788XOVrwcl2q/1H7APpcWAO4oINEqZasV4uFJKl7fbbVhJpa7Ck8pKQP2THfRfRHcpGVUMn64JmzF8D7jEsyMXHb5c8mE6fyUvBsZzI49F8ciIUAlznYYuxH5Z/y8rx9FDXMrXFhER9HRiROo8M4Gsp0AoXhMx2mmsWEOAUvKwZhBYimxVFOgas3N3ugl92vqW0cGP69YXwlEBenfrZkcdN/8/z18Q== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980705; c=relaxed/relaxed; bh=ocelP5BLZjaYNqJA/jF/UJ2BfrTGPj5YgQPaa6hhf5Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YTKQLAsCYxniyN2IWqlzhpn/6JkVtwRdjdRpXd1+ma2VWLsPYboq19Da02rltmkSiGnxAG+EQI1KGy/m/8nlS8YsgtjR9DO1o8/VFx8LVKk0EYQazTAOHJjiMb3iIQ9kQp4gzLlgAtFUIGCN7igCDfbdGxmBqvsbFg1xyeqc6cu2pGmDVWj4/9bJWYeFA5QqMOsNs4Dmb7V0Asf9iea+AhJjcn8iUg0vOLE9AdyJwST0hbygjGSGTeXxg2VTsSS/T3MIC3sdl8ntSaWwYBk3mmCgGNShD4tbk8HP5s5gSCvqvMcvLRHRxBvMecjjKX3Q2516WtLoILz4sc4qh1ggcA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YFnGtyyB; dkim-atps=neutral; spf=pass (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19944-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YFnGtyyB; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19944-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNwX4sqvz4wCt for ; Sat, 03 Oct 2026 08:38:20 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id A8EBD3FF23 for ; Fri, 2 Oct 2026 22:37:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 228BF46C83D; Fri, 2 Oct 2026 22:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YFnGtyyB" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 BE426411A03; Fri, 2 Oct 2026 22:37:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980644; cv=none; b=gTmRZuXTiKgKYyAT4hQomsnIA6ezhL2OUeSSC60WJCHGmPLISSJIupANxt26DC22QBhBPV+ie+QZ0Tzi7NEyPt2+M/WP28KzYIrs3aga6uEjRZ3qt/p14+Lb2HrJNzrOd4cEDa+kTTohdwRamh5/HZ9TOZ8dqRyZ4FiIXug+FEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980644; c=relaxed/simple; bh=Oq9HJZo+l2AjIYKwZwzq3YVfYi2UUYhoRUrCyDGsj/c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WHiwukeZ3/0vPB7Vds1dw/tkAAwL04vMt4FkDjVT1yJ5OzR7g89mMFjNbH0OBXtiH952GvTpECdWkFCp4clJGP1pMq+LV4kptYBsTDHjmzFkokioqWS9x3tSrTb8TbtNkM+C8PGbzwppFk6d5CgVtGoByCMSGzVfY01tWwWW0es= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YFnGtyyB; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45DEB1F00893; Fri, 2 Oct 2026 22:37:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980643; bh=ocelP5BLZjaYNqJA/jF/UJ2BfrTGPj5YgQPaa6hhf5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YFnGtyyBWAW1TY3GeRLaJct5HVZo077BH2V2ZmgX5bYqhco/iuPNOeTaw0l0vK4bV sSjycpWb0TzKsZq16yVkAwywt4bxuLFe+dxwiBgJkK2X9xTb9BcedRqEpu5c0lT1/Z 2ANNyLpz8AJKNqefMXcY5yZEYyAJ1jsQ6oYD8dIcYujPu0oc2rrsbImcZbNFgiDt8l j9gAC6y21jVlR2Nx4IqI9QTj8+XWlxQVIlI7MD1COCaYMW4A8i2lwKT8KR3PbQLjZN XKdMhemIjvXcRrSwXjWKvES642HLR1D9nmC2wYFdmiun8Vm0liKoayPM76b4jII+sM 98SQE7BNppoQw== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com, David Sterba Subject: [PATCH v17 03/21] fsverity: pass digest size and hash of the all-zeroes block to ->write Date: Sat, 3 Oct 2026 00:36:44 +0200 Message-ID: <20261002223705.2175542-4-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org Let filesystem iterate over hashes in the block and check if these are hashes of zeroed data blocks. XFS will use this to decide if it want to store tree block full of these hashes. Signed-off-by: Andrey Albershteyn Reviewed-by: "Darrick J. Wong" Acked-by: Eric Biggers Acked-by: David Sterba --- fs/btrfs/verity.c | 6 +++++- fs/ext4/verity.c | 4 +++- fs/f2fs/verity.c | 4 +++- fs/verity/enable.c | 4 +++- include/linux/fsverity.h | 6 +++++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c index 4e0ab5842274..c572acacb4d4 100644 --- a/fs/btrfs/verity.c +++ b/fs/btrfs/verity.c @@ -779,11 +779,15 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, * @buf: Merkle tree block to write * @pos: the position of the block in the Merkle tree (in bytes) * @size: the Merkle tree block size (in bytes) + * @zero_digest: the hash of the all-zeroes block + * @digest_size: size of zero_digest, in bytes * * Returns 0 on success or negative error code on failure */ static int btrfs_write_merkle_tree_block(struct file *file, const void *buf, - u64 pos, unsigned int size) + u64 pos, unsigned int size, + const u8 *zero_digest, + unsigned int digest_size) { struct inode *inode = file_inode(file); loff_t merkle_pos = merkle_file_pos(inode); diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c index ca61da53f313..347945ac23a4 100644 --- a/fs/ext4/verity.c +++ b/fs/ext4/verity.c @@ -374,7 +374,9 @@ static void ext4_readahead_merkle_tree(struct inode *inode, pgoff_t index, } static int ext4_write_merkle_tree_block(struct file *file, const void *buf, - u64 pos, unsigned int size) + u64 pos, unsigned int size, + const u8 *zero_digest, + unsigned int digest_size) { pos += ext4_verity_metadata_pos(file_inode(file)); diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c index 39f482515445..cc4158fc841d 100644 --- a/fs/f2fs/verity.c +++ b/fs/f2fs/verity.c @@ -272,7 +272,9 @@ static void f2fs_readahead_merkle_tree(struct inode *inode, pgoff_t index, } static int f2fs_write_merkle_tree_block(struct file *file, const void *buf, - u64 pos, unsigned int size) + u64 pos, unsigned int size, + const u8 *zero_digest, + unsigned int digest_size) { pos += f2fs_verity_metadata_pos(file_inode(file)); diff --git a/fs/verity/enable.c b/fs/verity/enable.c index 42dfed1ce0ce..ad4ff71d7dd9 100644 --- a/fs/verity/enable.c +++ b/fs/verity/enable.c @@ -50,7 +50,9 @@ static int write_merkle_tree_block(struct file *file, const u8 *buf, int err; err = inode->i_sb->s_vop->write_merkle_tree_block(file, buf, pos, - params->block_size); + params->block_size, + params->zero_digest, + params->digest_size); if (err) fsverity_err(inode, "Error %d writing Merkle tree block %lu", err, index); diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h index 3c3250f6f272..9e7d946676b9 100644 --- a/include/linux/fsverity.h +++ b/include/linux/fsverity.h @@ -124,6 +124,8 @@ struct fsverity_operations { * @buf: the Merkle tree block to write * @pos: the position of the block in the Merkle tree (in bytes) * @size: the Merkle tree block size (in bytes) + * @zero_digest: the hash of the all-zeroes block + * @digest_size: size of zero_digest, in bytes * * This is only called between ->begin_enable_verity() and * ->end_enable_verity(). @@ -131,7 +133,9 @@ struct fsverity_operations { * Return: 0 on success, -errno on failure */ int (*write_merkle_tree_block)(struct file *file, const void *buf, - u64 pos, unsigned int size); + u64 pos, unsigned int size, + const u8 *zero_digest, + unsigned int digest_size); }; #ifdef CONFIG_FS_VERITY From patchwork Fri Oct 2 12:36:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315391 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GH7OOA4l; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=cguo=hy=vger.kernel.org=linux-ext4+bounces-19945-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1 raw public key) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNvv1DMSz1xyX for ; Sat, 03 Oct 2026 08:37:47 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNvG3GJwz4w1S for ; Sat, 03 Oct 2026 08:37:14 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNvG3C70z4w9g; Sat, 03 Oct 2026 08:37:14 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c04:e001:36c::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980634; cv=pass; b=iDSn92qo1NTT4O6XSPFrZL68fMt5IzSuEvy2gpLkKJRv/2Ty6zBTeYeRzCuMQsnGvJR2p1YCF4s5BxfqIVL3NJSWK92RUsgv2l7bMLi0Tnvbdl3OIi83JUD4z9iBQ7i8whtm1iprIhT1qf7XjC1hWbAxw3ilQYRYk/HnRDTU/sfiUEDmGSt78HDUFKtjlCumpDa/hH1hTr2zMnsMfD6/UlSQuLT1/8eOgH8ji0by/OpgZ3S1W5ibUMo0yz5umaco50CfYIpqEElTl0bzHf+CAj17XnpcI5tDDpQgUg80UwA8PoUYLza4xgbuT8X3oMr7T3qvR25n0mzgiZUN2dp7cg== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980634; c=relaxed/relaxed; bh=5kBhEFj3Ic0jQ4W+kZl9S7neY9+Pxt8ASNrS40LLOrM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=agqtfr3ch5hhjp1dGYQooL3sQ61AxdFuB65C5U8SNQvS+4oKKY1Pi0tRCVbgKFZbGTk6rMiahGmTO3YUQdqv30UHhvf6iCh1ze+k+eoBAI6jeiKCuIAd8yi2YQYE6RzcKOlTPkmk8wgaAVrXbdxLAUiKGJ/k6IH40kSc5ss5F3T/Y1pvDBM21QhWnd9iDa5ZtOl+ZCCucLOdfnf+mEDVLb4XDguRzuIU0U3HS5/TcDr6cAqyk4vzevGSxkREJeAGhupDdu2N4c2ybDOQZ0zw+Xvh6fptDydffOj0IRLq+GI2X0onjckLUKyxh8/u/qoxdbBeS0WA6Jfnhmmha7kyBw== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GH7OOA4l; dkim-atps=neutral; spf=pass (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19945-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GH7OOA4l; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19945-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from tor.lore.kernel.org (tor.lore.kernel.org [IPv6:2600:3c04:e001:36c::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNvC01Txz4w1S for ; Sat, 03 Oct 2026 08:37:10 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 1EBC130DC1 for ; Fri, 2 Oct 2026 22:37:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DA3046C4C6; Fri, 2 Oct 2026 22:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GH7OOA4l" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 079CB3C4555; Fri, 2 Oct 2026 22:37:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980648; cv=none; b=YIVUGofuO8IMiHXDde7lRCFp/v3SEmvlXC5lYArGSUQQQHiu5FTJwophUPF/xs+dV5vmQOMta9dELaRyjnd4uYdFI0AlTTYeumWYeuhtiK0KKVNcKy85hWeTv4astPqSoh5KbepjdCC034CMXh2J/P9qpzZSFFA0goXUnIAsSJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980648; c=relaxed/simple; bh=uU9LZECtunZjMmI4kNqkrZ+7oaDRoulPh+9RwM44jcw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mUJ3m/rcKGrEDZceXRaCRr/7eVceN8vLuP0hOEUJwqzJNIZR9xKQ+LydNOaDSdmK//+SKWntHAs7j0+vcLUo+EEfcyrFNu5B8X3XKrX7yr/hTECVdrBA+39HnqOj3xi7rec4Hl/f4qS5GRz/gf3ONAoxJa9g5D8Xje+HXnEVYIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GH7OOA4l; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA0D31F000FF; Fri, 2 Oct 2026 22:37:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980646; bh=5kBhEFj3Ic0jQ4W+kZl9S7neY9+Pxt8ASNrS40LLOrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GH7OOA4lwxuEf7PQvRJPhU69q6QShi6QGgMGq9KWzpLJCNRgygcUuyngYCLduFYvU RHFEIhUXvGmjbUdOxXEJW2+ICwPv6xNXR4UZkRNb6XkkdGOlVIOokJAEGEH9tAiK/e 7YyvDCVeWIQzgnsmS6DASj8iGEuY+SUKaZDvaSCcZ/cBXtEbyLUwCSEUphs6Gu/7ny zmOcCNJjiz1T8PcwXmDXUKJARzBpkEy3wAXboW57GQgGgA62Z2GYZ4JsqxO9+JaNHh moqndrzIRg/lu2gRcUeH9NWpvYinmOxlltESE1uqlonaP2Gw0MazuvSSoH/ZpgFg80 67lbrBAsoLkww== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 04/21] fsverity: hoist pagecache_read from f2fs/ext4 to fsverity Date: Sat, 3 Oct 2026 00:36:45 +0200 Message-ID: <20261002223705.2175542-5-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org This is the same function to read from pageache. XFS will also need this, so move this to core fsverity. Note that f2fs and ext4 functions diverged a bit, as ext4 operated over folios and f2fs operated over pages. The common one will operate over folios. Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Acked-by: Eric Biggers Signed-off-by: Andrey Albershteyn --- fs/ext4/verity.c | 32 +++----------------------------- fs/f2fs/verity.c | 30 +----------------------------- fs/verity/pagecache.c | 33 +++++++++++++++++++++++++++++++++ include/linux/fsverity.h | 2 ++ 4 files changed, 39 insertions(+), 58 deletions(-) diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c index 347945ac23a4..ac5c133f5529 100644 --- a/fs/ext4/verity.c +++ b/fs/ext4/verity.c @@ -34,32 +34,6 @@ static inline loff_t ext4_verity_metadata_pos(const struct inode *inode) return round_up(inode->i_size, 65536); } -/* - * Read some verity metadata from the inode. __vfs_read() can't be used because - * we need to read beyond i_size. - */ -static int pagecache_read(struct inode *inode, void *buf, size_t count, - loff_t pos) -{ - while (count) { - struct folio *folio; - size_t n; - - folio = read_mapping_folio(inode->i_mapping, pos >> PAGE_SHIFT, - NULL); - if (IS_ERR(folio)) - return PTR_ERR(folio); - - n = memcpy_from_file_folio(buf, folio, pos, count); - folio_put(folio); - - buf += n; - pos += n; - count -= n; - } - return 0; -} - /* * Write some verity metadata to the inode for FS_IOC_ENABLE_VERITY. * kernel_write() can't be used because the file descriptor is readonly. @@ -311,8 +285,8 @@ static int ext4_get_verity_descriptor_location(struct inode *inode, goto bad; desc_size_pos -= sizeof(desc_size_disk); - err = pagecache_read(inode, &desc_size_disk, sizeof(desc_size_disk), - desc_size_pos); + err = fsverity_pagecache_read(inode, &desc_size_disk, + sizeof(desc_size_disk), desc_size_pos); if (err) return err; desc_size = le32_to_cpu(desc_size_disk); @@ -352,7 +326,7 @@ static int ext4_get_verity_descriptor(struct inode *inode, void *buf, if (buf_size) { if (desc_size > buf_size) return -ERANGE; - err = pagecache_read(inode, buf, desc_size, desc_pos); + err = fsverity_pagecache_read(inode, buf, desc_size, desc_pos); if (err) return err; } diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c index cc4158fc841d..f3a4617656db 100644 --- a/fs/f2fs/verity.c +++ b/fs/f2fs/verity.c @@ -37,34 +37,6 @@ static inline loff_t f2fs_verity_metadata_pos(const struct inode *inode) return round_up(inode->i_size, 65536); } -/* - * Read some verity metadata from the inode. __vfs_read() can't be used because - * we need to read beyond i_size. - */ -static int pagecache_read(struct inode *inode, void *buf, size_t count, - loff_t pos) -{ - while (count) { - size_t n = min_t(size_t, count, - PAGE_SIZE - offset_in_page(pos)); - struct page *page; - - page = read_mapping_page(inode->i_mapping, pos >> PAGE_SHIFT, - NULL); - if (IS_ERR(page)) - return PTR_ERR(page); - - memcpy_from_page(buf, page, offset_in_page(pos), n); - - put_page(page); - - buf += n; - pos += n; - count -= n; - } - return 0; -} - /* * Write some verity metadata to the inode for FS_IOC_ENABLE_VERITY. * kernel_write() can't be used because the file descriptor is readonly. @@ -250,7 +222,7 @@ static int f2fs_get_verity_descriptor(struct inode *inode, void *buf, if (buf_size) { if (size > buf_size) return -ERANGE; - res = pagecache_read(inode, buf, size, pos); + res = fsverity_pagecache_read(inode, buf, size, pos); if (res) return res; } diff --git a/fs/verity/pagecache.c b/fs/verity/pagecache.c index 99f5f53eea98..9d82e6b74ba1 100644 --- a/fs/verity/pagecache.c +++ b/fs/verity/pagecache.c @@ -78,3 +78,36 @@ void fsverity_fill_zerohash(struct folio *folio, size_t offset, size_t len, vi->tree_params.digest_size); } EXPORT_SYMBOL_GPL(fsverity_fill_zerohash); + +/** + * fsverity_pagecache_read() - read page and copy data to buffer + * @inode: copy from this inode's address space + * @buf: buffer to copy to + * @count: number of bytes to copy + * @pos: position of the folio to copy from + * + * Read some verity metadata from the inode. __vfs_read() can't be used because + * we need to read beyond i_size. + */ +int fsverity_pagecache_read(struct inode *inode, void *buf, size_t count, + loff_t pos) +{ + while (count) { + struct folio *folio; + size_t n; + + folio = read_mapping_folio(inode->i_mapping, pos >> PAGE_SHIFT, + NULL); + if (IS_ERR(folio)) + return PTR_ERR(folio); + + n = memcpy_from_file_folio(buf, folio, pos, count); + folio_put(folio); + + buf += n; + pos += n; + count -= n; + } + return 0; +} +EXPORT_SYMBOL_GPL(fsverity_pagecache_read); diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h index 9e7d946676b9..f9433332c274 100644 --- a/include/linux/fsverity.h +++ b/include/linux/fsverity.h @@ -328,5 +328,7 @@ void fsverity_cleanup_inode(struct inode *inode); struct page *generic_read_merkle_tree_page(struct inode *inode, pgoff_t index); void generic_readahead_merkle_tree(struct inode *inode, pgoff_t index, unsigned long nr_pages); +int fsverity_pagecache_read(struct inode *inode, void *buf, size_t count, + loff_t pos); #endif /* _LINUX_FSVERITY_H */ From patchwork Fri Oct 2 12:36:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315401 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OEaM6Ilz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=xa4k=hy=vger.kernel.org=linux-ext4+bounces-19946-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNyw4Ftpz1xvt for ; Sat, 03 Oct 2026 08:40:24 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNyH6vd9z4w0Q for ; Sat, 03 Oct 2026 08:39:51 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNyH6sjvz4w9T; Sat, 03 Oct 2026 08:39:51 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.234.253.10 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980791; cv=pass; b=V4fwMyfC3semo5y6cRfW5l9er5HSgg+caHw9+CKK0jCgHDj+lctqidM984MSS8zceyNjMPh+/W1tpM5kdQtq5KCx1fU7xlvhHeeI1KTkuXrtbR9WQbFCeS8DlVi6OwY90KRfGW73v1hvD3FLLVGug85McCmFhF9/YoUMMroDf2aOQPEl2i0sdyPyxrBwC0FsHxlBgkIi/OHliI9RQyKaWAJt0fWll1LPnSzSui3P/EGCTTNGDXh++ztSkNpfiHnPV3X1rlUcPP2ioVhsTxgkhfN+ROQdMXBGUlqSIoRrzHcTsnoTkN4NZUs8YtRX5hxKbAiLZAUjQBmlxmO9PwSiCA== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980791; c=relaxed/relaxed; bh=nbiOvvmh3uAAd1oxFar1z2uB37LIOE/Lgee7w9bmdyU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u0LR+JHouY/2laJpYTeoZvUqnoO/0LWfb8xNcTFF5AHedihBMNliDg604KTtPivBGvGYU8gEUewTsMotcCbJ/TrBgXLDSTopyEEcAvzt+qjiy+bdshlLI2eBxciM5kYLVyJFbLF4Y8H0lA9/eYoOmaa3gi6qU7EdC1VQXmK7sREJezOzWT9C5vB7eA62anBmj62hMQBgV5zLhLdNdPkqFk51HdJGjin2I/DPqQI/P8IDHIlzNZ5vUOlU+HY2OMxWf92ytOj66HdFpifvbiYUFGs9/jq95bTnTlrNqRqHwGhteU0uALgzdm0OLiTHW+TSmVvwrTJMYzztJlKqxnTzvA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OEaM6Ilz; dkim-atps=neutral; spf=pass (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19946-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OEaM6Ilz; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19946-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNyD4FFTz4w0Q for ; Sat, 03 Oct 2026 08:39:48 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 95E84430E7 for ; Fri, 2 Oct 2026 22:37:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20C0F46EC7F; Fri, 2 Oct 2026 22:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OEaM6Ilz" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 D813C411A03; Fri, 2 Oct 2026 22:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980653; cv=none; b=fKTxcLboOolJ5SSG1oum7WOOMJymvN9tebZ5E/tanoOz7NyrMQ95/s4Ai6nYu5la9rrIvXLF1WnaNPP0zbHgjo6huCVlXVJMlO3G+f/SkSvunP5wgOdk2QcRjVhGGPOql/L5FBxaDPXml3flfNQgXf1ONCEKTwoVQ4BCM/YdCzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980653; c=relaxed/simple; bh=NciHHsUwbDFuZeKCsrcMzZSUKpPt3AZax3aBo18/9+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IPNj5u5h5LECqb+0DeVc7kHuUKBxoZf2XeTjIUKWDGTXQS969qEixwMIBgBSsfap0ZZoSB5UHmtKai+Vu9O+/UDKAaSEqidw8XQsrp2c0ggleLtXAADQjcfVloRZ3xWVy0xHvIiWy49Auk+PjQs8ELQq0UX6d5ivrfWr8dmB09M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OEaM6Ilz; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BD9B1F00893; Fri, 2 Oct 2026 22:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980650; bh=nbiOvvmh3uAAd1oxFar1z2uB37LIOE/Lgee7w9bmdyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OEaM6Ilz8wEalxqxW4RlHAB/L8XqhWxXwEAxiLKewJye9vhz5bG+NATN/YFaN5IpG yWsJAsptz9sUEUCYWCpUvgSJyEXHuXjnQ9ah/20SZrURo1SaJuFs3v2hu8wsutEO/S 4qFI9rmeepYpgaNmgiWkOycA6MV0gYVLvDqaXxEJUiaqeG84urAmcDKNvZADtd0Mir KmX/NDZb7fb9kZWSUSB+ur62k9cJoU7WpqrWoznu+G2ckxLdbJVeOE1eQTXdy47iWi /14VMESV2btPQkm434A6y+yiecauQvW6oOEVKs3ZwWmCKYgw0ILP4IcHHthrtH16Bs no80OKQWBoXEQ== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 05/21] fsverity: don't allow setting DAX file attribute on fsverity files Date: Sat, 3 Oct 2026 00:36:46 +0200 Message-ID: <20261002223705.2175542-6-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org When fsverity is enabled on the file, with FS_IOC_ENABLE_VERITY ioctl(), it checks if file has DAX enabled and fails if that's true. However, the opposite case is not checked. Note, that the only other filesystem supporting DAX and fsverity is ext4, and ext4 does check for this case. Signed-off-by: Andrey Albershteyn Reviewed-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" Reviewed-by: Eric Biggers --- fs/file_attr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/file_attr.c b/fs/file_attr.c index bfb00d256dd5..391edd1d0ce3 100644 --- a/fs/file_attr.c +++ b/fs/file_attr.c @@ -235,10 +235,15 @@ static int fileattr_set_prepare(struct inode *inode, /* * It is only valid to set the DAX flag on regular files and * directories on filesystems. + * + * DAX and fsverity are incompatible. */ - if ((fa->fsx_xflags & FS_XFLAG_DAX) && - !(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) - return -EINVAL; + if (fa->fsx_xflags & FS_XFLAG_DAX) { + if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) + return -EINVAL; + if (old_ma->fsx_xflags & FS_XFLAG_VERITY) + return -EINVAL; + } /* Extent size hints of zero turn off the flags. */ if (fa->fsx_extsize == 0) From patchwork Fri Oct 2 12:36:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315404 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AMgBaGw/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=ucu0=hy=vger.kernel.org=linux-ext4+bounces-19947-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNzP44vBz1xvt for ; Sat, 03 Oct 2026 08:40:49 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNym6hT0z4w9T for ; Sat, 03 Oct 2026 08:40:16 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNym6dj9z4w0Q; Sat, 03 Oct 2026 08:40:16 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c0a:e001:db::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980816; cv=pass; b=CkG97sBT0y+5ko4s3KWiBZBxzTszFvNSSxaUFyAwTWPnfTuvnYh+m1AXL5mh03KAVCrvO16xk9xpFjpTrtLkha8sa7RzJZTzgaZtACCkSRJPz8IifZuqS47wkoEocsjguLeVjcPyvwtDrJSZAYbb4E7HFwToNwctXsYREEM8DYu8d7m2roAur/xGWpG174WnoSHdESdL4S5fZdBn35XTb33iNPC1C3Wb5lHwLvqSS19k0jnksBBBMqo95fqdSdU2H9GNfp4HpMjrksgACnzqCVof+bIb/rzFPzygEKyEQDWt7ndnVQPAmtqX7T/kyIYAvEi6ww81+37qNgvnw5/DMg== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980816; c=relaxed/relaxed; bh=UVN+59hMO8qdkHBssLzN1RNNKhQ8KQ1mimLdxlbt15M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SEKPp1t0vIZAe41mnml2XKCULfmZCYdudkmYIHn/+3ysYQQX4PrSoenIuypr9KwUOyy05MYJ3SRLtCFOMURfFWcVXyMxkB0Nkk5US7lSCXZCuD4YxvdY1831Doehgk8QBfyEtIkQ3ZF2box1Z4Uh7eFGKHN9mxxMiHcesz39J4E1Gasn6g+CUFPVm7bKIFNcvU8YMa6pMTFUXM4lKDoT894MxPyhUzcgBfsPwaU47Ci0jyv2sCWFmPhZAzTSrSDH3Qhk3C60MbIqHWoB5XL5FfhM3pO1lqhUYcMDSWVtFfPTCa/KUC6PV5FXBDkegux7Aro/exLH0iF3JzZHx0iUQA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AMgBaGw/; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19947-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AMgBaGw/; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19947-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [IPv6:2600:3c0a:e001:db::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNyj3nWvz4w9T for ; Sat, 03 Oct 2026 08:40:13 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id E2B2243AAE for ; Fri, 2 Oct 2026 22:37:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4C5046DFE5; Fri, 2 Oct 2026 22:37:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AMgBaGw/" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 6FFFC455605; Fri, 2 Oct 2026 22:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980655; cv=none; b=eFp0rEMmeNGRNyPQcLNL0Awyv8A3LJSosbiw3sFLio7QWovI+xXomgN90KTGWx0iCd7n4g8XOd9zbW3g5GME3HigqZVg7xdG0G9BmNEcjYuDYd0M6WSkN4zR6fpzJH+9rGIv3drw9eAAIGx9dHi+lqeK9yY4FS0bWZ6XwY5Rl7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980655; c=relaxed/simple; bh=BrImC1zQUupHyWjfco3L85lPWp/4vRjvL457rfr9be4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wo2apSbrPXmzCKAj4yQExI4fdT5Qo6MMoUL3kICN/GGyrdGRxynaIugSt606We6ekfYan2Xm9xA54aOV7EE0CFZ1JKMGoMaT9EKsigxbmrw2tUg7ykL1eB5H06jJ9SEcp0h0aYrhq6gw+QpQT14B9HVXQAAv6h4cJlWiuP2DbKk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AMgBaGw/; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E93B21F00898; Fri, 2 Oct 2026 22:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980654; bh=UVN+59hMO8qdkHBssLzN1RNNKhQ8KQ1mimLdxlbt15M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AMgBaGw/eYw3bbHkJOE6O/EgrUc3aAjhokZqbm4kMzSflOUARroBuDKzttAVFu9En h0pVvR+xdTie06nf16HhxVCBi7Rb7shA3pcjj3Y735mVX47p/pJB4nYGCBlDa3Kxig q2QcFWEfg1Od1JgjSN3zt055LhuHzVAY/e73DkfcZ4jMBMvgimDVIIRq9dpL1WuzHh esyQQmdl1u/iCNdfAwMvXswWu33+8sWTVAueeLksdvIjKRJexJrWOg30GjE+cZ6r7b FfViQrW/vxoNHw1oRnch5JJLEvxmDJKZBZRG+9+2oMqNtW3dzM5G7wcOwQkmdq4cVo fWW9uDGyVupaw== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com, stable@vger.kernel.org Subject: [PATCH v17 06/21] fsverity: hoist statx reporting of fs-verity flag Date: Sat, 3 Oct 2026 00:36:47 +0200 Message-ID: <20261002223705.2175542-7-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org All filesystems, supporting fsverity, report this status by checking inode flag. Also, BTRFS was missing stat->attributes_mask, which is fixed now. Fixes: 146054090b08 ("btrfs: initial fsverity support") Cc: stable@vger.kernel.org Signed-off-by: Andrey Albershteyn Acked-by: Eric Biggers Reviewed-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" --- fs/btrfs/inode.c | 3 --- fs/ext4/inode.c | 5 +---- fs/f2fs/file.c | 5 +---- fs/stat.c | 6 +++++- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 93ef3cec191e..c34d0198b988 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8236,7 +8236,6 @@ static int btrfs_getattr(struct mnt_idmap *idmap, struct inode *inode = d_inode(path->dentry); u32 blocksize = btrfs_sb(inode->i_sb)->sectorsize; u32 bi_flags = BTRFS_I(inode)->flags; - u32 bi_ro_flags = BTRFS_I(inode)->ro_flags; stat->result_mask |= STATX_BTIME; stat->btime.tv_sec = BTRFS_I(inode)->i_otime_sec; @@ -8249,8 +8248,6 @@ static int btrfs_getattr(struct mnt_idmap *idmap, stat->attributes |= STATX_ATTR_IMMUTABLE; if (bi_flags & BTRFS_INODE_NODUMP) stat->attributes |= STATX_ATTR_NODUMP; - if (bi_ro_flags & BTRFS_INODE_RO_VERITY) - stat->attributes |= STATX_ATTR_VERITY; stat->attributes_mask |= (STATX_ATTR_APPEND | STATX_ATTR_COMPRESSED | diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 26f0f9714f03..206c6245c619 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -6318,15 +6318,12 @@ int ext4_getattr(struct mnt_idmap *idmap, const struct path *path, stat->attributes |= STATX_ATTR_IMMUTABLE; if (flags & EXT4_NODUMP_FL) stat->attributes |= STATX_ATTR_NODUMP; - if (flags & EXT4_VERITY_FL) - stat->attributes |= STATX_ATTR_VERITY; stat->attributes_mask |= (STATX_ATTR_APPEND | STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED | STATX_ATTR_IMMUTABLE | - STATX_ATTR_NODUMP | - STATX_ATTR_VERITY); + STATX_ATTR_NODUMP); generic_fillattr(idmap, request_mask, inode, stat); return 0; diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index edc352569e87..dc1cc0965532 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1075,15 +1075,12 @@ int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path, stat->attributes |= STATX_ATTR_IMMUTABLE; if (flags & F2FS_NODUMP_FL) stat->attributes |= STATX_ATTR_NODUMP; - if (IS_VERITY(inode)) - stat->attributes |= STATX_ATTR_VERITY; stat->attributes_mask |= (STATX_ATTR_COMPRESSED | STATX_ATTR_APPEND | STATX_ATTR_ENCRYPTED | STATX_ATTR_IMMUTABLE | - STATX_ATTR_NODUMP | - STATX_ATTR_VERITY); + STATX_ATTR_NODUMP); generic_fillattr(idmap, request_mask, inode, stat); diff --git a/fs/stat.c b/fs/stat.c index c461c3054234..e03954c36b33 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -203,8 +203,12 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, if (IS_DAX(inode)) stat->attributes |= STATX_ATTR_DAX; + if (IS_VERITY(inode)) + stat->attributes |= STATX_ATTR_VERITY; + stat->attributes_mask |= (STATX_ATTR_AUTOMOUNT | - STATX_ATTR_DAX); + STATX_ATTR_DAX | + STATX_ATTR_VERITY); idmap = mnt_idmap(path->mnt); if (inode->i_op->getattr) { From patchwork Fri Oct 2 12:36:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315405 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cW87j4se; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=/wko=hy=vger.kernel.org=linux-ext4+bounces-19948-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNzz4gZJz1xvt for ; Sat, 03 Oct 2026 08:41:19 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNzM07Tjz4w0Q for ; Sat, 03 Oct 2026 08:40:47 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNzM04W9z4w9T; Sat, 03 Oct 2026 08:40:47 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c0a:e001:db::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980846; cv=pass; b=mf7NiGPby61OQEF7VlleDb8ijYCnB+yuhfj+3csBHaq0D8O2NFM7DXBU+g8JeDrzHC2T1uqdLzUh7w+SQci3yXSlex5hFWKznzqnCtWwQguYbOTG5bzXH2lr8JQ7b5sYrIVt31QJBs13k6u+4En5Yfxxz0BTUy5q9f/ztkn0Rnl2oXStzoH5txLJ+xkTO6G7vpI8dmOlZ186dU6+QMrUq0mRLRZomhSjdYT0X+43g2V1SP/9l52PGu5K8NgGOmymyu+EEiciY7/xTCQlI4D9MUJb/B2zsV8UNccB0ct1h5fBPraQlFbp0i3yQIcttCZivwEGbR4J7ZjkpXqPv7WywQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980846; c=relaxed/relaxed; bh=I/PdPOBJE7QGY68F87fru7mnK+/jnmUWScBlE91haiA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=a4sk/E/6Dhy4cITOFJPDiiSeiCCsCDvD1OshU60ohBp2KyIc8T37WYUl0FsERGA0K8Dw1ba8oLojCpSAhoVVPh9q81LCZUDHyGW0QRQaEgmacwWiPaiOT2txh83LRt3HO3gjxrcI5jl5lGLrkSYRtvKfiZ7znQjWBX/msjUdNI4P3cQm4+HDKwzxrWf2TYQS70snCDw5qO/dULacG07xC00sbDjYxj4uEOHD4TCHllB5UoiVgEGS4uW69wQfvDEpbQMXa9DAp2q3R3NnEUmQPpn906VkYENONCI7vhBXGdAD9UBpJO8NGLc/tN46XfFXgBemWXBYpb49z1v962/b2w== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cW87j4se; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19948-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cW87j4se; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19948-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [IPv6:2600:3c0a:e001:db::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNzH42PVz4w0Q for ; Sat, 03 Oct 2026 08:40:43 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 070AC4450D for ; Fri, 2 Oct 2026 22:37:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8061B470E97; Fri, 2 Oct 2026 22:37:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cW87j4se" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 DFDB73C4555; Fri, 2 Oct 2026 22:37:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980659; cv=none; b=GC5/Y+7StbKY/akujCZRGXMzSmRKDdiAkTguEP3x2tCBBBwmO/xLLFxdUGx9wbkH6ow0XRyxmRoGNuYjjM0Ab9/xJUNs2cTLxc6iFpHL34y7xYw5tb7MVrG8N9sOHX8mM8uQiA7jA7kUiz+/nzeTpNWvOOF+ESAvvwYawG/TTYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980659; c=relaxed/simple; bh=dnStKtASmyuFs6J/dGjSkvxfVtSOHWzIWo7H21kyeZs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PjC5h/+tcnojHAjmeV6HUo6CUb+ncC7+MqsI/eKXQwxbUKogPQHiTwEI75hBvUMdet5x9OX3mMKycju9i28SiLah2suys2rAGVVOUGdoYrVP0++891vY7XIuTEe+9RY8SFvPtGkZNE22O5JETpwAIpjqVxEbvPg1vVud3tzb/cw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cW87j4se; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 978D81F00893; Fri, 2 Oct 2026 22:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980657; bh=I/PdPOBJE7QGY68F87fru7mnK+/jnmUWScBlE91haiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cW87j4seoq6YRTRP61hKaT3rehb5v6mu98Zauf28XZFta6h9Zwz4wngd/TcVng+4E zBVnxXj7NTeNozN7xL7BqF3vMIj/mTZkAKoVEDSGTMPID99pyHWPNm6RjKE1GHMwYU 5vuctEsn4LavX+WDg4oxMizxMn5GiYmuQ4obo5HPtmWMvk7mc17D+JAj/Gryg2JM0H gQUdVVRleN7+4Gwt1TT4uupsa+ewCdDwB0FxjdBDpuvLKGSOu/GR7BTXuq6tc4qaUq FZ9XnmPuIi9TkMe3eymZaSmz69VewGZrZ1F9tez3jrXbb5eFHraXKd1LkebOXGMgx+ U7x/DyXti9o0w== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 07/21] xfs: introduce fsverity on-disk changes Date: Sat, 3 Oct 2026 00:36:48 +0200 Message-ID: <20261002223705.2175542-8-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org Introduce XFS_DIFLAG2_VERITY for inodes with fsverity. This flag indicates that inode has fs-verity enabled (i.e. descriptor exist, tree is built and file is read-only). Introduce XFS_SB_FEAT_RO_COMPAT_VERITY for filesystems having fsverity inodes. As on-disk changes applies to fsverity inodes only, let older kernels read-only access. This will be enabled in the further patch after full fsverity support. Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_format.h | 30 +++++++++++++++++++++++++++++- fs/xfs/libxfs/xfs_inode_buf.c | 8 ++++++++ fs/xfs/libxfs/xfs_inode_util.c | 5 ++++- fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_iops.c | 5 ++++- fs/xfs/xfs_mount.h | 2 ++ 6 files changed, 49 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index dd0ed046fbe9..fc196d9e12dd 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -374,6 +374,7 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ #define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ +#define XFS_SB_FEAT_RO_COMPAT_VERITY (1 << 4) /* fs-verity */ #define XFS_SB_FEAT_RO_COMPAT_ALL \ (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ @@ -1230,16 +1231,21 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) */ #define XFS_DIFLAG2_METADATA_BIT 5 +/* inodes sealed with fs-verity */ +#define XFS_DIFLAG2_VERITY_BIT 6 + #define XFS_DIFLAG2_DAX (1ULL << XFS_DIFLAG2_DAX_BIT) #define XFS_DIFLAG2_REFLINK (1ULL << XFS_DIFLAG2_REFLINK_BIT) #define XFS_DIFLAG2_COWEXTSIZE (1ULL << XFS_DIFLAG2_COWEXTSIZE_BIT) #define XFS_DIFLAG2_BIGTIME (1ULL << XFS_DIFLAG2_BIGTIME_BIT) #define XFS_DIFLAG2_NREXT64 (1ULL << XFS_DIFLAG2_NREXT64_BIT) #define XFS_DIFLAG2_METADATA (1ULL << XFS_DIFLAG2_METADATA_BIT) +#define XFS_DIFLAG2_VERITY (1ULL << XFS_DIFLAG2_VERITY_BIT) #define XFS_DIFLAG2_ANY \ (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ - XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64 | XFS_DIFLAG2_METADATA) + XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64 | XFS_DIFLAG2_METADATA | \ + XFS_DIFLAG2_VERITY) static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) { @@ -2027,4 +2033,26 @@ struct xfs_acl { #define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1) #define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1) +/* + * At maximum of 8 levels with 128 hashes per block (32 bytes SHA-256) maximum + * tree size is ((128^8 − 1)/(128 − 1)) = 567*10^12 blocks. This should fit in + * 53 bits address space. + * + * At this Merkle tree size we can cover 295EB large file. This is much larger + * than the currently supported file size. + * + * For sha512 the largest file we can cover ends at 1 << 50 offset, this is also + * good. + */ +#define XFS_FSVERITY_LARGEST_FILE ((loff_t)1ULL << 53) + +/* + * Alignment of the fsverity metadata placement. This is largest supported PAGE + * SIZE for fsverity. This is used to space out data and metadata in page cache. + * The spacing is necessary for non-exposure of metadata to userspace and + * correct merkle tree synthesis in the iomap. + */ +#define XFS_FSVERITY_START_ALIGN (65536) + + #endif /* __XFS_FORMAT_H__ */ diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index e4c3f7b24e95..b4cc673adc8a 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -761,6 +761,14 @@ xfs_dinode_verify( !xfs_has_rtreflink(mp)) return __this_address; + /* only regular files can have fsverity */ + if (flags2 & XFS_DIFLAG2_VERITY) { + if (!xfs_has_verity(mp)) + return __this_address; + if (!S_ISREG(mode)) + return __this_address; + } + if (xfs_has_zoned(mp) && dip->di_metatype == cpu_to_be16(XFS_METAFILE_RTRMAP)) { if (be32_to_cpu(dip->di_used_blocks) > mp->m_sb.sb_rgextents) diff --git a/fs/xfs/libxfs/xfs_inode_util.c b/fs/xfs/libxfs/xfs_inode_util.c index 258ac3d0d486..5a516bd31c31 100644 --- a/fs/xfs/libxfs/xfs_inode_util.c +++ b/fs/xfs/libxfs/xfs_inode_util.c @@ -74,7 +74,8 @@ xfs_flags2diflags2( uint64_t di_flags2 = (ip->i_diflags2 & (XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_BIGTIME | - XFS_DIFLAG2_NREXT64)); + XFS_DIFLAG2_NREXT64 | + XFS_DIFLAG2_VERITY)); if (xflags & FS_XFLAG_DAX) di_flags2 |= XFS_DIFLAG2_DAX; @@ -126,6 +127,8 @@ xfs_ip2xflags( flags |= FS_XFLAG_DAX; if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) flags |= FS_XFLAG_COWEXTSIZE; + if (ip->i_diflags2 & XFS_DIFLAG2_VERITY) + flags |= FS_XFLAG_VERITY; } if (xfs_inode_has_attr_fork(ip)) diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index f0341adbb879..985c7c6a09f2 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -165,6 +165,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_REFLINK; if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT) features |= XFS_FEAT_INOBTCNT; + if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_VERITY) + features |= XFS_FEAT_VERITY; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_FTYPE) features |= XFS_FEAT_FTYPE; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_SPINODES) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index d1306e723899..c7ecbb3d258a 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1397,12 +1397,15 @@ xfs_diflags_to_iflags( flags |= S_NOATIME; if (init && xfs_inode_should_enable_dax(ip)) flags |= S_DAX; + if (xflags & FS_XFLAG_VERITY) + flags |= S_VERITY; /* * S_DAX can only be set during inode initialization and is never set by * the VFS, so we cannot mask off S_DAX in i_flags. */ - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND | S_SYNC | S_NOATIME); + inode->i_flags &= + ~(S_IMMUTABLE | S_APPEND | S_SYNC | S_NOATIME | S_VERITY); inode->i_flags |= flags; } diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 894ff2f4ecbd..60cb54c1a5ec 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -403,6 +403,7 @@ typedef struct xfs_mount { #define XFS_FEAT_EXCHANGE_RANGE (1ULL << 27) /* exchange range */ #define XFS_FEAT_METADIR (1ULL << 28) /* metadata directory tree */ #define XFS_FEAT_ZONED (1ULL << 29) /* zoned RT device */ +#define XFS_FEAT_VERITY (1ULL << 30) /* fs-verity */ /* Mount features */ #define XFS_FEAT_NOLIFETIME (1ULL << 47) /* disable lifetime hints */ @@ -460,6 +461,7 @@ __XFS_HAS_FEAT(exchange_range, EXCHANGE_RANGE) __XFS_HAS_FEAT(metadir, METADIR) __XFS_HAS_FEAT(zoned, ZONED) __XFS_HAS_FEAT(nolifetime, NOLIFETIME) +__XFS_HAS_FEAT(verity, VERITY) static inline bool xfs_has_rtgroups(const struct xfs_mount *mp) { From patchwork Fri Oct 2 12:36:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315393 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Is6rdJmm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=iveq=hy=vger.kernel.org=linux-ext4+bounces-19949-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNwr5Sl0z1xyX for ; Sat, 03 Oct 2026 08:38:36 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNwD0wJJz4w1S for ; Sat, 03 Oct 2026 08:38:04 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNwD0pY8z4w9g; Sat, 03 Oct 2026 08:38:04 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c04:e001:36c::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980684; cv=pass; b=Z4hH1POOK0C563ZPsY8GwWlQ+wtf21d8BwQSE9ySZxseUrboUPsSvYxA0RrfICf1cVKagcr3IfvcKYyDED6GjAuQntTt7cELD7YV9ILQOa6rERj0xiiotZS+WQA0ZyC9/cWHTATmZ5tdWMMd9776DpnlSmbMiFYj4/lWZJbrK/2GqoYD2kT56DRc5WIwi7crAsjdHmsFTPaglN1zXRQD3fuH+cifCzsA9U38xpgh1b5Hodp+olwwNyR9/FjQ6ooOAkUo7V7oz6sZiSBiGryS7HmrFuE4vWeow0/yFQl586YW/7TjZ6+E6tp4FRGePTgh93CEqzHOVatw3qRK18jT+w== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980684; c=relaxed/relaxed; bh=tyN8+gtU92vgNY5ULImxmqhPQNG/e7/IRfFO6L6Bczg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y7NFp0kHdJJIrSjb32FMw2uZ+PJiDrwEOa8X5B/qkrewX1Grq5p/gRr86kClIYG1ia+cQCMBJmYWra938ybPJ7o+tkdTX/3wF64/eYB2f46nzR5aTqRTGzc0jqy9sbYacR/z4cyKE5L/2Eej4VeRkFfPhZU4bpf8j2FZNVAWfmHw5NZoa8pvGXo9iX5kr096reBIcelXnvbX61QV7rtZu8RlxO2q5vDvbbH6Z9po9GFL0RGNuj7KBN2JKUPIpe5dmsqdGiGr5TD+ayaUq005pTfRaZaHibhXJLHoUkyeYHIuDaHOiu1nBA9/zwkLa9QK/XcGqJO259NxfWCXWUz5aQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Is6rdJmm; dkim-atps=neutral; spf=pass (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19949-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Is6rdJmm; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19949-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from tor.lore.kernel.org (tor.lore.kernel.org [IPv6:2600:3c04:e001:36c::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNw85Cchz4w1S for ; Sat, 03 Oct 2026 08:38:00 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 1287A32582 for ; Fri, 2 Oct 2026 22:37:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 617DA47125F; Fri, 2 Oct 2026 22:37:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Is6rdJmm" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 2728A411A03; Fri, 2 Oct 2026 22:37:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980662; cv=none; b=cGxSEqMXofp5l63Q1E3EYjip/9r2YpoMYSdGvpijvwWQRSLUS8IdyukoazK+a0+DwPIsrRPBUrD5Z6bn4cUfylFS166MikXj6zRKlaHo/LB72Dz4PSCHJZ44atzZWEtphipgLs1msSd3q+3Zgp5zX5LryH2E1XySwFwhSDPfda8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980662; c=relaxed/simple; bh=H/e0P+UlJBXIJCMWsp5bxESKBgwV9KeCad/muhyUdmw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ubcyZoHHN2UCZh7YhHopAoMGVbY2JDn29M29vhLc/f+ocN4f9lVZ3+97ORNYI5YBg0yt6X+68unlRB6TYtJvGp+jP3eEHpOTIq/j7MU0P905FkaGfl2IJRgC+m2gToXm+0prSYGphmxjUfES9jLHQTwosDS4EEEco3eihICbM70= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Is6rdJmm; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16CFA1F000FF; Fri, 2 Oct 2026 22:37:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980661; bh=tyN8+gtU92vgNY5ULImxmqhPQNG/e7/IRfFO6L6Bczg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Is6rdJmm0F740AinrlD2eXqyQ7AnNrjuP5QcPizteoY4fErQuf4b372wSufcyTpwG DfD+ogqXcOEEIPLqRu0Xk0Q0cVs0mDcylKHW1kpe0MeZA38YSOM7QGzEd0oBIGxk5E XKJCJgZOqTviIv0Kj0/07h3MT0BfC2AVswMpbecJ1bnTwWIWMqpMBPB+nbzbYmA6/y jUmZvZ4AghOwsfooqgtmHwV10fPRswe04TVonX12wfSorIksJk1tCl5zRUzl7ZhIPs 874hWB8sD2Y7C6+h+JOurBcKXIph4D5k65eIlzYgko16vJfHbLuleABmueEyMx+Uap hynN3EuS5Zovg== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 08/21] xfs: don't allow to enable DAX on fs-verity sealed inode Date: Sat, 3 Oct 2026 00:36:49 +0200 Message-ID: <20261002223705.2175542-9-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org fs-verity doesn't support DAX. Forbid filesystem to enable DAX on inodes which already have fs-verity enabled. The opposite is checked when fs-verity is enabled, it won't be enabled if DAX is. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Andrey Albershteyn --- fs/xfs/xfs_iops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index c7ecbb3d258a..b07ca2a33c64 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1369,6 +1369,8 @@ xfs_inode_should_enable_dax( return false; if (!xfs_inode_supports_dax(ip)) return false; + if (ip->i_diflags2 & XFS_DIFLAG2_VERITY) + return false; if (xfs_has_dax_always(ip->i_mount)) return true; if (ip->i_diflags2 & XFS_DIFLAG2_DAX) From patchwork Fri Oct 2 12:36:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315407 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aE8cWwJu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=m3/2=hy=vger.kernel.org=linux-ext4+bounces-19950-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxP134kMCz1xvt for ; Sat, 03 Oct 2026 08:42:15 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxP0R0BC8z4w0Q for ; Sat, 03 Oct 2026 08:41:43 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxP0R083Lz4wBD; Sat, 03 Oct 2026 08:41:43 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.234.253.10 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980903; cv=pass; b=uIcXhbgLBRfr9qRTYZ8Sz0aUytyaqsedbR0f5gWLqyBRJrB0x5fc8nDNdzlXR5n7BfeJ0bW2cNJVUa4F1Lfeuwzy/k9FVFy7Gs18PvTIR+ixo5WqJ9E7OfebaNM8GTFuhbamhWkZyxvO6GOP+zW/cmFT6f6h6sh28DteelxvCMNavjyPAEYQJb/u7fPFtzi83KfMaUodaInUiw+21XS/YLcbP+exmEzoH8gHfRnYJEuisKl8HvrX7U+XxmbbTpRwQ8/nFqhcIek6V/jQuVozD+tV0Zc6bY6ptqp5Wn4hrPI722Yae1urzZU0v0/1CK0XWjZTyLVdMCNu5oWPq2mi6w== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980903; c=relaxed/relaxed; bh=V/xMdTPkYwWHhaiHtNRdjWuqquaN/UDdlep3XfzYfiw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hrnJSHnIaBA/AQvqrM93pmIDxXeTOBiMqnbk8T/bofi/WHX5TK8cKrILuyQOtmQ/5A31RDlLnTB/qWtmoGdZRcYO71EfPd7QgjuiABXAyIA8yzRN1r25UJFXctX9S4tIiP3uB+IrO6oyZxACAHQIY6i4Sqf9j2dyYKUonYkCpzbKHsWdq5WQy3tIyYBEDcolaANeB7SulBBl1CpnxzL3/2El83FBUlvptHaEUyUA1ADD2HKaHx5KzOksADBpIZ4MWDdemAA3IgB8QtoGhI0rX1QarpIjtQ+h+UT0w+Wt2/6rhl0Wn8NFfdYnRGvGayaFQtKQv570hMj7fYovUPVnuQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aE8cWwJu; dkim-atps=neutral; spf=pass (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19950-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aE8cWwJu; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19950-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxP0M57jSz4w0Q for ; Sat, 03 Oct 2026 08:41:39 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id ACF4B4672D for ; Fri, 2 Oct 2026 22:37:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5386946E017; Fri, 2 Oct 2026 22:37:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aE8cWwJu" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 F13253C4555; Fri, 2 Oct 2026 22:37:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980666; cv=none; b=KROuIukow9A1YnousqKuI+jnkNHVsG7IY+m5yPfDS8kA0PMKdxQAdL2XE80dKkAIjaGRDVktYV56S5lS+VfVst0V6y9UBN+KF6uJjUfXoylYsuzG5I3NNHA48y8ZrHiqdp2ge7gF9RklxiAavtpGZDW4QAgIGeZMjMRYdynhOck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980666; c=relaxed/simple; bh=T8QaJnUp0BFUpEp0YiOa+PckWORguMtKwkHNvRCfbeY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cGEfsGOvvZ0f1yliHwI6E4LMSFXxLefDCpfSfC+Yv5ZDDonxxtar0G8UgVhDkjXJQHj+YD1Grb3u4wK4SsduTt7ZURPvM9af2ja1KyztYzrPte8gvPuEDdUBDxmPjY6ZVBDXk1Lwrdupp3cOvMd2aTryyHudqlHvHnmZnYgdnrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aE8cWwJu; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B0251F00893; Fri, 2 Oct 2026 22:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980664; bh=V/xMdTPkYwWHhaiHtNRdjWuqquaN/UDdlep3XfzYfiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aE8cWwJuQNVQUvEZa9dP1qgvQ5tnUowl9bA37rROte8G+MhGqEHmneOPCiZc/+xgM WsIz3hWRkcRZWiRIMGMOAzTXHvN8dGaiwyX2W+NQcj8q1iG1I7IEFRxrjgdujXWvDE N0/345qRxjhlGa30R0qzkxhIuO8fPgB2lW6U4HAhcYwQQfLZjwgUDO0YjmsGP9go4M PTiOkEnArREa+yngNUKpziNTxiJFqB/eKdKqBs2ZjsAcbpU27ubSyYUR0aQH25H+mv ePOwFYb1uu7zX2RheziOIJw5N+slBgzbach85qEprWRIbrcUg8Bd/pa2hW+LVF87mb 54O40WZgoxsGw== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 09/21] xfs: disable direct read path for fs-verity files Date: Sat, 3 Oct 2026 00:36:50 +0200 Message-ID: <20261002223705.2175542-10-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org The direct path is not supported on verity files. Attempts to use direct I/O path on such files should fall back to buffered I/O path. Add a fall back to buffered I/O at two place, in a common fast path and latter when lock is acquired. The second check prevents TOCTOU issue with reading fsverity_active() status and resetting IOCB_DIRECT flag. If one thread saw fsverity_active() to be false, and then second thread acquired XFS_IOLOCK_EXCL and enabled fsverity. The first thread will go through the DIO path. Signed-off-by: Darrick J. Wong Signed-off-by: Andrey Albershteyn Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_file.c | 61 +++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index dd3782e9af93..07abf6e8783f 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -38,6 +38,7 @@ #include #include #include +#include static const struct vm_operations_struct xfs_file_vm_ops; @@ -232,6 +233,25 @@ static const struct iomap_dio_ops xfs_dio_read_bounce_ops = { .bio_set = &iomap_ioend_bioset, }; +STATIC ssize_t +xfs_file_buffered_read( + struct kiocb *iocb, + struct iov_iter *to) +{ + struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp)); + ssize_t ret; + + trace_xfs_file_buffered_read(iocb, to); + + ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED); + if (ret) + return ret; + ret = generic_file_read_iter(iocb, to); + xfs_iunlock(ip, XFS_IOLOCK_SHARED); + + return ret; +} + STATIC ssize_t xfs_file_dio_read( struct kiocb *iocb, @@ -250,6 +270,17 @@ xfs_file_dio_read( ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED); if (ret) return ret; + + /* + * Re-check verity status after acquiring lock. This prevents TOCTOU in + * xfs_file_read_iter() while falling back from DIO to buffered I/O as + * now we are holding a lock + */ + if (fsverity_active(VFS_I(ip))) { + xfs_iunlock(ip, XFS_IOLOCK_SHARED); + iocb->ki_flags &= ~IOCB_DIRECT; + return xfs_file_buffered_read(iocb, to); + } if (mapping_stable_writes(iocb->ki_filp->f_mapping)) { ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, &xfs_dio_read_bounce_ops, 0, NULL, 0); @@ -269,7 +300,8 @@ xfs_file_dax_read( struct kiocb *iocb, struct iov_iter *to) { - struct xfs_inode *ip = XFS_I(iocb->ki_filp->f_mapping->host); + struct inode *inode = iocb->ki_filp->f_mapping->host; + struct xfs_inode *ip = XFS_I(inode); ssize_t ret = 0; trace_xfs_file_dax_read(iocb, to); @@ -287,25 +319,6 @@ xfs_file_dax_read( return ret; } -STATIC ssize_t -xfs_file_buffered_read( - struct kiocb *iocb, - struct iov_iter *to) -{ - struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp)); - ssize_t ret; - - trace_xfs_file_buffered_read(iocb, to); - - ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED); - if (ret) - return ret; - ret = generic_file_read_iter(iocb, to); - xfs_iunlock(ip, XFS_IOLOCK_SHARED); - - return ret; -} - STATIC ssize_t xfs_file_read_iter( struct kiocb *iocb, @@ -320,6 +333,14 @@ xfs_file_read_iter( if (xfs_is_shutdown(mp)) return -EIO; + /* + * In case fs-verity is enabled, we also fallback to the buffered read + * from the direct read path. Therefore, IOCB_DIRECT is set and need to + * be cleared (see generic_file_read_iter()) + */ + if (fsverity_active(inode)) + iocb->ki_flags &= ~IOCB_DIRECT; + if (IS_DAX(inode)) ret = xfs_file_dax_read(iocb, to); else if (iocb->ki_flags & IOCB_DIRECT) From patchwork Fri Oct 2 12:36:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315394 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=laeAvlxH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=y4u/=hy=vger.kernel.org=linux-ext4+bounces-19951-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNx63V2bz1xyX for ; Sat, 03 Oct 2026 08:38:50 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNwT63TXz4w1S for ; Sat, 03 Oct 2026 08:38:17 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNwT61QFz4w9g; Sat, 03 Oct 2026 08:38:17 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.105.105.114 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980697; cv=pass; b=d+qT7ZVqvzSYygDCOf7oal36QQsy54ab4LSYkkX8KUP03rY+pMNYw1uPmzEBPMTQaDYmKyLHefCiYwpY06fT47YI3jbRuIPlc3K4XEqPjJESJbX+7IFUQsGdZQLq1shyukD16fcVEzMygX4FkM+2VDEmPj9ipCteDdqIgm480L/+SX0Qf4PRqYX5v9xcXnoeUXIgagXL56h/CKcKgnMYEPRQuko/DxrCvt6Vx4Dwyk4uhdUpTtA+Akn5/q3TCp8NO9g+Zjp8SWuyrGiDP6f6BSqLYLykPO/l/YUTpU5hAGyeAy6zhfTg5xiL5iyVpRcElazw5m1HpgLyr3wJqnooAw== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980697; c=relaxed/relaxed; bh=ieVuD4QM5J41nXjMBZicua2S6B/WM0wDRAu86VZATUA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KTh+vCE/NXIX1EUAEA/+1Nwf+yODp+VbLdB0NyRR5qpKWo06ycFLlacf/apBV+W5LuCdTelO5HACeM4Bl8UbAvYfYMpNN+x9yaxpntnMyMXXd4XpsCQX1GO8X4QQTLsK2n0IGZjNaLyNj9kS1FjUVmmI3gIG1bQj1YJEemSHGAfBZy132BNLd+5i32vKxefz46zzuTzHP3aT7skJC6bR17TsaElp6dZ99uHkyLzH3UqhyOIEhxJbBUBNyUWvVuuFIgymp4TSxKBGPDNR3B8L8kBkkrrgvn75AviK7c9R6iDRy/vunCC/25aa3sK2pUmsVkFRD01djFTF3embG/tzIQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=laeAvlxH; dkim-atps=neutral; spf=pass (client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19951-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=laeAvlxH; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19951-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNwQ1M8jz4w1S for ; Sat, 03 Oct 2026 08:38:14 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id D164431544 for ; Fri, 2 Oct 2026 22:37:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93BE846E017; Fri, 2 Oct 2026 22:37:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="laeAvlxH" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 5AAD044AB68; Fri, 2 Oct 2026 22:37:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980669; cv=none; b=qMO2uG/KoLN9vMEy4eI3EXnohJyBsP2mXhs+20jo7s+Si94EBXXhg+/eiq/KYrUwB87rpCCEheT/DDRZ0UnACtJ1tto9BIhIBRiBTcquU0z+DNgJKnX0jJtDzL4DR3CasE0f6sjnP9MkBq6MdR9XXu1ms5YBTHDoS1Lce/H2PCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980669; c=relaxed/simple; bh=kI3gumtKLRQWMTMAXEpDV7dndwtPFc184oyMWIaFzT8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HEps0uxykNpvfiJ/w3QpqXJQD0HVZDq/Uz4Y4BQVpVgE/SN/qYflyakfgjykFEfW63twzGwz861035yX6sY7eealhyISK7b22LF4SzKf3+vJwZ0TrtBNQAhnn4FIoXX6+OiYhNdZE7W04eB/Yb0fo0EiSjCWHe8+QWaC0bFz2XM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=laeAvlxH; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F7D11F000FF; Fri, 2 Oct 2026 22:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980668; bh=ieVuD4QM5J41nXjMBZicua2S6B/WM0wDRAu86VZATUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=laeAvlxHHeZ6Gte499h9yTtQJvpFgsdWN+gvKWUOCNP7KOHdNtYZMYj3fwWTfNjXr pq8f2uFqJbR1EKTTKCOKIYg4ZJzzWY1xpfXeMtssLVo+ORkuobos6oJOSbPBSjXp1J o++FLhVXeMGL3o4k74vh+VS7vftXkT/xXEnoBM9lWPgEFxsN2pzyTDdRgLCpjYXZBY RsFt2zuA1HMsR3ErbZ6Tl7OGqvcRwmsCEe5jnFsaVRnlmJJHk5XEL4Lfodf3xOToi3 Z786P3kwJBXjGqxIN6vxA95vzkKiO83v3Ljg2UwEAcSvAjWx9Flk3oavfJibauapaQ htYUNR0YTBuUQ== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 10/21] xfs: don't report dio_mem_align and dio_offset_align for fsverity files Date: Sat, 3 Oct 2026 00:36:51 +0200 Message-ID: <20261002223705.2175542-11-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org Sashiko.dev reported that while fsverity files falls back to the buffered IO for Direct I/O, they should not report non-zero values in dio_mem_align and dio_offset_align, meaning it's not supported. The STATX_DIOALIGN | STATX_DIO_READ_ALIGN flags are used to explicitly report if DIO is supported or not. They can not indicate that fallback to the buffered IO is used in this case. The zero alignment values also mean that DIO is not supported on this file, see statx(2). Signed-off-by: Andrey Albershteyn Acked-by: Eric Biggers Reviewed-by: "Darrick J. Wong" --- fs/xfs/xfs_iops.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index b07ca2a33c64..d9c25c06cc60 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -35,6 +35,7 @@ #include #include #include +#include /* * Directories have different lock order w.r.t. mmap_lock compared to regular @@ -579,6 +580,10 @@ xfs_report_dioalign( struct block_device *bdev = target->bt_bdev; stat->result_mask |= STATX_DIOALIGN | STATX_DIO_READ_ALIGN; + + if (fsverity_active(VFS_I(ip))) + return; + stat->dio_mem_align = bdev_dma_alignment(bdev) + 1; /* From patchwork Fri Oct 2 12:36:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315408 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Um6giWYf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=jf9l=hy=vger.kernel.org=linux-ext4+bounces-19952-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxP2L0fsBz1xvt for ; Sat, 03 Oct 2026 08:43:22 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxP1j36kKz4w0Q for ; Sat, 03 Oct 2026 08:42:49 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxP1j34Ykz4wBD; Sat, 03 Oct 2026 08:42:49 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c0a:e001:db::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980969; cv=pass; b=r6j1V/3eJ/d9nOOqgYPWyy+OY7FZ5D49KtC1EjNKh9fqeDXVmUA6Tfawz6o7jkYkCLOHvr2zqEq2NSo0uoEnGI6htJQIvqEctPC2HAaUG47virYCyt8xpAoopirZ+9q8QbgQKraNaixNZfJJVdyN/cT8VACP45ZKRwd+xpTWqbfPMeByzvafel/AfkzbPL+laL6+4XdS8pFTX0xgixwVQk0kwLwo2lijtThdJcHqTAGHCHP05nI77cirUVT+ShLctLvCSJP96FVTdu497M7KzlYjRKoNG3ZJ4w/sMEjhr2VFv8NRzbAHk26vjSJ9+qx3EB7SIu1X6brSMrLmJhD1IQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980969; c=relaxed/relaxed; bh=dvtqKS0n96fAVujRqx2ORjcVNwtZXlHKAcxua1BPCkQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gXF8XrGAozFYgHurxImTeAGEzkX61aqpw4/79pqALgkV43ROd2n2xmG654NYt+U0hxXpmVyj/3dCC1j9oANQyIfqUj41p1PEoa2CiCX2pw/6pjpIN3W2S+JOGsE68atKZXN/wPxK7VIaB//4sDREVjxRZuyitj4rSPAq4j1rK32DBcp9i6xFCLatwYcUITFJZW64V+4vnDMBChftmkF/A0cj3lmRyKgbqETNnbmvtZNBZmtiIoy+nWdUn5+ft8Abotusp9Gw0NaZ2ST9277zcxCssV5X7SfZeJ7NWPMcFV6TIfGNTRgF9g1BEOkYf3b16pnksqr1IlDk7DFIa1FYVg== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Um6giWYf; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19952-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Um6giWYf; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19952-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [IPv6:2600:3c0a:e001:db::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxP1d60mrz4w0Q for ; Sat, 03 Oct 2026 08:42:45 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id B201760109 for ; Fri, 2 Oct 2026 22:37:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53B1746D0B0; Fri, 2 Oct 2026 22:37:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Um6giWYf" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 9B45B411A03; Fri, 2 Oct 2026 22:37:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980673; cv=none; b=tIjVP2Gf9qjuYSLv+nddXWG7h+ouZLZrwUwr3njzUqdZFk6NzVnM1079j5SAhPP09+OZlJtT1OoFCQlHEHH4/WxWiRvgT+IKbFRmzq23d9OOW/dDlL2zekvwTGWqgaF++DWzLlBbdDO684P9UO19ixNKD6maPX8O+JLdth0WT3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980673; c=relaxed/simple; bh=8Ni3Hg6w5RGSiN4+LHYANHNB8vTJemV8cpIOkc6KLlA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HeH61PMytFm+8Q0yWPbalgcigZrahnTz9xStBd+/Hw7QvtxpvJChY5jc8Ih48qeAn2582XF7flQMxIxLwje67RlgOES0qBuCvSqTbt96mMosnJpfCKRYuC1YXRuIwdQCASmJUHxMsGgU7Cz1g+9dk2LqqoStxScS+6UY5sqdKrk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Um6giWYf; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86C731F00893; Fri, 2 Oct 2026 22:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980671; bh=dvtqKS0n96fAVujRqx2ORjcVNwtZXlHKAcxua1BPCkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Um6giWYfKVSRYSzIVspSz4rGB0wLsnTcz+weHoBt7jJr/HqS2T1h8GvPPt7MTuej7 X48FiP8p0zLbv2AJiqNSe7kMjw0EGMFIJyuEFozdoTtNIQKCgG2EpBCLELUlMJF8VF wPQ4+i9vVpuH7L4N+A51QFwDhNuiwIQA9Ilo3BA068IsMde7j/UqmkNZT1g7/HdT8m 8H0Hmlem7S5C4dhsf5qDTk0RNOARNYYi913tnJyP7hdnLy1SZdfWTnqNdqOUfFK+fh C7NV0ZV+Mz4HprrdE6q/GScTEQZCwr+dAoDblpN1vldiH9VC6LE/sPFTouFi1QEFt6 a3/mC89KEGDng== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 11/21] xfs: handle fsverity I/O in write/read path Date: Sat, 3 Oct 2026 00:36:52 +0200 Message-ID: <20261002223705.2175542-12-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org For write/writeback set IOMAP_F_FSVERITY flag telling iomap to not update inode size and to not skip folios beyond EOF. Initiate fsverity writeback with IOMAP_F_FSVERITY set to tell iomap should not skip folio that is dirty beyond EOF. In read path let iomap know that we are reading fsverity metadata. So, treat holes in the tree as request to synthesize tree blocks and hole after descriptor as end of the fsverity region. Introduce a new inode flag meaning that merkle tree is being build on the inode. Signed-off-by: Andrey Albershteyn Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_bmap.c | 9 +++++++++ fs/xfs/xfs_aops.c | 36 +++++++++++++++++++++++++++++++----- fs/xfs/xfs_fsverity.c | 22 ++++++++++++++++++++++ fs/xfs/xfs_fsverity.h | 20 ++++++++++++++++++++ fs/xfs/xfs_inode.h | 6 ++++++ fs/xfs/xfs_iomap.c | 37 ++++++++++++++++++++++++++++--------- fs/xfs/xfs_iomap.h | 5 +++-- 8 files changed, 120 insertions(+), 16 deletions(-) create mode 100644 fs/xfs/xfs_fsverity.c create mode 100644 fs/xfs/xfs_fsverity.h diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 399a207f2d0e..dd712c521862 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -150,6 +150,7 @@ xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o xfs-$(CONFIG_SYSCTL) += xfs_sysctl.o xfs-$(CONFIG_COMPAT) += xfs_ioctl32.o xfs-$(CONFIG_EXPORTFS_BLOCK_OPS) += xfs_pnfs.o +xfs-$(CONFIG_FS_VERITY) += xfs_fsverity.o # notify failure ifeq ($(CONFIG_MEMORY_FAILURE),y) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index d64defeda645..9dc96a4edea6 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -41,6 +41,8 @@ #include "xfs_inode_util.h" #include "xfs_rtgroup.h" #include "xfs_zone_alloc.h" +#include "xfs_fsverity.h" +#include struct kmem_cache *xfs_bmap_intent_cache; @@ -4402,6 +4404,9 @@ xfs_bmapi_convert_one_delalloc( * the extent. Just return the real extent at this offset. */ if (!isnullstartblock(bma.got.br_startblock)) { + if (xfs_iflags_test(ip, XFS_VERITY_CONSTRUCTION) && + offset >= xfs_fsverity_metadata_offset(ip)) + flags |= IOMAP_F_FSVERITY; xfs_bmbt_to_iomap(ip, iomap, &bma.got, 0, flags, xfs_iomap_inode_sequence(ip, flags)); if (seq) @@ -4449,6 +4454,10 @@ xfs_bmapi_convert_one_delalloc( XFS_STATS_ADD(mp, xs_xstrat_bytes, XFS_FSB_TO_B(mp, bma.length)); XFS_STATS_INC(mp, xs_xstrat_quick); + if (xfs_iflags_test(ip, XFS_VERITY_CONSTRUCTION) && + offset >= xfs_fsverity_metadata_offset(ip)) + flags |= IOMAP_F_FSVERITY; + ASSERT(!isnullstartblock(bma.got.br_startblock)); xfs_bmbt_to_iomap(ip, iomap, &bma.got, 0, flags, xfs_iomap_inode_sequence(ip, flags)); diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index c30e688cfc9f..19640e4e3ed1 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -23,6 +23,7 @@ #include "xfs_ioend.h" #include "xfs_zone_alloc.h" #include "xfs_rtgroup.h" +#include "xfs_fsverity.h" struct xfs_writepage_ctx { struct iomap_writepage_ctx ctx; @@ -172,12 +173,16 @@ xfs_map_blocks( int retries = 0; int error = 0; unsigned int *seq; + unsigned int iomap_flags = 0; if (xfs_is_shutdown(mp)) return -EIO; XFS_ERRORTAG_DELAY(mp, XFS_ERRTAG_WB_DELAY_MS); + if (xfs_iflags_test(ip, XFS_VERITY_CONSTRUCTION)) + iomap_flags |= IOMAP_F_FSVERITY; + /* * COW fork blocks can overlap data fork blocks even if the blocks * aren't shared. COW I/O always takes precedent, so we must always @@ -265,7 +270,8 @@ xfs_map_blocks( isnullstartblock(imap.br_startblock)) goto allocate_blocks; - xfs_bmbt_to_iomap(ip, &wpc->iomap, &imap, 0, 0, XFS_WPC(wpc)->data_seq); + xfs_bmbt_to_iomap(ip, &wpc->iomap, &imap, 0, iomap_flags, + XFS_WPC(wpc)->data_seq); trace_xfs_map_blocks_found(ip, offset, count, whichfork, &imap); return 0; allocate_blocks: @@ -412,12 +418,16 @@ xfs_zoned_map_blocks( xfs_filblks_t count_fsb; struct xfs_bmbt_irec imap, del; struct xfs_iext_cursor icur; + u16 iomap_flags = 0; if (xfs_is_shutdown(mp)) return -EIO; XFS_ERRORTAG_DELAY(mp, XFS_ERRTAG_WB_DELAY_MS); + if (xfs_iflags_test(ip, XFS_VERITY_CONSTRUCTION)) + iomap_flags |= IOMAP_F_FSVERITY; + /* * All dirty data must be covered by delalloc extents. But truncate can * remove delalloc extents underneath us or reduce their size. @@ -441,7 +451,7 @@ xfs_zoned_map_blocks( imap.br_startblock = HOLESTARTBLOCK; imap.br_state = XFS_EXT_NORM; xfs_iunlock(ip, XFS_ILOCK_EXCL); - xfs_bmbt_to_iomap(ip, &wpc->iomap, &imap, 0, 0, 0); + xfs_bmbt_to_iomap(ip, &wpc->iomap, &imap, 0, iomap_flags, 0); return 0; } end_fsb = min(end_fsb, imap.br_startoff + imap.br_blockcount); @@ -454,7 +464,7 @@ xfs_zoned_map_blocks( xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iomap_set_anon_write(ip, &wpc->iomap, offset, - XFS_FSB_TO_B(mp, count_fsb)); + XFS_FSB_TO_B(mp, count_fsb), iomap_flags); trace_xfs_zoned_map_blocks(ip, offset, wpc->iomap.length); return 0; } @@ -507,6 +517,22 @@ static const struct iomap_writeback_ops xfs_zoned_writeback_ops = { .writeback_submit = xfs_zoned_writeback_submit, }; +static int +xfs_iomap_writepages( + struct xfs_inode *ip, + struct iomap_writepage_ctx *ctx) +{ + /* + * Writeback does not work for folios past EOF, let it know that + * I/O happens for fsverity metadata and this restriction need + * to be skipped + */ + if (xfs_iflags_test(ip, XFS_VERITY_CONSTRUCTION)) + ctx->iomap.flags |= IOMAP_F_FSVERITY; + + return iomap_writepages(ctx); +} + STATIC int xfs_vm_writepages( struct address_space *mapping, @@ -526,7 +552,7 @@ xfs_vm_writepages( }; int error; - error = iomap_writepages(&xc.ctx); + error = xfs_iomap_writepages(ip, &xc.ctx); if (xc.open_zone) xfs_open_zone_put(xc.open_zone); return error; @@ -539,7 +565,7 @@ xfs_vm_writepages( }, }; - return iomap_writepages(&wpc.ctx); + return xfs_iomap_writepages(ip, &wpc.ctx); } } diff --git a/fs/xfs/xfs_fsverity.c b/fs/xfs/xfs_fsverity.c new file mode 100644 index 000000000000..e30021c22683 --- /dev/null +++ b/fs/xfs/xfs_fsverity.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2026 Red Hat, Inc. + */ +#include "xfs_platform.h" +#include "xfs_fs.h" +#include "xfs_shared.h" +#include "xfs_format.h" +#include "xfs_log_format.h" +#include "xfs_trans_resv.h" +#include "xfs_mount.h" +#include "xfs_inode.h" +#include "xfs_fsverity.h" +#include +#include + +loff_t +xfs_fsverity_metadata_offset( + const struct xfs_inode *ip) +{ + return round_up(i_size_read(VFS_IC(ip)), XFS_FSVERITY_START_ALIGN); +} diff --git a/fs/xfs/xfs_fsverity.h b/fs/xfs/xfs_fsverity.h new file mode 100644 index 000000000000..c2ab5af89370 --- /dev/null +++ b/fs/xfs/xfs_fsverity.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2026 Red Hat, Inc. + */ +#ifndef __XFS_FSVERITY_H__ +#define __XFS_FSVERITY_H__ + +#include "xfs_platform.h" + +#ifdef CONFIG_FS_VERITY +loff_t xfs_fsverity_metadata_offset(const struct xfs_inode *ip); +#else +static inline loff_t xfs_fsverity_metadata_offset(const struct xfs_inode *ip) +{ + WARN_ON_ONCE(1); + return ULLONG_MAX; +} +#endif /* CONFIG_FS_VERITY */ + +#endif /* __XFS_FSVERITY_H__ */ diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 1602027cd0aa..af5ced6997e8 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -419,6 +419,12 @@ static inline bool xfs_inode_can_sw_atomic_write(const struct xfs_inode *ip) */ #define XFS_IREMAPPING (1U << 15) +/* + * fs-verity's Merkle tree is under construction. The file is read-only, the + * only writes happening are for the fsverity metadata. + */ +#define XFS_VERITY_CONSTRUCTION (1U << 16) + /* All inode state flags related to inode reclaim. */ #define XFS_ALL_IRECLAIM_FLAGS (XFS_IRECLAIMABLE | \ XFS_IRECLAIM | \ diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 7c6238fed61e..ccc8b8fabab3 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -32,6 +32,8 @@ #include "xfs_rtbitmap.h" #include "xfs_icache.h" #include "xfs_zone_alloc.h" +#include "xfs_fsverity.h" +#include #define XFS_ALLOC_ALIGN(mp, off) \ (((off) >> mp->m_allocsize_log) << mp->m_allocsize_log) @@ -883,6 +885,9 @@ xfs_direct_write_iomap_begin( if (flags & IOMAP_ATOMIC) iomap_flags |= IOMAP_F_ATOMIC_BIO; + if (xfs_iflags_test(ip, XFS_VERITY_CONSTRUCTION)) + iomap_flags |= IOMAP_F_FSVERITY; + /* * COW writes may allocate delalloc space or convert unwritten COW * extents, so we need to make sure to take the lock exclusively here. @@ -1023,7 +1028,8 @@ xfs_direct_write_iomap_begin( trace_xfs_iomap_found(ip, offset, length - offset, XFS_COW_FORK, &cmap); if (imap.br_startblock != HOLESTARTBLOCK) { seq = xfs_iomap_inode_sequence(ip, 0); - error = xfs_bmbt_to_iomap(ip, srcmap, &imap, flags, 0, seq); + error = xfs_bmbt_to_iomap(ip, srcmap, &imap, flags, + iomap_flags & IOMAP_F_FSVERITY, seq); if (error) goto out_unlock; } @@ -1083,7 +1089,7 @@ xfs_zoned_direct_write_iomap_begin( return error; } - xfs_iomap_set_anon_write(ip, iomap, offset, length); + xfs_iomap_set_anon_write(ip, iomap, offset, length, 0); return 0; } @@ -1595,7 +1601,8 @@ xfs_zoned_buffered_write_iomap_begin( loff_t count, unsigned flags, struct iomap *iomap, - struct iomap *srcmap) + struct iomap *srcmap, + u16 iomap_flags) { struct iomap_iter *iter = container_of(iomap, struct iomap_iter, iomap); @@ -1605,7 +1612,6 @@ xfs_zoned_buffered_write_iomap_begin( struct xfs_mount *mp = ip->i_mount; xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); xfs_fileoff_t end_fsb = xfs_iomap_end_fsb(mp, offset, count); - u16 iomap_flags = IOMAP_F_SHARED; unsigned int lockmode = XFS_ILOCK_EXCL; xfs_filblks_t count_fsb; xfs_extlen_t indlen; @@ -1668,7 +1674,8 @@ xfs_zoned_buffered_write_iomap_begin( smap.br_startoff + smap.br_blockcount); xfs_trim_extent(&smap, offset_fsb, end_fsb - offset_fsb); - error = xfs_bmbt_to_iomap(ip, srcmap, &smap, flags, 0, + error = xfs_bmbt_to_iomap(ip, srcmap, &smap, flags, + iomap_flags, xfs_iomap_inode_sequence(ip, 0)); if (error) goto out_unlock; @@ -1678,6 +1685,8 @@ xfs_zoned_buffered_write_iomap_begin( if (!ip->i_cowfp) xfs_ifork_init_cow(ip); + iomap_flags |= IOMAP_F_SHARED; + if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &got)) got.br_startoff = end_fsb; if (got.br_startoff <= offset_fsb) { @@ -1809,9 +1818,12 @@ xfs_buffered_write_iomap_begin( if (xfs_is_shutdown(mp)) return -EIO; + if (xfs_iflags_test(ip, XFS_VERITY_CONSTRUCTION)) + iomap_flags |= IOMAP_F_FSVERITY; + if (xfs_is_zoned_inode(ip)) return xfs_zoned_buffered_write_iomap_begin(inode, offset, - count, flags, iomap, srcmap); + count, flags, iomap, srcmap, iomap_flags); /* we can't use delayed allocations when using extent size hints */ if (xfs_get_extsz_hint(ip)) @@ -2095,7 +2107,8 @@ xfs_buffered_write_iomap_begin( found_cow: if (imap.br_startoff <= offset_fsb) { - error = xfs_bmbt_to_iomap(ip, srcmap, &imap, flags, 0, + error = xfs_bmbt_to_iomap(ip, srcmap, &imap, flags, + iomap_flags & IOMAP_F_FSVERITY, xfs_iomap_inode_sequence(ip, 0)); if (error) goto out_unlock; @@ -2199,12 +2212,17 @@ xfs_read_iomap_begin( bool shared = false; unsigned int lockmode = XFS_ILOCK_SHARED; u64 seq; + unsigned int iomap_flags = 0; ASSERT(!(flags & (IOMAP_WRITE | IOMAP_ZERO))); if (xfs_is_shutdown(mp)) return -EIO; + if (fsverity_active(inode) && + (offset >= xfs_fsverity_metadata_offset(ip))) + iomap_flags |= IOMAP_F_FSVERITY; + error = xfs_ilock_for_iomap(ip, flags, &lockmode); if (error) return error; @@ -2218,8 +2236,9 @@ xfs_read_iomap_begin( if (error) return error; trace_xfs_iomap_found(ip, offset, length, XFS_DATA_FORK, &imap); - return xfs_bmbt_to_iomap(ip, iomap, &imap, flags, - shared ? IOMAP_F_SHARED : 0, seq); + iomap_flags |= shared ? IOMAP_F_SHARED : 0; + + return xfs_bmbt_to_iomap(ip, iomap, &imap, flags, iomap_flags, seq); } static DEFINE_IOMAP_ITER_NEXT(xfs_read_iomap_next, xfs_read_iomap_begin); diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h index f2520a9b3a13..d3ca0f2afc9f 100644 --- a/fs/xfs/xfs_iomap.h +++ b/fs/xfs/xfs_iomap.h @@ -34,13 +34,14 @@ xfs_iomap_set_anon_write( struct xfs_inode *ip, struct iomap *iomap, loff_t offset, - loff_t length) + loff_t length, + u16 iomap_flags) { iomap->type = IOMAP_MAPPED; iomap->bdev = ip->i_mount->m_rtdev_targp->bt_bdev; iomap->offset = offset; iomap->length = length; - iomap->flags = IOMAP_F_ANON_WRITE | IOMAP_F_DIRTY; + iomap->flags = iomap_flags | IOMAP_F_ANON_WRITE | IOMAP_F_DIRTY; if (bdev_has_integrity_csum(iomap->bdev)) iomap->flags |= IOMAP_F_INTEGRITY; } From patchwork Fri Oct 2 12:36:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SgWjCDUP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=itst=hy=vger.kernel.org=linux-ext4+bounces-19953-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxP2s5Jxgz1xvt for ; Sat, 03 Oct 2026 08:43:49 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxP2F0k9Bz4w0Q for ; Sat, 03 Oct 2026 08:43:17 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxP2F0ggxz4w9T; Sat, 03 Oct 2026 08:43:17 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c0a:e001:db::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980997; cv=pass; b=kC7EjsMJss3WoBXmM7yp/9wrAcnixUXdt8thbVfu3uenNxtwOx2HDViCgXNv5w4RrckKp7YyaDBASjRNA4Em7+U3DTyL4uD3eDtn86giY8av+KawbSwSbPG6LU+f/5I7peKv+zrbpSD7scbIKEKOP+7CC0lihdWA1z1E7+oNncvmQ8RO9A8fQVBKVKcQTIRyJc13opMOXu08B4tNh2ZiXLycfxtcR8HnPFJHLET9jeY9Fr+OIW+GbjUd1aBqZKfryb8PkvuviOCP7PZGUp06pPzF+P6ixs2IuFOM2sn24ULuZVQg6ZsiMTPRXVTUDmGjABDyKohILkF/pAV4W2cW7w== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980997; c=relaxed/relaxed; bh=ioSMxM3XsVn6ilFgBGbSjQd+ABy2K7sVn2gY80y7yTA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=xeewuR/ULonI7wgr4SM7YWOK5T3ZZHM4OX3KSxUrHc00JTNwiRQZ/9U0KF4begPabupmOdyVrKK1wZtPGpGnoU7hWVWqgFCLjvChGpkaVzmQltM3ZbNvOcax1xezhtbVtEF/bP85vRBN55uffTHJAoHA6nmMvEftbyU4d32D9NJDR30fsm4pPg/Rz15oqSlj1WaXLH9WpySS07NZ/rYLcGTPM3l3rKHzqSmFfgUrfCctsVH4fOaUczzJ52rChFWXl4B3TiA54UAx0s+H02W34C35nH0Wy4M6ZnDOPiOmq2nJ9Gg+xwnae9i9Kq52//w25XPlUDP+fBeC0w3HxzuXmA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SgWjCDUP; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19953-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SgWjCDUP; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19953-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [IPv6:2600:3c0a:e001:db::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxP292XrQz4w0Q for ; Sat, 03 Oct 2026 08:43:13 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 2B04260A18 for ; Fri, 2 Oct 2026 22:37:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9CF9411A03; Fri, 2 Oct 2026 22:37:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SgWjCDUP" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 1DE823C4555; Fri, 2 Oct 2026 22:37:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980676; cv=none; b=gjtZkzxnDmINhbl3uu2b/Kmmvcqm7MtHq2Cb98/dDnQeYAyJGLk4tJMmNpKuE1OuSy/mXx1TFs62YkTuo5w6yTfvfU0/mU85YJG8yQdUXxdbSTDRYolO0T8MmFX1SzIl9IUl98PMwaioIbP4HoCSZBLiI6ExK140xulzqgCH+s8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980676; c=relaxed/simple; bh=V9LsR+xUxqfxtRUI5SQXStQEBBgTlyjr2YvBEYvMV7U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QWFVV+vTcmg7f8FNM4JdYjGUJZSn41+B/RZJoaJYPJ1cq5Qtoz8JRFNTiDBt8rj23UvLsiBreDg0jdLSUD+gEHotYU3pgQCkJNuZootXpdnqXs4OvsEKXGJaqRxGp6JfNuwJDWY7LdhZXx3s+jqM9A4HdqCfWCLXlTi6Af0sb64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SgWjCDUP; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B7A41F000FF; Fri, 2 Oct 2026 22:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980675; bh=ioSMxM3XsVn6ilFgBGbSjQd+ABy2K7sVn2gY80y7yTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SgWjCDUPJGcoAgBBi20AW1gv2/oEwxzI0aiujc52M6AU8Erlfz1Z3dRXv7j0D9LcV u1nH3aPQFShm9rGun02VYmatrtDPg1TRTp7ZHSNGKftrO1XOAHeME66fF52k0n/ie0 0NZclbs3zsf/2Xg66eRe3bSlUzH3ZJwCtDedvlPAH5FmM5ZdmXOz8kXfv5Og/k0z9y 5PbPaU9Unm0lRmzSPXwvq4h39Xsi3wn1hLl/xoOQY4JYEYUEOhQDwQaMFeyvkR/ySh jvtglcAMi9b8PzT1W1mJ+0KWosTO8vdQ+QZhBxfdHP2KdtCtjnnzMPrnszRC89LOGR qvwckEQR/8NXw== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 12/21] xfs: use read ioend for fsverity data verification Date: Sat, 3 Oct 2026 00:36:53 +0200 Message-ID: <20261002223705.2175542-13-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org Use read ioends for fsverity verification. Do not issue fsverity metadata I/O through the same workqueue due to risk of a deadlock by a filled workqueue. Pass fsverity_info from iomap context down to the ioend as hashtable lookups are expensive. Add a simple helper to check that this is not fsverity metadata but file data that needs verification. Signed-off-by: Andrey Albershteyn --- fs/xfs/xfs_aops.c | 13 +++++++---- fs/xfs/xfs_file.c | 3 ++- fs/xfs/xfs_fsverity.c | 31 +++++++++++++++++++++++++ fs/xfs/xfs_fsverity.h | 25 ++++++++++++++++++++ fs/xfs/xfs_ioend.c | 53 ++++++++++++++++++++++++++++++++++++++----- fs/xfs/xfs_ioend.h | 4 +++- fs/xfs/xfs_super.c | 24 +++++++++++++++++++- 7 files changed, 139 insertions(+), 14 deletions(-) diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 19640e4e3ed1..a36f840884b4 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -24,6 +24,7 @@ #include "xfs_zone_alloc.h" #include "xfs_rtgroup.h" #include "xfs_fsverity.h" +#include struct xfs_writepage_ctx { struct iomap_writepage_ctx ctx; @@ -611,7 +612,7 @@ xfs_bio_submit_read( { xfs_ioend_submit_read(iter->inode, ctx->read_ctx, ctx->read_ctx_file_offset, - iomap_ioend_flags(&iter->iomap)); + iomap_ioend_flags(&iter->iomap), ctx->vi); ctx->read_ctx = NULL; } @@ -623,11 +624,13 @@ static const struct iomap_read_ops xfs_iomap_read_ops = { static inline const struct iomap_read_ops * xfs_get_iomap_read_ops( - const struct address_space *mapping) + const struct address_space *mapping, + loff_t pos) { struct xfs_inode *ip = XFS_I(mapping->host); - if (bdev_has_integrity_csum(xfs_inode_buftarg(ip)->bt_bdev)) + if (bdev_has_integrity_csum(xfs_inode_buftarg(ip)->bt_bdev) || + xfs_fsverity_is_file_data(ip, pos)) return &xfs_iomap_read_ops; return &iomap_bio_read_ops; } @@ -639,7 +642,7 @@ xfs_vm_read_folio( { struct iomap_read_folio_ctx ctx = { .cur_folio = folio }; - ctx.ops = xfs_get_iomap_read_ops(folio->mapping); + ctx.ops = xfs_get_iomap_read_ops(folio->mapping, folio_pos(folio)); iomap_read_folio(&xfs_read_iomap_ops, &ctx, NULL); return 0; } @@ -650,7 +653,7 @@ xfs_vm_readahead( { struct iomap_read_folio_ctx ctx = { .rac = rac }; - ctx.ops = xfs_get_iomap_read_ops(rac->mapping), + ctx.ops = xfs_get_iomap_read_ops(rac->mapping, readahead_pos(rac)); iomap_readahead(&xfs_read_iomap_ops, &ctx, NULL); } diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 07abf6e8783f..578ca6fb8292 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -225,7 +225,8 @@ xfs_dio_read_bounce_submit_io( loff_t file_offset) { xfs_ioend_submit_read(iter->inode, bio, file_offset, - iomap_ioend_flags(&iter->iomap) | IOMAP_IOEND_DIRECT); + iomap_ioend_flags(&iter->iomap) | IOMAP_IOEND_DIRECT, + NULL); } static const struct iomap_dio_ops xfs_dio_read_bounce_ops = { diff --git a/fs/xfs/xfs_fsverity.c b/fs/xfs/xfs_fsverity.c index e30021c22683..976e05257bf9 100644 --- a/fs/xfs/xfs_fsverity.c +++ b/fs/xfs/xfs_fsverity.c @@ -14,9 +14,40 @@ #include #include +struct kmem_cache *xfs_fsverity_ioend_cache; +mempool_t xfs_fsverity_ioend_pool; + +#define XFS_FSVERITY_IOEND_POOL_MIN 128 + +/* + * Back the fsverity ioend allocations with a mempool so that read I/O + * completion always makes forward progress and cannot deadlock + */ +int +xfs_fsverity_init(void) +{ + return mempool_init_slab_pool(&xfs_fsverity_ioend_pool, + XFS_FSVERITY_IOEND_POOL_MIN, xfs_fsverity_ioend_cache); +} + +void +xfs_fsverity_exit(void) +{ + mempool_exit(&xfs_fsverity_ioend_pool); +} + loff_t xfs_fsverity_metadata_offset( const struct xfs_inode *ip) { return round_up(i_size_read(VFS_IC(ip)), XFS_FSVERITY_START_ALIGN); } + +bool +xfs_fsverity_is_file_data( + const struct xfs_inode *ip, + loff_t offset) +{ + return fsverity_active(VFS_IC(ip)) && + offset < xfs_fsverity_metadata_offset(ip); +} diff --git a/fs/xfs/xfs_fsverity.h b/fs/xfs/xfs_fsverity.h index c2ab5af89370..01269a828fc0 100644 --- a/fs/xfs/xfs_fsverity.h +++ b/fs/xfs/xfs_fsverity.h @@ -6,15 +6,40 @@ #define __XFS_FSVERITY_H__ #include "xfs_platform.h" +#include +#include #ifdef CONFIG_FS_VERITY +int xfs_fsverity_init(void); +void xfs_fsverity_exit(void); loff_t xfs_fsverity_metadata_offset(const struct xfs_inode *ip); +bool xfs_fsverity_is_file_data(const struct xfs_inode *ip, loff_t offset); #else +static inline int xfs_fsverity_init(void) +{ + return 0; +} +static inline void xfs_fsverity_exit(void) +{ +} static inline loff_t xfs_fsverity_metadata_offset(const struct xfs_inode *ip) { WARN_ON_ONCE(1); return ULLONG_MAX; } +static inline bool xfs_fsverity_is_file_data(const struct xfs_inode *ip, + loff_t offset) +{ + return false; +} #endif /* CONFIG_FS_VERITY */ +struct xfs_fsverity_ioend { + struct iomap_ioend *ioend; + struct work_struct work; +}; + +extern struct kmem_cache *xfs_fsverity_ioend_cache; +extern mempool_t xfs_fsverity_ioend_pool; + #endif /* __XFS_FSVERITY_H__ */ diff --git a/fs/xfs/xfs_ioend.c b/fs/xfs/xfs_ioend.c index e70be5b86f0b..f4c1bbc03714 100644 --- a/fs/xfs/xfs_ioend.c +++ b/fs/xfs/xfs_ioend.c @@ -18,7 +18,26 @@ #include "xfs_ioend.h" #include "xfs_error.h" #include "xfs_errortag.h" +#include "xfs_fsverity.h" #include +#include + +static void +xfs_end_fsverity_io_read( + struct work_struct *work) +{ + struct xfs_fsverity_ioend *fsv_ioend = + container_of(work, struct xfs_fsverity_ioend, work); + struct iomap_ioend *ioend = fsv_ioend->ioend; + struct bio *bio = &ioend->io_bio; + + mempool_free(fsv_ioend, &xfs_fsverity_ioend_pool); + + if (!bio->bi_status) + fsverity_verify_bio(ioend->io_vi, bio); + + iomap_finish_ioends(ioend, blk_status_to_errno(bio->bi_status)); +} static void xfs_dio_bounce_end_io( @@ -93,12 +112,14 @@ xfs_read_bounce_and_resubmit( static void xfs_end_io_read( - struct bio *bio) + struct bio *bio) { - struct iomap_ioend *ioend = iomap_ioend_from_bio(bio); - struct xfs_inode *ip = XFS_I(ioend->io_inode); - struct xfs_mount *mp = ip->i_mount; - int error = blk_status_to_errno(bio->bi_status); + struct iomap_ioend *ioend = iomap_ioend_from_bio(bio); + struct xfs_inode *ip = XFS_I(ioend->io_inode); + struct xfs_mount *mp = ip->i_mount; + int error = + blk_status_to_errno(bio->bi_status); + struct xfs_fsverity_ioend *fsv_ioend; if (!error && (ioend->io_flags & IOMAP_IOEND_INTEGRITY)) { error = iomap_ioend_integrity_verify(ioend); @@ -117,6 +138,24 @@ xfs_end_io_read( } } + /* + * If we have fsverity on this bio, we need to run fsverity verification + * of data folios from a separate fsverity workqueue. This is necessary + * to avoid deadlocking due to fsverity issuing more reads of fsverity + * metadata which would be processed by the same worker in the BIO + * completion workqueue. + */ + if (IS_ENABLED(CONFIG_FS_VERITY) && !error && ioend->io_vi && + xfs_fsverity_is_file_data(ip, ioend->io_offset)) { + fsv_ioend = mempool_alloc(&xfs_fsverity_ioend_pool, + GFP_NOFS); + fsv_ioend->ioend = ioend; + INIT_WORK(&fsv_ioend->work, xfs_end_fsverity_io_read); + + fsverity_enqueue_verify_work(&fsv_ioend->work); + return; + } + iomap_finish_ioends(ioend, error); } @@ -125,13 +164,15 @@ xfs_ioend_submit_read( struct inode *inode, struct bio *bio, loff_t file_offset, - u16 ioend_flags) + u16 ioend_flags, + struct fsverity_info *vi) { struct xfs_inode *ip = XFS_I(inode); struct xfs_mount *mp = ip->i_mount; struct iomap_ioend *ioend; ioend = iomap_init_ioend(inode, bio, file_offset, ioend_flags); + ioend->io_vi = vi; if ((ioend_flags & IOMAP_IOEND_DIRECT) && READ_ONCE(mp->m_read_bounce) == XFS_READ_BOUNCE_ALWAYS) { iomap_bounce_read(ioend, bdev_logical_block_size(bio->bi_bdev), diff --git a/fs/xfs/xfs_ioend.h b/fs/xfs/xfs_ioend.h index 7c2a1ea3e6ed..992c248a693a 100644 --- a/fs/xfs/xfs_ioend.h +++ b/fs/xfs/xfs_ioend.h @@ -2,6 +2,8 @@ #ifndef __XFS_IOEND_H #define __XFS_IOEND_H +#include + /* * Fast and loose check if this write could update the on-disk inode size. */ @@ -13,6 +15,6 @@ static inline bool xfs_ioend_is_append(struct iomap_ioend *ioend) void xfs_end_bio(struct bio *bio); void xfs_ioend_submit_read(struct inode *inode, struct bio *bio, - loff_t file_offset, u16 ioend_flags); + loff_t file_offset, u16 ioend_flags, struct fsverity_info *vi); #endif /* __XFS_IOEND_H */ diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index fce1d2905c94..7a8d071dbe56 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -2516,8 +2516,20 @@ xfs_init_caches(void) if (!xfs_parent_args_cache) goto out_destroy_xmi_cache; +#ifdef CONFIG_FS_VERITY + xfs_fsverity_ioend_cache = kmem_cache_create("xfs_fsverity_ioend", + sizeof(struct xfs_fsverity_ioend), + 0, 0, NULL); + if (!xfs_fsverity_ioend_cache) + goto out_destroy_parent_args_cache; +#endif + return 0; +#ifdef CONFIG_FS_VERITY + out_destroy_parent_args_cache: + kmem_cache_destroy(xfs_parent_args_cache); +#endif out_destroy_xmi_cache: kmem_cache_destroy(xfs_xmi_cache); out_destroy_xmd_cache: @@ -2580,6 +2592,9 @@ xfs_destroy_caches(void) * destroy caches. */ rcu_barrier(); +#ifdef CONFIG_FS_VERITY + kmem_cache_destroy(xfs_fsverity_ioend_cache); +#endif kmem_cache_destroy(xfs_parent_args_cache); kmem_cache_destroy(xfs_xmd_cache); kmem_cache_destroy(xfs_xmi_cache); @@ -2660,10 +2675,14 @@ init_xfs_fs(void) if (error) goto out; - error = xfs_init_workqueues(); + error = xfs_fsverity_init(); if (error) goto out_destroy_caches; + error = xfs_init_workqueues(); + if (error) + goto out_fsverity_exit; + error = xfs_mru_cache_init(); if (error) goto out_destroy_wq; @@ -2740,6 +2759,8 @@ init_xfs_fs(void) xfs_mru_cache_uninit(); out_destroy_wq: xfs_destroy_workqueues(); + out_fsverity_exit: + xfs_fsverity_exit(); out_destroy_caches: xfs_destroy_caches(); out: @@ -2763,6 +2784,7 @@ exit_xfs_fs(void) xfs_cleanup_procfs(); xfs_mru_cache_uninit(); xfs_destroy_workqueues(); + xfs_fsverity_exit(); xfs_destroy_caches(); xfs_uuid_table_free(); } From patchwork Fri Oct 2 12:36:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315397 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ONU7QUY3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=hu5s=hy=vger.kernel.org=linux-ext4+bounces-19954-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNxW1b7rz1xyX for ; Sat, 03 Oct 2026 08:39:11 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNwt4Bbsz4w1S for ; Sat, 03 Oct 2026 08:38:38 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNwt47gWz4w9g; Sat, 03 Oct 2026 08:38:38 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c04:e001:36c::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980718; cv=pass; b=NmobFxbSkBZ51P8HjoHvsXlNPTdaHBr6E24uUxVgw4a9pZfceEd94uckD0MuEjCqHcq32Yk3ZmIyaSd4tb7mOrzK7zBJlrb3KOzb9CzDf2YobWcxdjWf98ZA4Ij7LgwzWrcqvHLNh4JXUEzguET4p5ZFcZpbwBHz6Sp9hRj7ZEtdryipTC/X1/SkF1Z5AymcroyJeWc/dmders9LnUpVT5M29Bia3Ygp2o7tIEgkt5hA9pL/YcpR/sAGjjTDcesZohC9LZDj9xf7dlg+gTHEZEyvu9ncewdIEznGvGUYmIW0nbtccQDoOvqy/y1sNMh6cTyDdetz0XYgl3qcXVEY8Q== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980718; c=relaxed/relaxed; bh=aAXU3AobDu5QtwLxj6kfPLMsQwMacpv2rFmEyWNfcHY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D2pPrjA1JGDPFmZsIcqaL624RRoEsDf0Nx+10tUIMBv1gkvoEVVBw2lANrHHsK74IXV+Alq/o2MIaNF3VLqIJsx/7StANvQe8kh/4UPNMzzP+B8l7i1crdQ4OOMBwuB5saO1cjGJCk0gZ58DcfMMfLyqOJFcOWtzuRGqPLp1ScAofZm50Dl5kp5yav9y7dyNGuOLGiI9A2pV81pFgW34Evsp9bciWNJgL4ImaZW5Y/QR1AGfggT+nyHwd4OqWqjK3SDwq+1U8DwfRN+Uh5WrM8juBcEu2t9gQBxkhIWRY5QtQg3anxbToVLw9ptvRzVtxS0mcd1+Sng2tXvIEGfbiw== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ONU7QUY3; dkim-atps=neutral; spf=pass (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19954-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ONU7QUY3; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19954-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from tor.lore.kernel.org (tor.lore.kernel.org [IPv6:2600:3c04:e001:36c::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNwq0fj9z4w1S for ; Sat, 03 Oct 2026 08:38:35 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 899CF30B8F for ; Fri, 2 Oct 2026 22:38:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6813146C83D; Fri, 2 Oct 2026 22:38:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ONU7QUY3" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E65823C4555; Fri, 2 Oct 2026 22:37:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980680; cv=none; b=qEKqXLtIqYv185tsHj24roqx3V4rOFIXiJYsdX+MAovISqA7+kJwS5F4CYZ+Q5XNw8xrgn9Q7fG9aZz4OcICeSJ9QjbF5+I9uXzbtAbK43a/yoHraJX9ChDskupoS6b7xYazX3M/8DeUXi/etCqKOXBHzVRFW+1/YxMMAJrsU6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980680; c=relaxed/simple; bh=y+uj4hLo41KsmlJYth0ubMz10AxJigq0sof3plHv6qI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pMTIyAQJv/VEq00P0taCAllvPdjkb8jyR3rvsXrhJwXG362o8LLDMwtfNX4ibMWEcO4c87FDAG1ALVD3mv5vJKCp3HUEzcw/cg2UGM67TLwO56G5TlR3DdCaBd+oeyGbg1y2V4K/Vg9Jy3IiBZGwYK6JFHjIDgKnwEG6IhzCJGA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ONU7QUY3; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 800FB1F00898; Fri, 2 Oct 2026 22:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980678; bh=aAXU3AobDu5QtwLxj6kfPLMsQwMacpv2rFmEyWNfcHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ONU7QUY39Iqo4VNtD3neA0lRuGuW+5hkdI0Sm+F3jR2/Fq1xzsCy4uTZUx/Z/gmiZ Z05ApZbFgH3J8BS/t005BwdVwRv9Sl9g9F5Xw9ARv9GjnfDc82PkZQStI8Z70hNb0k wm2gMKCSPc9ouzyoc+cGwSMZEJGDNfvLhWn9xztCE1rdMyWmSJy2zX0ChdrtUiLDwY PV2eOY38JL0NIe69I2A8WES8eTCQl+1F7IXvmLNaZB4inkTszFU99qAet5MprsKC5C GjmAb6usLkcehbe2hE4x7bimPMvWodr1DBoFcuXqVumRjBekYzwgoclWdxwvw8a4Yl xZ6UcYVVeXZZg== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 13/21] xfs: add XFS_BMAPI_UNWRITTEN to unmap unwritten extents in __xfs_bunmapi() Date: Sat, 3 Oct 2026 00:36:54 +0200 Message-ID: <20261002223705.2175542-14-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org The __xfs_bunmapi() is used to remove all extents past EOF. Add XFS_BMAPI_UNWRITTEN to remove only unwritten extents, while leaving written ones in place. This will be used in following patch to clean up unwritten extents on fsverity inodes. Signed-off-by: Andrey Albershteyn Reviewed-by: "Darrick J. Wong" --- fs/xfs/libxfs/xfs_bmap.c | 6 +++++- fs/xfs/libxfs/xfs_bmap.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 9dc96a4edea6..6f0094445cea 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5278,6 +5278,10 @@ __xfs_bunmapi( if (del.br_startoff + del.br_blockcount > end + 1) del.br_blockcount = end + 1 - del.br_startoff; + if ((flags & XFS_BMAPI_UNWRITTEN) && + del.br_state != XFS_EXT_UNWRITTEN) + goto skip; + if (!isrt || (flags & XFS_BMAPI_REMAP)) goto delete; @@ -5412,7 +5416,7 @@ __xfs_bunmapi( if (error) goto error0; } - +skip: end = del.br_startoff - 1; nodelete: /* diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h index d5f2729305fa..0f36431d9936 100644 --- a/fs/xfs/libxfs/xfs_bmap.h +++ b/fs/xfs/libxfs/xfs_bmap.h @@ -90,6 +90,9 @@ struct xfs_bmalloca { /* Try to align allocations to the extent size hint */ #define XFS_BMAPI_EXTSZALIGN (1u << 11) +/* Process unwritten extents only. Used for unmapping */ +#define XFS_BMAPI_UNWRITTEN (1u << 12) + #define XFS_BMAPI_FLAGS \ { XFS_BMAPI_ENTIRE, "ENTIRE" }, \ { XFS_BMAPI_METADATA, "METADATA" }, \ @@ -102,7 +105,8 @@ struct xfs_bmalloca { { XFS_BMAPI_COWFORK, "COWFORK" }, \ { XFS_BMAPI_NODISCARD, "NODISCARD" }, \ { XFS_BMAPI_NORMAP, "NORMAP" },\ - { XFS_BMAPI_EXTSZALIGN, "EXTSZALIGN" } + { XFS_BMAPI_EXTSZALIGN, "EXTSZALIGN" }, \ + { XFS_BMAPI_UNWRITTEN, "UNWRITTEN" } static inline int xfs_bmapi_aflag(int w) From patchwork Fri Oct 2 12:36:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Nrpfpa71; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=6jgg=hy=vger.kernel.org=linux-ext4+bounces-19955-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNxr5Nxyz1xyX for ; Sat, 03 Oct 2026 08:39:28 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNxD0qqLz4w1S for ; Sat, 03 Oct 2026 08:38:56 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNxD0mG1z4w9g; Sat, 03 Oct 2026 08:38:56 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.105.105.114 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980736; cv=pass; b=rPqOd6omJ8s6yXRijYGdOB8DegO+QZN4Y+3cwamwWlxbYnt29IioQOIURS6qEOCdOR4Qv2REKvir4zWRhHYzdqivYna4oKhmQKDTfvYpEChvdcUG8USQ7quy2VfrHPAR8NcvoxDMU7IVS2wAF8tfFrQvqslzfe9enlTEDu6Ijik3D05ESyn3qvzSOON81g1ikYTXrkOZQ2eCU+3CKocpeacm4amopMNpZojYbOwFvMgJBw2cGoSqfMmc7fPpp3rzHZ7tZ5XtX+bqPS6G3pSaiqBsfwRfMdogUsIumWPzOAWQ8Yo21raZkuk3RDpKA6iUkAkM8z06mgbt+rsxMP+4qg== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980736; c=relaxed/relaxed; bh=xCYk0Gq6TJerMCtpjc/Alie0O8U64/7WPSND7e9qc2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qM04BkmD1r42hAuwEMgZqbB3R8mmnAdLAW3wmX1qZ9lObdZn8c4rWip32/QiXgTpjLtuTPsOwRkp+A2kikreAwDrNkfMGbgqqvtw/0UkogiesWzQ0ZfUfjgMPLuVdUrhINiTpyTWy+iK6fIQJvHxcVtTklWNHV2w7tgazzdAv2Mdn4T17P5qMAw8QIjRHSC7vufOj2sgcQoyovjRUGJT3GgZzCeb7NVpzeS758Djfy4QQkcPDilJ0MgCKzu0NqKbkPPnyvVBQHMFamXS2mjraoIopKtQYzLZ/qQVbq+dCz0mroyAnZXYNTaE4QdSrdudaaVSj7c+L6c/4BHIoxBz+A== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Nrpfpa71; dkim-atps=neutral; spf=pass (client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19955-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Nrpfpa71; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19955-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNx84XyYz4w1S for ; Sat, 03 Oct 2026 08:38:52 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 0358F34181 for ; Fri, 2 Oct 2026 22:38:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7232746D0B0; Fri, 2 Oct 2026 22:38:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Nrpfpa71" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 1DF1C3C4555; Fri, 2 Oct 2026 22:38:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980683; cv=none; b=EcanMRiaAL6oTJB54CqkmYpwumQZARNBArSUk1rR0CGf5+NEPIIa5ftGcQ5Tzr7I5Cpeh/vBfiXy5wJOIbFSGgtlzJH/ceFRu+sWD+IT6/yUUXeKLJ3sNoZlTlNvNlFJqZNlsRaoRAiXpL6jFdIbh8m/IEKlD/VQl+4/gv9i4hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980683; c=relaxed/simple; bh=6P2RDTfPU9YsVywTeFthZLxox/53khjwNChUqddXfoc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dRtg6Vet35ccCmURvBvD/DEne5oYj3oy3UR+JtZTzpBOFlr15KPLbG6nV7HQe2ZeFq33kTS2OTLXfNDjlipLlsSm4QNX/6OOdMHzwoeG3H0uWoBbNxDplhlS1Ax4rCNcTgBK5XN5FmvViyhC30xSPbO2U4NHQdMA3I7Sx0TCqPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nrpfpa71; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 094F71F000FF; Fri, 2 Oct 2026 22:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980682; bh=xCYk0Gq6TJerMCtpjc/Alie0O8U64/7WPSND7e9qc2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Nrpfpa71CSPmqBRx81HpMBjNKeXWnwvFTlU0cnTd0ZMl89Ysvgnw8hio9TsVPYUGC NnK2JUH8qruaOmXIFYHZ8afRmuLLG1wxC2PA+2iK+kc6Mx6+swNA966eDwu2xxfOVw VNK1ed/+qOdxLGHrC2MEGwOpglCMZQ5TL9jnPEFTGg3peZcB+zDSybxWE6YB6fC4oM gNhMBmz464TJKEjCZqjXgDg8RH+W53UX8Z8yH48BZoQrajXDS8osA3/tU2p2FJsxga +rCjavTFEULegNei+FmxslOeVwiRuvIngIoIjYxndJ3L0B1U+1CMRX1sKTe9c8tk4X cMVymZseBBr4A== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 14/21] xfs: don't remove written extents past EOF on fsverity inodes Date: Sat, 3 Oct 2026 00:36:55 +0200 Message-ID: <20261002223705.2175542-15-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org xfs_free_eofblocks() removes all extents past EOF unless the XFS_DIFLAG_PREALLOC or XFS_DIFLAG_APPEND flags are set. This is undesired for fsverity as it stores metadata beyond EOF. However, while merkle tree is being built, delayed preallocation and unwritten extents are used. After metadata construction is done, fsverity inodes becomes read-only and won't be changed anymore, none of these unwritten extents or preallocations in post EOF region will be used. Let xfs_free_eofblocks() be called on fsverity inode as usual to remove anything which is not written extent. However, inodes which are undergoing merkle tree construction need to be skipped in case reclaim takes place. Signed-off-by: Andrey Albershteyn Reviewed-by: "Darrick J. Wong" --- fs/xfs/xfs_bmap_util.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 268d159339d0..74e99d0bee7a 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -31,6 +31,7 @@ #include "xfs_rtbitmap.h" #include "xfs_rtgroup.h" #include "xfs_zone_alloc.h" +#include /* Kernel only BMAP related definitions and functions */ @@ -553,6 +554,15 @@ xfs_can_free_eofblocks( if (last_fsb <= end_fsb) return false; + /* + * Don't clean fsverity inodes as they already have been cleaned up and + * are read-only. Skip inodes which have merkle tree being built, the + * merkle tree is written beyond EOF + */ + if (fsverity_active(VFS_IC(ip)) || + xfs_iflags_test(ip, XFS_VERITY_CONSTRUCTION)) + return false; + /* * Check if there is an post-EOF extent to free. If there are any * delalloc blocks attached to the inode (data fork delalloc @@ -579,6 +589,9 @@ xfs_free_eofblocks( struct xfs_trans *tp; struct xfs_mount *mp = ip->i_mount; int error; + int bmapi_flags = XFS_BMAPI_NODISCARD; + bool has_verity = + ip->i_diflags2 & XFS_DIFLAG2_VERITY; /* Attach the dquots to the inode up front. */ error = xfs_qm_dqattach(ip); @@ -593,15 +606,20 @@ xfs_free_eofblocks( * * Note that this means we also leave speculative preallocations in * place for preallocated files. + * + * Clean up delalloc reservations for fsverity too as those won't be + * used */ - if (ip->i_diflags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) { + if (ip->i_diflags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND) || + has_verity) { if (ip->i_delayed_blks) { xfs_bmap_punch_delalloc_range(ip, XFS_DATA_FORK, round_up(XFS_ISIZE(ip), mp->m_sb.sb_blocksize), LLONG_MAX, NULL); } xfs_inode_clear_eofblocks_tag(ip); - return 0; + if (!has_verity) + return 0; } error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); @@ -613,6 +631,13 @@ xfs_free_eofblocks( xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, 0); + /* + * While fs-verity writes metadata after EOF, it can leave unwritten + * preallocations. Clear all that out. + */ + if (has_verity) + bmapi_flags |= XFS_BMAPI_UNWRITTEN; + /* * Do not update the on-disk file size. If we update the on-disk file * size and then the system crashes before the contents of the file are @@ -620,7 +645,7 @@ xfs_free_eofblocks( * bug). */ error = xfs_itruncate_extents_flags(&tp, ip, XFS_DATA_FORK, - XFS_ISIZE(ip), XFS_BMAPI_NODISCARD); + XFS_ISIZE(ip), bmapi_flags); if (error) goto err_cancel; From patchwork Fri Oct 2 12:36:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AVUy08NT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=ak69=hy=vger.kernel.org=linux-ext4+bounces-19956-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1 raw public key) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNxH0f9Lz1yDH for ; Sat, 03 Oct 2026 08:38:59 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNwf0KFXz4w9g for ; Sat, 03 Oct 2026 08:38:26 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNwf0Hs0z4wDJ; Sat, 03 Oct 2026 08:38:26 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=104.64.211.4 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980706; cv=pass; b=hQDnWN5RTBqsqddzab8zOC/pM99cW5EBl4xrPRZIqeVTYLJ8YRa/qC3Nh6mBx49j7kkkaStkkmZNN4wh6bCqJo0eYpSunK5qV3duPZ2JytVPvHTBCR1OYmShZd27ep5wCGYI+wlwvsVLkWkD9LeWpOM3yufYKvf/Q+5MfmNW/Zmo/WnoHGHSMxprUQ5VyyppR/WhTHK0EjCRkY8a3XV7LYZo9GfnN3i24nmbWWVTtqOA5kPcHeP+Rip53U7EPRQUzekZKlOIbb/jU1LZtzZvj2rNo8QiAxXLaEl0EdXfmLxnuHuH4ZX/rth2ZCkxNo9eXyu2E3loUp46lMiwHepv8g== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980706; c=relaxed/relaxed; bh=9Fbq8b8IpWQabaz6UJinxCtNy9ARbxv8N6/UciwExZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uxZXOocFqU+ay065e6xeGxMAzBNDwwmYMrAZ0POzqRGLh/OdcMbHGOpqg0M2MxExPVbVVdCzjvEUhAWfJWbGO3C75veoTRTc70IG7sp4Zpnc1WkCRNwq/fnvhMatBjrYS3WZdqvl/8xPryeWPfcY6d5tXPAmEKdpq20YU/21IcrnMOUNnKaNNS5vHj9QIDkP+roAaj9EI3FiZKsCiiJNfZXXYhaVUqJAOmGyRZfVNj/MZEJfvf01TcB0lTAn5dBoesSvbP/w7yBHzpZY9M9m0BQsxfbDJjzGor4EJCi+7nP/eMi9054X2QDnw5jAtloXhub4IBiGclRCMenJ3PsalA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AVUy08NT; dkim-atps=neutral; spf=pass (client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=linux-ext4+bounces-19956-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AVUy08NT; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=linux-ext4+bounces-19956-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNwW5bD3z4w1S for ; Sat, 03 Oct 2026 08:38:19 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id 284282C0EE for ; Fri, 2 Oct 2026 22:38:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C22C469826; Fri, 2 Oct 2026 22:38:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AVUy08NT" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 9678E3C4555; Fri, 2 Oct 2026 22:38:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980687; cv=none; b=CiwTDLMmgkl+iT1bnbCb0TrqkDknfLoOrCTzvNyEYgCl+7ZLdbSKM0+keyzWAWWLnhRn7n5wrlh8EwjadxfpHoBRKZysZj3FYLTLY4+rxQIQrlrZGViQGBtdutwEmYyuH/3agBcnYo2A/Fd/eg2qnPG2y8DXKJ5YKoqcFnndCyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980687; c=relaxed/simple; bh=WsY0P/diqqHlOpAlCDPYIxY16IxVkU34e4+58ZeduDs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r45vD9uyynm512aVrV1y9VUrWvrtOvBD1SeAADPN0GhNnN8ynBy/nncsZX5RNzzoeUgJcjqtz7xwqrwMgCn+NU+Rn+b24r2JDgjU9VmFjajfV8LTSIr7D0zG566kFkhRfrnWcPjyHwlz7mWMBEb60l9cra7E1QASBT6jl2o7Rv0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AVUy08NT; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82C161F00893; Fri, 2 Oct 2026 22:38:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980685; bh=9Fbq8b8IpWQabaz6UJinxCtNy9ARbxv8N6/UciwExZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AVUy08NTqCMEqoyYqkIV6fG+sMuvlNCAs/WHdaeQU12+EsG48t0bN7cuVScyhYlhK Hqf7lq/Ll6Vh1A0XruvTh8nCDvsI6hB+nbvwMqvA6PHXukLdmPpg2QL3qFs6ZC/qc+ 8G6rJC1yNexa4L+t5dEyiYkvELi8vphZ089aOFo5VDt5/u0RVY8je/94AxU7P6PeDF 0suuk+q8HFKNwTFjp59W4Wkn7xJ/zeCn6f7RxYXihK5Lysma8UV5ZcpGhsmT+ikD25 Wtr6MTM50IT+SSNyFhxWdMNYZh3SAmxTEXw7nUIBSUQsMzlaQ471K9kPBjmnGhaFhI j0wp3QXQ8owAw== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 15/21] xfs: add fs-verity support Date: Sat, 3 Oct 2026 00:36:56 +0200 Message-ID: <20261002223705.2175542-16-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org Add integration with fs-verity. XFS stores fs-verity descriptor and Merkle tree in the inode data fork at first block aligned to 64k past EOF. The Merkle tree reading/writing is done through iomap interface. The data itself is read to the inode's page cache. When XFS reads from this region iomap doesn't call into fsverity to verify it against Merkle tree. For data, verification is done at ioend completion in a workqueue. When fs-verity is enabled on an inode, the XFS_IVERITY_CONSTRUCTION flag is set meaning that the Merkle tree is being build. The initialization ends with storing of verity descriptor and setting inode on-disk flag (XFS_DIFLAG2_VERITY). Lastly, the XFS_IVERITY_CONSTRUCTION is dropped and I_VERITY is set on inode. The descriptor is stored in a new block aligned to 64k after the last Merkle tree block. The size of the descriptor is stored at the end of the last descriptor block (descriptor can be multiple blocks). Pro-actively remove any unwritten extents as we use last extent to locate descriptor. Signed-off-by: Andrey Albershteyn Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_fsverity.c | 425 +++++++++++++++++++++++++++++++++++++++++- fs/xfs/xfs_fsverity.h | 2 + fs/xfs/xfs_message.c | 4 + fs/xfs/xfs_message.h | 1 + fs/xfs/xfs_mount.h | 2 + fs/xfs/xfs_super.c | 7 + 6 files changed, 440 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_fsverity.c b/fs/xfs/xfs_fsverity.c index 976e05257bf9..8cffcafc19aa 100644 --- a/fs/xfs/xfs_fsverity.c +++ b/fs/xfs/xfs_fsverity.c @@ -6,13 +6,22 @@ #include "xfs_fs.h" #include "xfs_shared.h" #include "xfs_format.h" -#include "xfs_log_format.h" #include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_inode.h" +#include "xfs_log_format.h" +#include "xfs_trans.h" +#include "xfs_trace.h" +#include "xfs_quota.h" #include "xfs_fsverity.h" +#include "xfs_iomap.h" +#include "xfs_error.h" +#include "xfs_health.h" +#include "xfs_bmap_util.h" +#include "xfs_icache.h" #include #include +#include struct kmem_cache *xfs_fsverity_ioend_cache; mempool_t xfs_fsverity_ioend_pool; @@ -51,3 +60,417 @@ xfs_fsverity_is_file_data( return fsverity_active(VFS_IC(ip)) && offset < xfs_fsverity_metadata_offset(ip); } + +/* + * Retrieve the verity descriptor. + */ +static int +xfs_fsverity_get_descriptor( + struct inode *inode, + void *buf, + size_t buf_size) +{ + struct xfs_inode *ip = XFS_I(inode); + struct xfs_mount *mp = ip->i_mount; + __be32 d_desc_size; + u32 desc_size; + u64 desc_size_pos; + int error; + u64 desc_pos; + struct xfs_bmbt_irec rec; + int is_empty; + uint32_t blocksize = i_blocksize(VFS_I(ip)); + xfs_fileoff_t last_block_offset; + + xfs_ilock(ip, XFS_ILOCK_EXCL); + /* + * Serialize reading of inode->i_flags with xfs_scrub clearing of this + * flag if inode is corrupted. + */ + if (!(inode->i_flags & S_VERITY)) { + xfs_iunlock(ip, XFS_ILOCK_EXCL); + return -ENODATA; + } + error = xfs_bmap_last_extent(NULL, ip, XFS_DATA_FORK, &rec, &is_empty); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + if (error) + return error; + + if (is_empty) + return -ENODATA; + + last_block_offset = + XFS_FSB_TO_B(mp, rec.br_startoff + rec.br_blockcount); + if (last_block_offset <= xfs_fsverity_metadata_offset(ip)) + return -ENODATA; + + desc_size_pos = last_block_offset - sizeof(__be32); + error = fsverity_pagecache_read(inode, (char *)&d_desc_size, + sizeof(d_desc_size), desc_size_pos); + if (error) + return error; + + desc_size = be32_to_cpu(d_desc_size); + if (XFS_IS_CORRUPT(mp, desc_size > FS_VERITY_MAX_DESCRIPTOR_SIZE)) + return -ERANGE; + if (XFS_IS_CORRUPT(mp, desc_size > desc_size_pos)) + return -ERANGE; + + if (!buf_size) + return desc_size; + + if (XFS_IS_CORRUPT(mp, desc_size > buf_size)) + return -ERANGE; + + desc_pos = round_down(desc_size_pos - desc_size, blocksize); + if (desc_pos < xfs_fsverity_metadata_offset(ip)) + return -ERANGE; + + error = fsverity_pagecache_read(inode, buf, desc_size, desc_pos); + if (error) + return error; + + return desc_size; +} + +static int +xfs_fsverity_write_descriptor( + struct file *file, + const void *desc, + u32 desc_size, + u64 merkle_tree_size) +{ + int error; + struct inode *inode = file_inode(file); + struct xfs_inode *ip = XFS_I(inode); + unsigned int blksize = ip->i_mount->m_sb.sb_blocksize; + u64 tree_last_block = + xfs_fsverity_metadata_offset(ip) + merkle_tree_size; + u64 desc_pos = + round_up(tree_last_block, XFS_FSVERITY_START_ALIGN); + u64 desc_end = desc_pos + desc_size; + __be32 desc_size_disk = cpu_to_be32(desc_size); + u64 desc_size_pos = + round_up(desc_end + sizeof(desc_size_disk), blksize) - + sizeof(desc_size_disk); + + error = iomap_fsverity_write(file, desc_size_pos, sizeof(__be32), + (const void *)&desc_size_disk, + &xfs_buffered_write_iomap_ops, + &xfs_iomap_write_ops); + if (error) + return error; + + return iomap_fsverity_write(file, desc_pos, desc_size, desc, + &xfs_buffered_write_iomap_ops, + &xfs_iomap_write_ops); +} + +/* + * Try to remove all the fsverity metadata after a failed enablement. + */ +static int +xfs_fsverity_delete_metadata( + struct xfs_inode *ip) +{ + struct xfs_trans *tp; + struct xfs_mount *mp = ip->i_mount; + int error; + + xfs_ilock(ip, XFS_MMAPLOCK_EXCL); + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); + if (error) { + xfs_iunlock(ip, XFS_MMAPLOCK_EXCL); + return error; + } + + truncate_inode_pages(VFS_I(ip)->i_mapping, XFS_ISIZE(ip)); + + xfs_ilock(ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); + + /* + * We remove post EOF data, no need to update i_size as fsverity + * didn't move i_size in the first place + */ + error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, XFS_ISIZE(ip)); + if (error) + goto err_cancel; + + error = xfs_trans_commit(tp); + xfs_iunlock(ip, XFS_MMAPLOCK_EXCL | XFS_ILOCK_EXCL); + return error; +err_cancel: + xfs_trans_cancel(tp); + xfs_iunlock(ip, XFS_MMAPLOCK_EXCL | XFS_ILOCK_EXCL); + return error; +} + +static int +xfs_fsverity_reset_inode( + struct xfs_inode *ip) +{ + int error; + struct xfs_mount *mp = ip->i_mount; + struct xfs_trans *tp; + + error = xfs_fsverity_delete_metadata(ip); + if (error) + return error; + + /* + * First, let's clean in-memory fsverity flag and then reset it on the + * disk + */ + inode_set_flags(VFS_I(ip), 0, S_VERITY); + + /* + * Set fsverity inode flag + */ + error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_ichange, + 0, 0, false, &tp); + if (error) + return error; + + ip->i_diflags2 &= ~XFS_DIFLAG2_VERITY; + + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); + xfs_trans_set_sync(tp); + + error = xfs_trans_commit(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + return error; +} + +/* + * Prepare to enable fsverity by clearing old metadata. + */ +static int +xfs_fsverity_begin_enable( + struct file *filp) +{ + struct inode *inode = file_inode(filp); + struct xfs_inode *ip = XFS_I(inode); + int error; + + xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL); + + if (IS_DAX(inode) || ip->i_diflags2 & XFS_DIFLAG2_DAX) + return -EINVAL; + + /* + * fs-verity stores the Merkle tree past EOF in units of the filesystem + * block size, so it cannot support realtime files whose allocation unit + * (extent size) is larger than the block size. + */ + if (xfs_inode_has_bigrtalloc(ip)) + return -EINVAL; + + if (inode->i_size > XFS_FSVERITY_LARGEST_FILE) + return -EFBIG; + + /* + * Flush pagecache before building Merkle tree. Inode is locked and no + * further writes will happen to the file except fsverity metadata + */ + error = filemap_write_and_wait(inode->i_mapping); + if (error) + return error; + + if (xfs_iflags_test_and_set(ip, XFS_VERITY_CONSTRUCTION)) + return -EBUSY; + + error = xfs_qm_dqattach(ip); + if (error) + goto out_clear; + + error = xfs_fsverity_delete_metadata(ip); + if (error) + goto out_clear; + return error; +out_clear: + xfs_iflags_clear(ip, XFS_VERITY_CONSTRUCTION); + return error; +} + +/* + * Complete (or fail) the process of enabling fsverity. + */ +static int +xfs_fsverity_end_enable( + struct file *file, + const void *desc, + size_t desc_size, + u64 merkle_tree_size) +{ + struct inode *inode = file_inode(file); + struct xfs_inode *ip = XFS_I(inode); + struct xfs_mount *mp = ip->i_mount; + struct xfs_trans *tp; + int error = 0; + loff_t range_start = xfs_fsverity_metadata_offset(ip); + + xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL); + + /* fs-verity failed, just cleanup */ + if (desc == NULL) + goto out; + + error = xfs_fsverity_write_descriptor(file, desc, desc_size, + merkle_tree_size); + if (error) + goto out; + + /* + * Wait for Merkle tree get written to disk before setting on-disk inode + * flag and clearing XFS_VERITY_CONSTRUCTION + */ + error = filemap_write_and_wait_range(inode->i_mapping, range_start, + LLONG_MAX); + if (error) + goto out; + + /* + * Set fsverity inode flag + */ + error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_ichange, + 0, 0, false, &tp); + if (error) + goto out; + + /* + * Ensure that we've persisted the verity information before we enable + * it on the inode and tell the caller we have sealed the inode. + */ + ip->i_diflags2 |= XFS_DIFLAG2_VERITY; + + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); + xfs_trans_set_sync(tp); + + error = xfs_trans_commit(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + if (error) + goto out; + + inode_set_flags(inode, S_VERITY, S_VERITY); + + /* + * Proactively remove unwritten extents left by COW preallocations and + * write preallocation in the merkle tree holes and past descriptor, + * and any delayed preallocations + */ + error = xfs_free_eofblocks(ip); +out: + if (error) { + int error2; + + error2 = xfs_fsverity_reset_inode(ip); + if (error2) + xfs_alert(ip->i_mount, +"ino 0x%llx failed to clean up new fsverity metadata, err %d", + I_INO(ip), error2); + } + + xfs_iflags_clear(ip, XFS_VERITY_CONSTRUCTION); + return error; +} + +/* + * Retrieve a merkle tree block. + */ +static struct page * +xfs_fsverity_read_merkle( + struct inode *inode, + pgoff_t index) +{ + index += xfs_fsverity_metadata_offset(XFS_I(inode)) >> PAGE_SHIFT; + + return generic_read_merkle_tree_page(inode, index); +} + +/* + * Retrieve a merkle tree block. + */ +static void +xfs_fsverity_readahead_merkle_tree( + struct inode *inode, + pgoff_t index, + unsigned long nr_pages) +{ + index += xfs_fsverity_metadata_offset(XFS_I(inode)) >> PAGE_SHIFT; + + generic_readahead_merkle_tree(inode, index, nr_pages); +} + +static inline bool +xfs_fsverity_is_hashes_of_zeroed_blocks( + struct xfs_inode *ip, + const void *buf, + unsigned int size, + const u8 *zero_digest, + unsigned int digest_size) +{ + /* + * If this is a block full of hashes of zeroed blocks, don't bother + * storing the block. We can synthesize them later. + * + * However, do this only in case Merkle tree block == fs block size. + * Iomap synthesizes these blocks based on holes in the merkle tree. We + * won't be able to tell if something need to be synthesizes for the + * range in the fs block. For example, for 4k filesystem block + * + * [ 1k | zero hashes | zero hashes | 1k ] + * + * Iomap won't know about these empty blocks. + */ + if (size != ip->i_mount->m_sb.sb_blocksize) + return false; + /* + * First digest is zero_digest + */ + if (memcmp(buf, zero_digest, digest_size)) + return false; + /* + * Every digest is same as previous, thus all are + * zero_digest + */ + return memcmp(buf + digest_size, buf, size - digest_size) == 0; +} + +/* + * Write a merkle tree block. + */ +static int +xfs_fsverity_write_merkle( + struct file *file, + const void *buf, + u64 pos, + unsigned int size, + const u8 *zero_digest, + unsigned int digest_size) +{ + struct inode *inode = file_inode(file); + struct xfs_inode *ip = XFS_I(inode); + loff_t position = pos + + xfs_fsverity_metadata_offset(ip); + + if (position + size > inode->i_sb->s_maxbytes) + return -EFBIG; + + if (xfs_fsverity_is_hashes_of_zeroed_blocks(ip, buf, size, zero_digest, + digest_size)) + return 0; + + return iomap_fsverity_write(file, position, size, buf, + &xfs_buffered_write_iomap_ops, + &xfs_iomap_write_ops); +} + +const struct fsverity_operations xfs_fsverity_ops = { + .begin_enable_verity = xfs_fsverity_begin_enable, + .end_enable_verity = xfs_fsverity_end_enable, + .get_verity_descriptor = xfs_fsverity_get_descriptor, + .read_merkle_tree_page = xfs_fsverity_read_merkle, + .readahead_merkle_tree = xfs_fsverity_readahead_merkle_tree, + .write_merkle_tree_block = xfs_fsverity_write_merkle, +}; diff --git a/fs/xfs/xfs_fsverity.h b/fs/xfs/xfs_fsverity.h index 01269a828fc0..7a3aee6d45fc 100644 --- a/fs/xfs/xfs_fsverity.h +++ b/fs/xfs/xfs_fsverity.h @@ -7,9 +7,11 @@ #include "xfs_platform.h" #include +#include #include #ifdef CONFIG_FS_VERITY +extern const struct fsverity_operations xfs_fsverity_ops; int xfs_fsverity_init(void); void xfs_fsverity_exit(void); loff_t xfs_fsverity_metadata_offset(const struct xfs_inode *ip); diff --git a/fs/xfs/xfs_message.c b/fs/xfs/xfs_message.c index 0243e509a468..44b13d46049c 100644 --- a/fs/xfs/xfs_message.c +++ b/fs/xfs/xfs_message.c @@ -149,6 +149,10 @@ xfs_warn_experimental( .opstate = XFS_OPSTATE_WARNED_LARP, .name = "logged extended attributes", }, + [XFS_EXPERIMENTAL_FSVERITY] = { + .opstate = XFS_OPSTATE_WARNED_FSVERITY, + .name = "fsverity", + }, }; ASSERT(feat >= 0 && feat < XFS_EXPERIMENTAL_MAX); BUILD_BUG_ON(ARRAY_SIZE(features) != XFS_EXPERIMENTAL_MAX); diff --git a/fs/xfs/xfs_message.h b/fs/xfs/xfs_message.h index 811b885f41c3..364fcc7e42b0 100644 --- a/fs/xfs/xfs_message.h +++ b/fs/xfs/xfs_message.h @@ -93,6 +93,7 @@ void xfs_buf_alert_ratelimited(struct xfs_buf *bp, const char *rlmsg, enum xfs_experimental_feat { XFS_EXPERIMENTAL_SHRINK, XFS_EXPERIMENTAL_LARP, + XFS_EXPERIMENTAL_FSVERITY, XFS_EXPERIMENTAL_MAX, }; diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 60cb54c1a5ec..a3074f060928 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -599,6 +599,8 @@ __XFS_HAS_FEAT(nouuid, NOUUID) #define XFS_OPSTATE_RESUMING_QUOTAON 18 /* (Zoned) GC is in progress */ #define XFS_OPSTATE_ZONEGC_RUNNING 20 +/* Kernel has logged a warning about fsverity support */ +#define XFS_OPSTATE_WARNED_FSVERITY 21 #define __XFS_IS_OPSTATE(name, NAME) \ static inline bool xfs_is_ ## name (struct xfs_mount *mp) \ diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 7a8d071dbe56..560493e2b78c 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -30,6 +30,7 @@ #include "xfs_filestream.h" #include "xfs_quota.h" #include "xfs_sysfs.h" +#include "xfs_fsverity.h" #include "xfs_ondisk.h" #include "xfs_rmap_item.h" #include "xfs_refcount_item.h" @@ -1736,6 +1737,9 @@ xfs_fs_fill_super( sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ; #endif sb->s_op = &xfs_super_operations; +#ifdef CONFIG_FS_VERITY + sb->s_vop = &xfs_fsverity_ops; +#endif /* * Delay mount work if the debug hook is set. This is debug @@ -1988,6 +1992,9 @@ xfs_fs_fill_super( if (error) goto out_filestream_unmount; + if (xfs_has_verity(mp)) + xfs_warn_experimental(mp, XFS_EXPERIMENTAL_FSVERITY); + root = igrab(VFS_I(mp->m_rootip)); if (!root) { error = -ENOENT; From patchwork Fri Oct 2 12:36:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315400 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=j8XOx/n/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=g8yu=hy=vger.kernel.org=linux-ext4+bounces-19957-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNyg1GbYz1xvt for ; Sat, 03 Oct 2026 08:40:11 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNy23pskz4w9T for ; Sat, 03 Oct 2026 08:39:38 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNy23mwHz4w0Q; Sat, 03 Oct 2026 08:39:38 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c04:e001:36c::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980778; cv=pass; b=xKjssI30Km+6Z5doImFN6KC3cCsSzNLuJDCfxx6GVIbsrrdUKT/wMrUTZRpDcXGJCcssbwYYRMrpjMgkCVPElSekKBKUPGJbcquGVPO6Y/5EkOaE2+axAE6jwj1qwodSvvtAtzd4WkH9ADMqEvufat39E6/I1Aq9+NABFq1VQccDIHlvApXobcXBbvnIPJ8wBlji7LxRigSc3TQtZEhcRvMweU/0B4xPby3XpPLqeS4tVpDezBlwtNLffT9DhjAGmK036h0HWixHpqBAbmOnUDsP8uGB09Wy7pWcmV8Yvt1LL5kSIrM2f+Tc+6/2aLpgHNBSSJ195apAulglxaH/hg== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980778; c=relaxed/relaxed; bh=lfg52zb8DlfflgPU8kvIwpmUoI7GKK53PRBf16ii4Ys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fSUlJ1FLxBjthK4nNwdUdqE1RUnDYacaeImUVbLKCnxbXJXx8q65T0fgFzjmsGMrDBQtThL/Uvjo+kR0R1tfvWcpojDP7LK9gIfHwpQveTUycGhBmJH0xVviESJxjYgQesZeixPA0MxeJYLaIbDicxPBihhoG3qcLycGoBgdPkUzHbuQuqB0VYCuT7/v3OahY4zworc+nbHjJpIw8faFppaQl1qOEkObMR0JV/5qVa+oM6r2bWNJ14AIEwBRke1pHK1EaAN58Ye69wpvNF73jbkY5GtCZmFvrCwP4lGg18mqGRUeDWdRa89gkARaj147Atm9VWcy8G1gk8WUVstEDA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=j8XOx/n/; dkim-atps=neutral; spf=pass (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19957-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=j8XOx/n/; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19957-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from tor.lore.kernel.org (tor.lore.kernel.org [IPv6:2600:3c04:e001:36c::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNxy6n85z4w9T for ; Sat, 03 Oct 2026 08:39:34 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 5CE9535BE6 for ; Fri, 2 Oct 2026 22:38:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A374947D95C; Fri, 2 Oct 2026 22:38:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j8XOx/n/" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 67D5B3C4555; Fri, 2 Oct 2026 22:38:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980690; cv=none; b=pQd/4ibCgpPNheAZu1UXCLwToil7EwU+b4viXg0la5SHhUmjmvcxkGuM8BEzX2CoabqPa4XrzUQDUfJHtIef0RDz1LqKjlkCmk89j/NzWquw0UOq/3roy2pF8Rtt737HOuUu8YWmxCgGKA75i5J9aJmK7jaO7KsIdy228OnYWsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980690; c=relaxed/simple; bh=6LzeMOZgSqk7X0dZt1145qUHKcU9xc7K0sSDHPbXy5Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NPDcI3VdIBJypnqb+T3Ltbm2axcu2sy5ZSaO8ADMbTU7JA/FQBpMhufLtsuoMZ7KWgIrr+ciOqO4q845KN7X5kx6oRX+iaBwOAU3p7RGXcbJJKRSatkbyN4z5JiWHIgVV9hdl9uvInVMUT5UpzULQ3pKTc6KXps3oSqmNZa3dO4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j8XOx/n/; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05C901F000FF; Fri, 2 Oct 2026 22:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980689; bh=lfg52zb8DlfflgPU8kvIwpmUoI7GKK53PRBf16ii4Ys=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=j8XOx/n/zCvUR4MwqSio1FINgu934XZOccwlfOyOhVAxRLgQ2vItJcIlkOM+3BhlH 5cMn/LN449BTuqYy+ZFVk63Aa5XkHARzLCXN7PJVvF2QPk1Bl17mrUHzK8OwKwOAne fyMNDoY3lsGKxA2bK/5dM6mOniQFf7XjN6OWqsqPPsScCfgy8NI6dKsR6l/Ft7xrHE l8BQXizyQP0rXmsLpW2SBSbLQZl2hZ5ivsD7wplYvvqTkUPpoKHA1sDcwRge3rR9ao d+Wuu75p4uYjWP/mGd7tzX9RfyFxOGl4w/fB630wkabWKeVqQLSS+sdySXuozauvTQ AVW/srWyw/8vA== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 16/21] xfs: initialize fs-verity on file open Date: Sat, 3 Oct 2026 00:36:57 +0200 Message-ID: <20261002223705.2175542-17-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org fs-verity will read and attach metadata (not the tree itself) from a disk for those inodes which already have fs-verity enabled. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Andrey Albershteyn --- fs/xfs/xfs_file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 578ca6fb8292..e13390539f04 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1794,11 +1794,18 @@ xfs_file_open( struct inode *inode, struct file *file) { + int error; + if (xfs_is_shutdown(XFS_M(inode->i_sb))) return -EIO; file->f_mode |= FMODE_NOWAIT | FMODE_CAN_ODIRECT; if (xfs_get_atomic_write_min(XFS_I(inode)) > 0) file->f_mode |= FMODE_CAN_ATOMIC_WRITE; + + error = fsverity_file_open(inode, file); + if (error) + return error; + return generic_file_open(inode, file); } From patchwork Fri Oct 2 12:36:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GNlQY51U; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=rth9=hy=vger.kernel.org=linux-ext4+bounces-19958-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNz128C6z1xvt for ; Sat, 03 Oct 2026 08:40:29 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNyN4mlGz4w0Q for ; Sat, 03 Oct 2026 08:39:56 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNyN4jM7z4w9T; Sat, 03 Oct 2026 08:39:56 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.105.105.114 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980796; cv=pass; b=W7A4DuDSd5KIyNsvlel48ve1K5wqOxQkr8aUiwS1DBd/u9WpyjM10vnQwypV2RuTPHERA6yDOFhHph+0+EbXWJqMXa5dTvlTf9whp/TsWOcDTg917kk284AeBtWTYXJwuBRMpFdEUBY1lPbEplXqLPiM9B3800MAXjLyPRGtFm44kNLdV3etRYS9l2uilyyYNvF+S3NZ1B3AgFjN8D+iwAagsVxJIRfS7b+wt77rjegXDwCjQKB1nTnbGJMIJsEZZfHBsa0Irgr5Qkz7M3I+UWjweKjOc1Vq66a/Mud3xwcOJmJ8FcYaUm1MuirFi336RTWS//UAcagFoAN5XS/PHg== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980796; c=relaxed/relaxed; bh=HrtmR+UhuIlkdLxqdHwsV1MPMtkWUuoZJKrA9HvlOJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mn769AU9589SVxHDzB5xXoNP8qM/Saal0QeAsCBR6x8nNwCh/LYNUI79iYvAus9da0YaN3wucpU9sVdor5y5kJrOjy5awH4AzOWjFYJWkqW58D9rHFGwo4h4on8b6UoSY4MJnxzTZ1/ZMduN69YN/PdNEhicu7pLP2t6oM4y8xhUOS5Tk+flBiwGbXRZFaAsEtV73UTSUa+KvkWQbQARLOaaDpXq3Agv1oYL8zwQjrXk93+UOaDSHHlu9jn7TQjyanEg+4YK8C6o0BstvUVtScSbbVqRxMrwWv4pz15JiVSzqrpr9VNEln5mU2V5KzcDNIeOSY7lQQR+6Y+52JWF7Q== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GNlQY51U; dkim-atps=neutral; spf=pass (client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19958-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GNlQY51U; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19958-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNyK0cB5z4w0Q for ; Sat, 03 Oct 2026 08:39:53 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 3E6E53690D for ; Fri, 2 Oct 2026 22:38:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00BEA471244; Fri, 2 Oct 2026 22:38:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GNlQY51U" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B30613C4555; Fri, 2 Oct 2026 22:38:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980693; cv=none; b=riajVIjSisg1jFpDXTLRE0AMGdsfkqAwOqK45MtNDABdqXs4gbeI3ZoDzjUQ1lK1n59lYtgYGuRbTkg6NnGAqjTPFtA0nx5MZlnpujNIOvHQt1Sjgqg+EnWtJKmfVmFRuqIy25zS44bs85dbjb0y4ymxbTDYG4COgZixG5jKdnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980693; c=relaxed/simple; bh=lG0XvtN47lrmr2yjGsrjuEbv5pnG0/i67p2cCRVww04=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fjz1klh6cUkr4WGlbotuuy3IVrC8SDc9R3sTUKeLrAAWoT7uCuq3OgkZGeOazudx0gYCVsO0inIPFd4K6ODfD4EsvOyDHtIeMwaJ2tiFHf+oCQuYXtt3Eb2ikGMxTjU/9dE295RsmoNLSQKLW44tMqulTwwujZldUsF1NvC8k7w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GNlQY51U; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DDFB1F00893; Fri, 2 Oct 2026 22:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980692; bh=HrtmR+UhuIlkdLxqdHwsV1MPMtkWUuoZJKrA9HvlOJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GNlQY51UK2aqkIyJmyZ4Kim5Wn44NuJ+ZNK1ATX3nI/r5cLKmuq7G252oExQojpgI 9SM8z0Tr9CdqjmM5/YGd6GjVMDQn9BOO+/lr6Xu+J8AvFDMf00x5UHdB2R9QPpFoxw 1TWiyZYwFj4gaI1ngJwCtiSbozEY2/RtEuurfiBiUmP5/AQjkk3T5Ca2ugVqLE19Ap oXLg7Uq09YlGPJGh2BGRT4sp5HrfI6HsRTgl0wekMCyWb2LZGoPHNKiLmRSa65BT9w lh95gpeOl2mCy1MGIunwV/zMEAGdR8Mcft7QLyK2dmGlcjKlfTgmZ5WQm/UnubyiK1 yFTRZmuMdNw1Q== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 17/21] xfs: add fs-verity ioctls Date: Sat, 3 Oct 2026 00:36:58 +0200 Message-ID: <20261002223705.2175542-18-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org Add fs-verity ioctls to enable, dump metadata (descriptor and Merkle tree pages) and obtain file's digest. [djwong: remove unnecessary casting] Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Andrey Albershteyn --- fs/xfs/xfs_ioctl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 96ca3e480cb9..ac4c36f381b8 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -49,6 +49,7 @@ #include #include +#include /* Return 0 on success or positive error */ int @@ -1466,6 +1467,19 @@ xfs_file_ioctl( case XFS_IOC_VERIFY_MEDIA: return xfs_ioc_verify_media(filp, arg); + case FS_IOC_ENABLE_VERITY: + if (!xfs_has_verity(mp)) + return -EOPNOTSUPP; + return fsverity_ioctl_enable(filp, arg); + case FS_IOC_MEASURE_VERITY: + if (!xfs_has_verity(mp)) + return -EOPNOTSUPP; + return fsverity_ioctl_measure(filp, arg); + case FS_IOC_READ_VERITY_METADATA: + if (!xfs_has_verity(mp)) + return -EOPNOTSUPP; + return fsverity_ioctl_read_metadata(filp, arg); + default: return -ENOTTY; } From patchwork Fri Oct 2 12:36:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315403 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=H0wWX9iv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=3/xe=hy=vger.kernel.org=linux-ext4+bounces-19959-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNzM389nz1xvt for ; Sat, 03 Oct 2026 08:40:47 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNyk5lzlz4w0Q for ; Sat, 03 Oct 2026 08:40:14 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNyk5jsVz4wBD; Sat, 03 Oct 2026 08:40:14 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c04:e001:36c::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980814; cv=pass; b=GM3chu7UplfwcWrOwLyevwdE7w7JynNQmYOl1sW+XALm4oF3kW074HtqpuJugcMXu144iL7GrlThevw7ff+OPFUmzqPKm4zrZtYs56RvmddrNZtlyp7dPTolAATAI0fpEye5eBL+0Mw2nmMNybufqtReTt/KZ1ZcNy5Ug+XMxK4S9RSEMoZOngakl6W/d1o4Ml4EkFGxGqx5n7BBa6r6Y1xz/82tXgQ0IKqyssFCr7DGaZoA/1CbcgHm7SxutsJo1+6D7QaTbssk28B4AIQIgNEo25URZzVLjGvGMoRhQ1SUQtYCHzzBGaSWQaQkstVQA42l8e4gjTpC0m2Mv14Sfg== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980814; c=relaxed/relaxed; bh=bSv6TKlW4NbrjSEeVlXfAwkAliMrPUfKHonbv3D6dao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cYXk2t+v6l81IJWjBfEYGr3Ww6xcfWIT+y/X9rLFiX761Kf4MAHGLAYYGaOq1mUhv2tR50jq/0B6FUQVLc4dfxTNoFSSZFSPVmRTbns544LvJ2DD89D3O7QgBxQO1dk0C1AFrWXaY8LJSB5R1/2qKJCXZ5L0aPgFho5tCu1w1eQ1NNf0PApYA3On8PZYNhYSPevHdpBZNiSOER+gzh9uqdtoqrMs2wox7xFUwaXyfeKHgd+BcFgTsRkl1XPsVzZLR68IctQrQYhq6Y+UCn5CFxviU1OTCPHOzuiMlMI9PznK/g1eccB3XNLh2aEfNXBcH+dscsaeFHK+gbE3PLwWDQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=H0wWX9iv; dkim-atps=neutral; spf=pass (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19959-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=H0wWX9iv; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19959-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from tor.lore.kernel.org (tor.lore.kernel.org [IPv6:2600:3c04:e001:36c::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNyg2PCrz4w0Q for ; Sat, 03 Oct 2026 08:40:11 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 205FA37119 for ; Fri, 2 Oct 2026 22:38:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7AD447C10A; Fri, 2 Oct 2026 22:38:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H0wWX9iv" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 6B32D3C4555; Fri, 2 Oct 2026 22:38:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980697; cv=none; b=hGf69/wqcQJgYb3tmKKbzerm1EotiFnP5UVm98/RkzBwWimKUhoHaVLPY2pnbSWNG9vA0ab+Cg3Hz62dSerKEggRPeMEilD6EiDvmODKCDF6rPtiCrZuqpEufbUx1BfaBVCuU5IcH2d1ZUOOHOzqFHaPrxZJpy4I9t/OSO96rHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980697; c=relaxed/simple; bh=GoZafcVwYM13EDs2y2xw2tBf35tv1AhEEm1Y2K/M1NI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lLE61xGpJZha/ChCtjKpRmrQX2pHC9x96wfoKr/yE/TWF2Z+cOQn7kUMbCLgBIAp/C0UOd0IymGUCiO3woFwlA9mz3PQdQJ3BN06UKyoDzPuPsCkrC5WaXkNBsThiaHn+gx6AvQNAnZKrcBuAbdK557GZi4pt2n4K5FSUvhxeN0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H0wWX9iv; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 195DC1F000FF; Fri, 2 Oct 2026 22:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980696; bh=bSv6TKlW4NbrjSEeVlXfAwkAliMrPUfKHonbv3D6dao=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=H0wWX9ivYxTyhCJGmh6b7cl5KdugmN9y7kixaF3pF3CuKALxTEITnlu6quHULbOJq rI+TBQ3p24lsFoZY2367W0bIXiZQiz4/vxm+TbMvRWwLWvUOtQK3m75gPhFmdhSNxl 66PHIYgEO1nHOw0ZIP//n2qbl6Z/Z5GVH3rrA6soTFEsSB7xpIGv2z8odxyoWs9wIp /1UlQiAbl5cJrmC8x6mtx8cQQilCHK+/jdZY8LPBdgboPXDGKAgJHiGehgi/50Uvrf jT7h3NOcdS0WRtbsZzuC97/QAE8PCq0zt3BG0Qz9kRzaN20ndr3yqMsB9egd6EK0eC pQ2ZrYbsFIA3g== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com, Andrey Albershteyn Subject: [PATCH v17 18/21] xfs: advertise fs-verity being available on filesystem Date: Sat, 3 Oct 2026 00:36:59 +0200 Message-ID: <20261002223705.2175542-19-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: "Darrick J. Wong" Advertise that this filesystem supports fsverity. Signed-off-by: Darrick J. Wong Reviewed-by: Andrey Albershteyn Reviewed-by: Christoph Hellwig Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_fs.h | 1 + fs/xfs/libxfs/xfs_sb.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 185f09f327c0..c80133784419 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -250,6 +250,7 @@ typedef struct xfs_fsop_resblks { #define XFS_FSOP_GEOM_FLAGS_PARENT (1 << 25) /* linux parent pointers */ #define XFS_FSOP_GEOM_FLAGS_METADIR (1 << 26) /* metadata directories */ #define XFS_FSOP_GEOM_FLAGS_ZONED (1 << 27) /* zoned rt device */ +#define XFS_FSOP_GEOM_FLAGS_VERITY (1 << 28) /* fs-verity */ /* * Minimum and maximum sizes need for growth checks. diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 985c7c6a09f2..fd06c3d6cc11 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -1587,6 +1587,8 @@ xfs_fs_geometry( geo->flags |= XFS_FSOP_GEOM_FLAGS_METADIR; if (xfs_has_zoned(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_ZONED; + if (xfs_has_verity(mp)) + geo->flags |= XFS_FSOP_GEOM_FLAGS_VERITY; geo->rtsectsize = sbp->sb_blocksize; geo->dirblocksize = xfs_dir2_dirblock_bytes(sbp); From patchwork Fri Oct 2 12:37:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315399 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YUTCaX/M; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=fdra=hy=vger.kernel.org=linux-ext4+bounces-19960-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxNyM1gybz1xyX for ; Sat, 03 Oct 2026 08:39:55 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxNxk4Dwfz4w9g for ; Sat, 03 Oct 2026 08:39:22 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxNxk49X7z4w1S; Sat, 03 Oct 2026 08:39:22 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c15:e001:75::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980762; cv=pass; b=DpLVVJ8s2u5p5dRzQktteG11kt2T5Pb+xYfuk2IZpm8uemVlJQMumduWI3lynBAoWydaXzDrDr2uq+zq6PrtjtaIuOsJYWGk5p46Ezp8FfYcZo5eAvCydM7eouA2/JxMLt3/0I25DdyYEOllhradpSSPoxvEMjaRxWQ3V4uYy9WkcwczcCxdWLSmIUnXPFybv45EFaHoWp+CWsAQWx3poF8iegbGbSxYSd0FjoQAj3EaJPcpFJnR2uRcf/jEHuBVWaIIKVpxXRMK8+GBTuKTSkOknycKSip0JVnaw29PEkXwI0hC/XOOurb9VueIJiBJWgcRFPDw4eTNixJVtYCGjw== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980762; c=relaxed/relaxed; bh=Pur684O7f4U32O/inLuavBXE9++fvzsYKMvpvb4wbkQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=yAoBN335TagfApQzH3rCi4RYv69RKOBa+KDWOwLvmKrWtFbsjBHSTEL4Ecl3vQvD+RXCXMFYEhAWtPGkMWJXNrI99wblZwYWofChLIiaccR5nqyFySi5xOq0isGL5dqNl3P5HylDD4bAwsyhAXy9adXp8quiHhOCO8Do0jKqUkfQMWWzVKu84tiA+51LrSA6Oo1dCELi+T6p4QgrPx7+gCBWN8knxLJqVTr1BSaOLzZW5uPc/dnGAggde4wyq5lC8WYy8xLG6ogYNo7IfhE20Cfs7cTLj724qRC5ACFcM1B/Tec6A8I6tPVdnt99N/RLJylhVD9rXfubM4tTsNB0rg== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YUTCaX/M; dkim-atps=neutral; spf=pass (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org; envelope-from=linux-ext4+bounces-19960-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YUTCaX/M; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org; envelope-from=linux-ext4+bounces-19960-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sin.lore.kernel.org (sin.lore.kernel.org [IPv6:2600:3c15:e001:75::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxNxg1Q40z4wBD for ; Sat, 03 Oct 2026 08:39:19 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id 35A8D2C92F for ; Fri, 2 Oct 2026 22:38:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C04046DFE5; Fri, 2 Oct 2026 22:38:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YUTCaX/M" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E1AFA3C4555; Fri, 2 Oct 2026 22:38:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980701; cv=none; b=SbRB4fjmhfvDm+mJylIar9Kl+Dl7MxTOAxFPthvtRaNUNKJnAnJwj2ZLBud1oYPnDzG4PqWw4h0TG9cMM5iIFlhPbO54j3bpgogL1s6VaTuL718ub5c/oCdyvIPkRkFiYzvm3orLEkm3AgrgVeWlvXO1Ftd3W3aElEKi5jlLxb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980701; c=relaxed/simple; bh=bhBcSc17wbgm6StUYRZVxk0LiBNjBq4BlqUyHt1bc7Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qkXBdzjTzRNlJh+Y3jlOdwewo1PqnI2fpFr7Ph5Lz38pQRv8Mu6nnpSl8ANC49zLxXUWXeHm1TrP0Y1vwrw3tpNPhyvzgcUQoRfrnNl9yDONIz0W7CTDT6vC3w5MDxweSmVSZATUwQxpbjb26ZWI8+qhhxbuD/USTZRkIg8qUu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YUTCaX/M; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CECE41F00898; Fri, 2 Oct 2026 22:38:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980699; bh=Pur684O7f4U32O/inLuavBXE9++fvzsYKMvpvb4wbkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YUTCaX/MOTK3BDrzMIhcs8ivu97PBb26K697p1RnoEk8xhY45C1i/1IKdMPJ40+N7 xnhXcjcXpfYnj9v38wZi1kg7FaVPbk4umcwp6uoa86ugqzRCHCuQCKz12I+plpyGaB 0W/O3QcAlD8UGOU3BJomAAYVCYHc0roYtRhVgjL+XCf9lZnAbX0+ZLL5b5l/A3HOwe JsP9BssSsicpf3132+BVole7CIf7+jXuQLBBq70WNP4estVxwUkT34OSFpBep0MOag 0s/LVwSSw3Vh8xIgFfx/yT5N9Z4cfZcZS9z89TQpjzRYTzc/i+SJ16CafZ9CDFhh+A T0bh1dX+KOi8Q== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 19/21] xfs: check and repair the verity inode flag state Date: Sat, 3 Oct 2026 00:37:00 +0200 Message-ID: <20261002223705.2175542-20-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: "Darrick J. Wong" If an inode has the incore verity iflag set, make sure that we can actually activate fsverity on that inode. If activation fails due to a fsverity metadata validation error, clear the flag. The usage model for fsverity requires that any program that cares about verity state is required to call statx/getflags to check that the flag is set after opening the file, so clearing the flag will not compromise that model. Signed-off-by: Darrick J. Wong Signed-off-by: Andrey Albershteyn Reviewed-by: Christoph Hellwig --- fs/xfs/scrub/common.c | 53 +++++++++++++++++++++++++++++++++++++ fs/xfs/scrub/common.h | 2 ++ fs/xfs/scrub/inode.c | 7 +++++ fs/xfs/scrub/inode_repair.c | 36 +++++++++++++++++++++++++ 4 files changed, 98 insertions(+) diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index e5233e31abb7..ebbef3afb7d6 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -45,6 +45,8 @@ #include "scrub/health.h" #include "scrub/tempfile.h" +#include + /* Common code for the metadata scrubbers. */ /* @@ -1754,3 +1756,54 @@ xchk_inode_count_blocks( return xfs_bmap_count_blocks(sc->tp, sc->ip, whichfork, nextents, count); } + +/* + * If this inode has S_VERITY set on it, read the verity info. If the reading + * fails with anything other than ENOMEM, the file is corrupt, which we can + * detect later with fsverity_active. + * + * Callers must hold the IOLOCK and must not hold the ILOCK of sc->ip because + * activation reads inode data. + */ +int +xchk_inode_setup_verity( + struct xfs_scrub *sc) +{ + int error; + + if (!fsverity_active(VFS_I(sc->ip))) + return 0; + + error = fsverity_ensure_verity_info(VFS_I(sc->ip)); + switch (error) { + case 0: + /* fsverity is active */ + break; + case -ENODATA: + case -EMSGSIZE: + case -EFSCORRUPTED: + case -ERANGE: + case -EBADMSG: + /* + * The nonzero errno codes above are the error codes that can + * be returned from fsverity on metadata validation errors. + */ + return 0; + default: + /* runtime errors */ + return error; + } + + return 0; +} + +/* + * Is this a verity file that failed to activate? Callers must have tried to + * activate fsverity via xchk_inode_setup_verity. + */ +bool +xchk_inode_verity_broken( + struct xfs_inode *ip) +{ + return fsverity_active(VFS_I(ip)) && !fsverity_get_info(VFS_I(ip)); +} diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h index f0f073a93413..676b4afd0be4 100644 --- a/fs/xfs/scrub/common.h +++ b/fs/xfs/scrub/common.h @@ -267,6 +267,8 @@ int xchk_inode_is_allocated(struct xfs_scrub *sc, xfs_agino_t agino, bool *inuse); int xchk_inode_count_blocks(struct xfs_scrub *sc, int whichfork, xfs_extnum_t *nextents, xfs_filblks_t *count); +int xchk_inode_setup_verity(struct xfs_scrub *sc); +bool xchk_inode_verity_broken(struct xfs_inode *ip); bool xchk_inode_is_dirtree_root(const struct xfs_inode *ip); bool xchk_inode_is_sb_rooted(const struct xfs_inode *ip); diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c index 65b13e311916..d1cdd6b445d0 100644 --- a/fs/xfs/scrub/inode.c +++ b/fs/xfs/scrub/inode.c @@ -36,6 +36,10 @@ xchk_prepare_iscrub( xchk_ilock(sc, XFS_IOLOCK_EXCL); + error = xchk_inode_setup_verity(sc); + if (error) + return error; + error = xchk_trans_alloc(sc, 0); if (error) return error; @@ -833,6 +837,9 @@ xchk_inode( if (S_ISREG(VFS_I(sc->ip)->i_mode)) xchk_inode_check_reflink_iflag(sc, I_INO(sc->ip)); + if (xchk_inode_verity_broken(sc->ip)) + xchk_ino_set_corrupt(sc, sc->sm->sm_ino); + xchk_inode_check_unlinked(sc); xchk_inode_xref(sc, I_INO(sc->ip), &di); diff --git a/fs/xfs/scrub/inode_repair.c b/fs/xfs/scrub/inode_repair.c index 8bc508336aa5..6c0b7130e227 100644 --- a/fs/xfs/scrub/inode_repair.c +++ b/fs/xfs/scrub/inode_repair.c @@ -573,6 +573,8 @@ xrep_dinode_flags( dip->di_nrext64_pad = 0; else if (dip->di_version >= 3) dip->di_v3_pad = 0; + if (!xfs_has_verity(mp) || !S_ISREG(mode)) + flags2 &= ~XFS_DIFLAG2_VERITY; if (flags2 & XFS_DIFLAG2_METADATA) { xfs_failaddr_t fa; @@ -1617,6 +1619,10 @@ xrep_dinode_core( if (iget_error) return iget_error; + error = xchk_inode_setup_verity(sc); + if (error) + return error; + error = xchk_trans_alloc(sc, 0); if (error) return error; @@ -2035,6 +2041,27 @@ xrep_inode_unlinked( return 0; } +/* + * If this file is a fsverity file, xchk_prepare_iscrub or xrep_dinode_core + * should have activated it. If it's still not active, then there's something + * wrong with the verity descriptor and we should turn it off. + */ +STATIC int +xrep_inode_verity( + struct xfs_scrub *sc) +{ + struct inode *inode = VFS_I(sc->ip); + + if (xchk_inode_verity_broken(sc->ip)) { + sc->ip->i_diflags2 &= ~XFS_DIFLAG2_VERITY; + inode_set_flags(inode, 0, S_VERITY); + + xfs_trans_log_inode(sc->tp, sc->ip, XFS_ILOG_CORE); + } + + return 0; +} + /* Repair an inode's fields. */ int xrep_inode( @@ -2084,6 +2111,15 @@ xrep_inode( return error; } + /* + * Disable fsverity if it cannot be activated. Activation failure + * prohibits the file from being opened, so there cannot be another + * program with an open fd to what it thinks is a verity file. + */ + error = xrep_inode_verity(sc); + if (error) + return error; + /* Reconnect incore unlinked list */ error = xrep_inode_unlinked(sc); if (error) From patchwork Fri Oct 2 12:37:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315410 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aZHEndfy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=bwvk=hy=vger.kernel.org=linux-ext4+bounces-19961-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxP5C58PSz1y1j for ; Sat, 03 Oct 2026 08:45:51 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxP4Z70Hrz4w1S for ; Sat, 03 Oct 2026 08:45:18 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxP4Z6l44z4wBD; Sat, 03 Oct 2026 08:45:18 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.234.253.10 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790981118; cv=pass; b=kWaqAspzeC+Hd+WaOh1C7r0ahb8p6yN4zILorv57LrnxqqK7PMhIQpiswy6eAr8ozEZD9D19B1O9SjyCVZrIi7/wNdZPTQW1LCi8V9n72bF1IiErceHKxUfOQIL+Uo5KIUEREUzPy2NR8stSIgcOSEVZ07n/kwheM+nyFaXclT/fLo45d7pvkAd1o/5KEdu4ecuEVXmY0uRNQlgEuDnUhzkA4l2LAQbc+ffEazEiMXF6y+DbOrgWwmJLs0MlYAX84HaAlh+LPxbkPFdTvV3DETQuFWFe9IhNVbwjEbSWtLSvvEhBeqv+8oWiX84esfuZs6HQ1VDZihzMety0KXdEvg== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790981118; c=relaxed/relaxed; bh=mScGgc1mNGHzg+HyC079sL+o0xTAcTNL6WYWLAzFG/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=domyWYrLuAnrbrDNqSCZea3kxQDtdkpXNawk8yATAp+btDeCFRo7JcjVPr3yHE9rNPBQuPOtJz9U13BfqrAg+p+KspMRRXYobNJ8zdrIUnX/SInB+hb9b7Ar5C1vhJQucE4FmKR75FWrd86XDHJ29LZME11eG8u/4rJ545kEhaEbObFDHTTcnEvdGY36jqm7cq6x+PXJK8EFoo7HOcPoKuwFb0gy2TR1+PgIuvHDDAN3L7GiGJ6cXJ/HSnIk5f0tr2CV8FSaCnuOwWXKTTIfZI8UkjuQq1JHgWww9NST1RBAA6vGH98pzpCfkRNBYtg9gManncZnriXYCIOR0XhBlw== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aZHEndfy; dkim-atps=neutral; spf=pass (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19961-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aZHEndfy; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19961-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxP4W569jz4w1S for ; Sat, 03 Oct 2026 08:45:15 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id EE2C93F94D for ; Fri, 2 Oct 2026 22:38:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00D4C4A0939; Fri, 2 Oct 2026 22:38:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aZHEndfy" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 954FF471424; Fri, 2 Oct 2026 22:38:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980704; cv=none; b=HPs5tLyjrBr1UIdfXs69LFPATbNjheQsBZeDJeA5MQSGGsTEtvXXxHsVYsp8g8+XrvdmkRZzLYauD2vIONCLZRnJWQaZiszdEGbpYncNgiM0HTK/2BqnpMIDSPGnuOjPmfM87g6vee8X17PzwfCikDqHDDZFFZEmJVKhwcvG3GE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980704; c=relaxed/simple; bh=WQtT0toHGKRuk8a9l6hkMm6Nr4k4/dhUSkNv4uiBiGQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YPjXBFrcwl52yCTGsMxh0LmKIujmOOOXo6HTloA5lpOBXgdI5KDuzAy+v5nDW133aBJnuqh1Ys+sAh0fpBTq9qBb4FeXohgC9hRMTq9wTm6YdQ6Eljbka3cz1ehHGzTDodxI23O+7FDDvJ+61PujQav9NxKAFNHOYi8CQwHlh48= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aZHEndfy; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 503FA1F000FF; Fri, 2 Oct 2026 22:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980703; bh=mScGgc1mNGHzg+HyC079sL+o0xTAcTNL6WYWLAzFG/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aZHEndfyMSwq1kZNQPhF1XTzmZZGMGpf/8t9zJXzVkQxP/Xy+XYwS39+6XZXc7n5S mlMpppAhAy6789X35pYfbAXfl5qF86+p1FD66IcdvjV48sg3vaIQjDda04ZvZCstA/ 39nhjnnIy7zOFxrrMZwpsvA/V3gR53kAab1qNlKaNTAOo6okyF0dibDBecoE98X5XJ cu861MS75j2HdLo/NYha4fO8Vz9S/o7JCVxoI4ohQpeKX+FTI9M4cAgoRa38rZEnsU SPz7UQAirdj2/aD9+DqvcnMzoq9nqoyYh5AEGYYM9lsaf1qY6m8S5jYHRY+eGgPaVf Fz+XmVextTA2w== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 20/21] xfs: introduce health state for corrupted fsverity metadata Date: Sat, 3 Oct 2026 00:37:01 +0200 Message-ID: <20261002223705.2175542-21-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org Report corrupted fsverity descriptor through health system. Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_fs.h | 1 + fs/xfs/libxfs/xfs_health.h | 4 +++- fs/xfs/xfs_fsverity.c | 25 +++++++++++++++++++------ fs/xfs/xfs_health.c | 1 + 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index c80133784419..84d62b7506a9 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -422,6 +422,7 @@ struct xfs_bulkstat { #define XFS_BS_SICK_SYMLINK (1 << 6) /* symbolic link remote target */ #define XFS_BS_SICK_PARENT (1 << 7) /* parent pointers */ #define XFS_BS_SICK_DIRTREE (1 << 8) /* directory tree structure */ +#define XFS_BS_SICK_FSVERITY (1 << 9) /* fsverity metadata */ /* * Project quota id helpers (previously projid was 16bit only diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h index 1d45cf5789e8..932b447190da 100644 --- a/fs/xfs/libxfs/xfs_health.h +++ b/fs/xfs/libxfs/xfs_health.h @@ -104,6 +104,7 @@ struct xfs_rtgroup; /* Don't propagate sick status to ag health summary during inactivation */ #define XFS_SICK_INO_FORGET (1 << 12) #define XFS_SICK_INO_DIRTREE (1 << 13) /* directory tree structure */ +#define XFS_SICK_INO_FSVERITY (1 << 14) /* fsverity metadata */ /* Primary evidence of health problems in a given group. */ #define XFS_SICK_FS_PRIMARY (XFS_SICK_FS_COUNTERS | \ @@ -140,7 +141,8 @@ struct xfs_rtgroup; XFS_SICK_INO_XATTR | \ XFS_SICK_INO_SYMLINK | \ XFS_SICK_INO_PARENT | \ - XFS_SICK_INO_DIRTREE) + XFS_SICK_INO_DIRTREE | \ + XFS_SICK_INO_FSVERITY) #define XFS_SICK_INO_ZAPPED (XFS_SICK_INO_BMBTD_ZAPPED | \ XFS_SICK_INO_BMBTA_ZAPPED | \ diff --git a/fs/xfs/xfs_fsverity.c b/fs/xfs/xfs_fsverity.c index 8cffcafc19aa..7174b36c8cd3 100644 --- a/fs/xfs/xfs_fsverity.c +++ b/fs/xfs/xfs_fsverity.c @@ -96,13 +96,17 @@ xfs_fsverity_get_descriptor( if (error) return error; - if (is_empty) + if (is_empty) { + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); return -ENODATA; + } last_block_offset = XFS_FSB_TO_B(mp, rec.br_startoff + rec.br_blockcount); - if (last_block_offset <= xfs_fsverity_metadata_offset(ip)) + if (last_block_offset <= xfs_fsverity_metadata_offset(ip)) { + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); return -ENODATA; + } desc_size_pos = last_block_offset - sizeof(__be32); error = fsverity_pagecache_read(inode, (char *)&d_desc_size, @@ -111,20 +115,29 @@ xfs_fsverity_get_descriptor( return error; desc_size = be32_to_cpu(d_desc_size); - if (XFS_IS_CORRUPT(mp, desc_size > FS_VERITY_MAX_DESCRIPTOR_SIZE)) + if (XFS_IS_CORRUPT(mp, desc_size > FS_VERITY_MAX_DESCRIPTOR_SIZE)) { + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); return -ERANGE; - if (XFS_IS_CORRUPT(mp, desc_size > desc_size_pos)) + } + + if (XFS_IS_CORRUPT(mp, desc_size > desc_size_pos)) { + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); return -ERANGE; + } if (!buf_size) return desc_size; - if (XFS_IS_CORRUPT(mp, desc_size > buf_size)) + if (XFS_IS_CORRUPT(mp, desc_size > buf_size)) { + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); return -ERANGE; + } desc_pos = round_down(desc_size_pos - desc_size, blocksize); - if (desc_pos < xfs_fsverity_metadata_offset(ip)) + if (desc_pos < xfs_fsverity_metadata_offset(ip)) { + xfs_inode_mark_sick(XFS_I(inode), XFS_SICK_INO_FSVERITY); return -ERANGE; + } error = fsverity_pagecache_read(inode, buf, desc_size, desc_pos); if (error) diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c index 239b843e83d4..be66760fb120 100644 --- a/fs/xfs/xfs_health.c +++ b/fs/xfs/xfs_health.c @@ -625,6 +625,7 @@ static const struct ioctl_sick_map ino_map[] = { { XFS_SICK_INO_DIR_ZAPPED, XFS_BS_SICK_DIR }, { XFS_SICK_INO_SYMLINK_ZAPPED, XFS_BS_SICK_SYMLINK }, { XFS_SICK_INO_DIRTREE, XFS_BS_SICK_DIRTREE }, + { XFS_SICK_INO_FSVERITY, XFS_BS_SICK_FSVERITY }, }; /* Fill out bulkstat health info. */ From patchwork Fri Oct 2 12:37:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 2315406 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CoJCQSqA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=e/r7=hy=vger.kernel.org=linux-ext4+bounces-19962-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hxP0r1HDPz1xvt for ; Sat, 03 Oct 2026 08:42:04 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hxP0C3hj1z4w0Q for ; Sat, 03 Oct 2026 08:41:31 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hxP0C3fVCz4wBD; Sat, 03 Oct 2026 08:41:31 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.105.105.114 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980891; cv=pass; b=RfWGg3fP1HHyJPuoQXxWy3meuMRsdHYuCGyWI9mlhVw9+aIs2lWlFdwDr0DMf2un7Z5ohPFCpDm4HE80rOV+e1spIhyxNkXcGTux7NtdyTGnDHNqK4MvDKfSq0HbirHbfLK/hjbKDXARtbUILS9Jl8K3TCV5/L7704wc0plHDZ3gvJ/9jrpLTeZ8pXYdGfXOBVXlrrEJZjmaT+ZFLyElpbjFq83KdkK8ekteRqVRU3Io+CwZlGF8WMrmccVI659aooNomm/XLe+ayQpJHfkl3PyQznXjIJZbwLjY7hH7t5L6LtwzcihnQh6fHZHOt1IUwoyifqnVQTSGuEw6JztAwg== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790980891; c=relaxed/relaxed; bh=9UsWTPXNPtGAnC/NXDW+DJPQrI7L9qVnDZTXWpl6xCI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a48NgTsrIvh7l+i10UN7ph14FREpiSsMXI5ojTjxAOA6emTjDMu8/k1p239DvDhTJ96al4/H+179Rx6bYfJz5XLqdGyHl328xQAdCwNviobu0A0bajfMMehsVB3p6BO3dbihlnM67V1Kcs3FAhYYzHn895apWzgfhTEoAaJF43OHQ0rePDFmKpLbknwADAnVUQc0feQqTvpVcaCaDyUb7EMagmb7ehfyS0Gm0ze3wAoZmN8gdQCqhNA8l/r4oHFQ/nbkcNM7NUUR264UTT7yZftTRnhkDpB+QIxKgrrTgC5sIgs/riPoGNrW0TUElLrIpzjkAstFAvGmgCI9i/8+Cw== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CoJCQSqA; dkim-atps=neutral; spf=pass (client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19962-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CoJCQSqA; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=linux-ext4+bounces-19962-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hxP080ZQwz4w0Q for ; Sat, 03 Oct 2026 08:41:28 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 3A18C38B89 for ; Fri, 2 Oct 2026 22:38:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D2A74968EC; Fri, 2 Oct 2026 22:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CoJCQSqA" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 3402047F3B5; Fri, 2 Oct 2026 22:38:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980708; cv=none; b=KyMbKo40QcDDqYLIyZkgC/lwJc76BFazC4Rd3SIHZsYrRBtcmmpsxyrpC8SHyKWb1ShAakpoLy/Ha77qlr1oTpMfloEm4RtidtgUp6RCaq5dDJ5ViPJWxVvy1p+0keMVRlJkltab1HMqYO/QUwzHKDOc1PhiAktDHfCzTF0ukq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790980708; c=relaxed/simple; bh=zD3fqdriNeyS4psrX9dNSbGJrsTYYoWrAlK7wvQAbGQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oxpcs8rSg3deG8VG7UrL7a3J4HZugpk0jtx7iM1Y2kXzLfEQs6C0nLXz+qIiTZ+1/Il5JPUeoVHZupJJVtljhL9+1OkN6aJ7TzLz5zEUfQyDZQSCBo5V36UT8+gmPN1D1BL7BH2oKTVZ6t9ApaJAAqHtEgbZG/A/XfW+JPit4GQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CoJCQSqA; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2E791F00893; Fri, 2 Oct 2026 22:38:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790980706; bh=9UsWTPXNPtGAnC/NXDW+DJPQrI7L9qVnDZTXWpl6xCI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CoJCQSqArVqS0yKPYrOGWg4qTKQn2ygVJn+7hmo/BCrCkxzJv5atgfDpFT8avQm/g DGNvxqqoAJIbU//Wy5j4qch4BUgGKmtRXU0VNSgOUaIV4SRlbYIUYkMZNbahH/jERW e+psjlv8/NZecBW5zWx8NndLCuoWlqGOLZYGxzt25FxphFT4uGvU6xx6eEmXbP99L3 XYoFYFyPq42CpODG66a+MpnH0r2b1o85XXMEOUNG8strfFwdWMYibG5/4Y/SZoUn8i Xdz+3SXxSBQP0AnOw9jtq/I+0tVUH60SqmQUcUCoKEryplFze0e9wd1LSDkWWJ5W5J 81YnHyO6PHvcA== From: Andrey Albershteyn To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino Cc: Andrey Albershteyn , fsverity@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, david@fromorbit.com Subject: [PATCH v17 21/21] xfs: enable ro-compat fs-verity flag Date: Sat, 3 Oct 2026 00:37:02 +0200 Message-ID: <20261002223705.2175542-22-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261002223705.2175542-1-aalbersh@kernel.org> References: <20261002223705.2175542-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org Finalize fs-verity integration in XFS by making kernel fs-verity aware with ro-compat flag. Reviewed-by: Darrick J. Wong [djwong: add spaces] Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_format.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index fc196d9e12dd..8be1b101b196 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -378,8 +378,9 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_ALL \ (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ - XFS_SB_FEAT_RO_COMPAT_REFLINK| \ - XFS_SB_FEAT_RO_COMPAT_INOBTCNT) + XFS_SB_FEAT_RO_COMPAT_REFLINK | \ + XFS_SB_FEAT_RO_COMPAT_INOBTCNT | \ + XFS_SB_FEAT_RO_COMPAT_VERITY) #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature(