• Eric Biggers's avatar
    fsverity: support enabling with tree block size < PAGE_SIZE · 56124d6c
    Eric Biggers authored
    Make FS_IOC_ENABLE_VERITY support values of
    fsverity_enable_arg::block_size other than PAGE_SIZE.
    
    To make this possible, rework build_merkle_tree(), which was reading
    data and hash pages from the file and assuming that they were the same
    thing as "blocks".
    
    For reading the data blocks, just replace the direct pagecache access
    with __kernel_read(), to naturally read one block at a time.
    
    (A disadvantage of the above is that we lose the two optimizations of
    hashing the pagecache pages in-place and forcing the maximum readahead.
    That shouldn't be very important, though.)
    
    The hash block reads are a bit more difficult to handle, as the only way
    to do them is through fsverity_operations::read_merkle_tree_page().
    
    Instead, let's switch to the single-pass tree construction algorithm
    that fsverity-utils uses.  This eliminates the need to read back any
    hash blocks while the tree is being built, at the small cost of an extra
    block-sized memory buffer per Merkle tree level.  This is probably what
    I should have done originally.
    
    Taken together, the above two changes result in page-size independent
    code that is also a bit simpler than what we had before.
    Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
    Reviewed-by: default avatarAndrey Albershteyn <aalbersh@redhat.com>
    Tested-by: default avatarOjaswin Mujoo <ojaswin@linux.ibm.com>
    Link: https://lore.kernel.org/r/20221223203638.41293-8-ebiggers@kernel.org
    56124d6c
fsverity.rst 36.6 KB