From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YFnGtyyB" 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 Content-Transfer-Encoding: 8bit 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 -- 2.54.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA920CA5FE7 for ; Fri, 2 Oct 2026 22:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-ID:Date:To:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HFXTACBcqTGoUkMUxfI5QPrW1pcN/XDdRgzuLi95mg0=; b=RS3GnOwJKuXCBUnEOVMszIB8NN 3qW28bucBvebPlyRNNqf49gsPv2tbVZft7459xlORTy5iFNlaykCrRo6W3YMU+RhJtR3tFTgN/9/+ C6aqoRxDhNtfOFNeZV+fS0zPaqRtlD1wOs6cdknguwSkGCY0ZTk8b0Ta6Q1tyBEb5BUk=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1xClsj-0007FX-N5; Fri, 02 Oct 2026 22:37:31 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1xClsi-0007FR-BG for linux-f2fs-devel@lists.sourceforge.net; Fri, 02 Oct 2026 22:37:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ocelP5BLZjaYNqJA/jF/UJ2BfrTGPj5YgQPaa6hhf5Q=; b=IZBXhb2BFwic7Bq+Sm0/zyK61G WpcLj92ZtiKTd+XWH0B9+IgsrQzhV1Z7W9dBxMEcOlD7Y1A27lF+gJdsDFT+bMkNWxg+ziFOu7i7c 648UoGQtfsxhn4Oo8mtkeSlREVUi3Ey1etOp2+HSdZV1kXhMvBi9jDcSCYz+SRWwmq0k=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ocelP5BLZjaYNqJA/jF/UJ2BfrTGPj5YgQPaa6hhf5Q=; b=IpvU2KmXOTN8J7vCLYFSrJu9xJ PvtB6G5/uqRTdSpcobO0TCzM0fYf6v5oQwDSDiU/hVoPDhcc+b4bbkv/i4+8MNSXAYGdIsxLvRQWn 8gF5vDgRBeIqiCoECL0tv25smHCoTcgZa1jGsLbicAwIcZw4HjZyKuDtOkK00RkG9cwM=; Received: from tor.source.kernel.org ([172.105.4.254]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1xClsf-0003iK-9f for linux-f2fs-devel@lists.sourceforge.net; Fri, 02 Oct 2026 22:37:29 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id B5CCA60214; Fri, 2 Oct 2026 22:37:23 +0000 (UTC) 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== To: djwong@kernel.org, ebiggers@kernel.org, hch@lst.de, Carlos Maiolino 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> MIME-Version: 1.0 X-Headers-End: 1xClsf-0003iK-9f Subject: [f2fs-dev] [PATCH v17 03/21] fsverity: pass digest size and hash of the all-zeroes block to ->write X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrey Albershteyn via Linux-f2fs-devel Reply-To: Andrey Albershteyn Cc: fsverity@lists.linux.dev, Andrey Albershteyn , david@fromorbit.com, linux-unionfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, David Sterba , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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 -- 2.54.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel