From patchwork Tue Apr 4 14:53:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13200351 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 800D82FAE for ; Tue, 4 Apr 2023 14:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680620110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WlIQw7/j0g439cxIh8Bf75rzXhQHTIStlmhsPCq2zc8=; b=Y3kWBAeCBYmXLA9IPNjyoG3USBm/aS7KuqCb71tAFJHuvATQZ7LBuXkHwPIXo9qt1Pp6U3 0AWXpuoecJjz5UGTEcPleHCPgNtfdSXpuLbrVi0g9pCJMDCk220/nbjiJkilG7dXTXd3pv CA9hBePlYTbSHwBnfaQRDZ1m5eAcOxc= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-AKY-TKFcMGyJiIr8mxJOWA-1; Tue, 04 Apr 2023 10:55:07 -0400 X-MC-Unique: AKY-TKFcMGyJiIr8mxJOWA-1 Received: by mail-qk1-f197.google.com with SMTP id s2-20020a37a902000000b0074a28a891baso4313981qke.18 for ; Tue, 04 Apr 2023 07:55:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680620106; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WlIQw7/j0g439cxIh8Bf75rzXhQHTIStlmhsPCq2zc8=; b=181u1Mbf1zKxdDYFdZjLIaIyTefXhY35OhWQlQyw1IfGlqdWZRmEbxFsuOkJUKGZDl Hr4OpGzu6QhYTcYHbLB8AQnszDdGekdlwgGEKb5hDGEqAznTZkngTw92akNyP0SkLNsx nRvZR0PjgX6fa6nOpN5o0aa4lXXwjXFC7w7NCd9JWN9kOtBsna9Tx2XlhIOwzzRQVm55 C0LyQxMo+MU4ALE3bfLcii63nDwlaMjUUJuttQAPvayLm0RrBnQS6FV1kb6SbrD/aBbf u4JJiQm3FpbZ5An1mU2uYKdk0wXX8ja+eb8oZLyI7pyft8guRVG5pYcPez3w8AhEUZRY 1Nuw== X-Gm-Message-State: AAQBX9dxrlaOUdfakTw8HogT9VdSYolcmbK+gfcm9NoTy5/K4mT7oF/R ajcRQHF0lrkQI64lt9/jT0YApx1FbXBVdsPoJlZOTM5gUuT5On7Q3quHplTu3QUAkwCwRLFUCv6 V9mnv/lBCFzMsuIIQCw== X-Received: by 2002:ac8:7c49:0:b0:3e4:db72:2fe9 with SMTP id o9-20020ac87c49000000b003e4db722fe9mr3470318qtv.36.1680620106386; Tue, 04 Apr 2023 07:55:06 -0700 (PDT) X-Google-Smtp-Source: AKy350ZkIqkTYw/ppN5CuEt6hgDbTeahRxMEc8GNEiOIjYIzOXDUEk9J53kAIKMBFKs3QN5nxJK1Ew== X-Received: by 2002:ac8:7c49:0:b0:3e4:db72:2fe9 with SMTP id o9-20020ac87c49000000b003e4db722fe9mr3470285qtv.36.1680620106020; Tue, 04 Apr 2023 07:55:06 -0700 (PDT) Received: from aalbersh.remote.csb ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id j4-20020ac86644000000b003e6387431dcsm3296539qtp.7.2023.04.04.07.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 07:55:05 -0700 (PDT) From: Andrey Albershteyn To: djwong@kernel.org, dchinner@redhat.com, ebiggers@kernel.org, hch@infradead.org, linux-xfs@vger.kernel.org, fsverity@lists.linux.dev Cc: rpeterso@redhat.com, agruenba@redhat.com, xiang@kernel.org, chao@kernel.org, damien.lemoal@opensource.wdc.com, jth@kernel.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, Andrey Albershteyn Subject: [PATCH v2 07/23] fsverity: pass Merkle tree block size to ->read_merkle_tree_page() Date: Tue, 4 Apr 2023 16:53:03 +0200 Message-Id: <20230404145319.2057051-8-aalbersh@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230404145319.2057051-1-aalbersh@redhat.com> References: <20230404145319.2057051-1-aalbersh@redhat.com> Precedence: bulk X-Mailing-List: fsverity@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com XFS will need to know size of Merkle tree block as these blocks will not be stored consecutively in fs blocks but under indexes in extended attributes. Signed-off-by: Andrey Albershteyn --- fs/btrfs/verity.c | 3 ++- fs/ext4/verity.c | 3 ++- fs/f2fs/verity.c | 3 ++- fs/verity/read_metadata.c | 3 ++- fs/verity/verify.c | 3 ++- include/linux/fsverity.h | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c index 4c2c09204bb4..737ad277b15a 100644 --- a/fs/btrfs/verity.c +++ b/fs/btrfs/verity.c @@ -713,7 +713,8 @@ int btrfs_get_verity_descriptor(struct inode *inode, void *buf, size_t buf_size) */ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, pgoff_t index, - unsigned long num_ra_pages) + unsigned long num_ra_pages, + u8 log_blocksize) { struct page *page; u64 off = (u64)index << PAGE_SHIFT; diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c index 35a2feb6fd68..cbf1253dd14a 100644 --- a/fs/ext4/verity.c +++ b/fs/ext4/verity.c @@ -361,7 +361,8 @@ static int ext4_get_verity_descriptor(struct inode *inode, void *buf, static struct page *ext4_read_merkle_tree_page(struct inode *inode, pgoff_t index, - unsigned long num_ra_pages) + unsigned long num_ra_pages, + u8 log_blocksize) { struct page *page; diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c index 019c7a6c6bcf..63c6a1b1bdef 100644 --- a/fs/f2fs/verity.c +++ b/fs/f2fs/verity.c @@ -256,7 +256,8 @@ static int f2fs_get_verity_descriptor(struct inode *inode, void *buf, static struct page *f2fs_read_merkle_tree_page(struct inode *inode, pgoff_t index, - unsigned long num_ra_pages) + unsigned long num_ra_pages, + u8 log_blocksize) { struct page *page; diff --git a/fs/verity/read_metadata.c b/fs/verity/read_metadata.c index cab1612bf4a3..d6cc58c24a2e 100644 --- a/fs/verity/read_metadata.c +++ b/fs/verity/read_metadata.c @@ -44,7 +44,8 @@ static int fsverity_read_merkle_tree(struct inode *inode, struct page *page; const void *virt; - page = vops->read_merkle_tree_page(inode, index, num_ra_pages); + page = vops->read_merkle_tree_page(inode, index, num_ra_pages, + vi->tree_params.log_blocksize); if (IS_ERR(page)) { err = PTR_ERR(page); fsverity_err(inode, diff --git a/fs/verity/verify.c b/fs/verity/verify.c index c2fc4c86af34..9213b1e5ed2c 100644 --- a/fs/verity/verify.c +++ b/fs/verity/verify.c @@ -199,7 +199,8 @@ verify_data_block(struct inode *inode, struct fsverity_info *vi, hpage = inode->i_sb->s_vop->read_merkle_tree_page(inode, hpage_idx, level == 0 ? min(max_ra_pages, - params->tree_pages - hpage_idx) : 0); + params->tree_pages - hpage_idx) : 0, + params->log_blocksize); if (IS_ERR(hpage)) { err = PTR_ERR(hpage); fsverity_err(inode, diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h index 3e923a8e0d6f..ad07a1d10fdf 100644 --- a/include/linux/fsverity.h +++ b/include/linux/fsverity.h @@ -103,7 +103,8 @@ struct fsverity_operations { */ struct page *(*read_merkle_tree_page)(struct inode *inode, pgoff_t index, - unsigned long num_ra_pages); + unsigned long num_ra_pages, + u8 log_blocksize); /** * Write a Merkle tree block to the given inode.