[PATCHSET v5.5 1/2] fs-verity: support merkle tree access by blocks

Darrick J. Wong
2024-03-30T00:32:25Z

Hi all,

I've split Andrey's fsverity patchset into two parts -- refactoring
fsverity to support per-block (instead of per-page) access to merkle
tree blocks, moving all filesystems to a per-superblock workqueue, and
enhancing iomap to support validating readahead with fsverity data.
This will hopefully address everything that Eric Biggers noted in his
review of the v5 patchset.

To eliminate the requirement of using a verified bitmap, I added to the
fsverity_blockbuf object the ability to pass around verified bits so
that the underlying implementation can remember if the fsverity common
code actually validated a block.

To support cleaning up stale/dead merkle trees and online repair, I've
added a couple of patches to export enough of the merkle tree geometry
to XFS so that it can erase remnants of previous attempts to enable
verity. I've also augmented it to share with XFS the hash of a
completely zeroed data block so that we can elide writing merkle leaves
for sparse regions of a file. This might be useful for enabling
fsverity on gold master disk images.

If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.

This has been running on the djcloud for months with no problems. Enjoy!
Comments and questions are, as always, welcome.

--D

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=fsverity-by-block
---
Commits in this patchset:
* fs: add FS_XFLAG_VERITY for verity files
* fsverity: pass tree_blocksize to end_enable_verity()
* fsverity: support block-based Merkle tree caching
* fsverity: add per-sb workqueue for post read processing
* fsverity: add tracepoints
* fsverity: send the level of the merkle tree block to ->read_merkle_tree_block
* fsverity: pass the new tree size and block size to ->begin_enable_verity
* fsverity: expose merkle tree geometry to callers
* fsverity: box up the write_merkle_tree_block parameters too
* fsverity: pass the zero-hash value to the implementation
* fsverity: report validation errors back to the filesystem
* fsverity: remove system-wide workqueue
* iomap: integrate fs-verity verification into iomap's read path
---
Documentation/filesystems/fsverity.rst | 8 +
MAINTAINERS | 1
fs/btrfs/super.c | 6 +
fs/btrfs/verity.c | 13 +-
fs/buffer.c | 7 +
fs/ext4/readpage.c | 5 +
fs/ext4/super.c | 3
fs/ext4/verity.c | 13 +-
fs/f2fs/compress.c | 3
fs/f2fs/data.c | 2
fs/f2fs/super.c | 3
fs/f2fs/verity.c | 13 +-
fs/ioctl.c | 11 ++
fs/iomap/buffered-io.c | 128 +++++++++++++++++-
fs/super.c | 7 +
fs/verity/enable.c | 20 ++-
fs/verity/fsverity_private.h | 41 ++++++
fs/verity/init.c | 2
fs/verity/open.c | 40 +++++-
fs/verity/read_metadata.c | 63 ++++-----
fs/verity/verify.c | 227 +++++++++++++++++++++++---------
include/linux/fs.h | 2
include/linux/fsverity.h | 159 +++++++++++++++++++++-
include/linux/iomap.h | 4 +
include/trace/events/fsverity.h | 142 ++++++++++++++++++++
include/uapi/linux/fs.h | 1
26 files changed, 788 insertions(+), 136 deletions(-)
create mode 100644 include/trace/events/fsverity.h