• Eric Biggers's avatar
    fsverity: support verification with tree block size < PAGE_SIZE · 5306892a
    Eric Biggers authored
    Add support for verifying data from verity files whose Merkle tree block
    size is less than the page size.  The main use case for this is to allow
    a single Merkle tree block size to be used across all systems, so that
    only one set of fsverity file digests and signatures is needed.
    
    To do this, eliminate various assumptions that the Merkle tree block
    size and the page size are the same:
    
    - Make fsverity_verify_page() a wrapper around a new function
      fsverity_verify_blocks() which verifies one or more blocks in a page.
    
    - When a Merkle tree block is needed, get the corresponding page and
      only verify and use the needed portion.  (The Merkle tree continues to
      be read and cached in page-sized chunks; that doesn't need to change.)
    
    - When the Merkle tree block size and page size differ, use a bitmap
      fsverity_info::hash_block_verified to keep track of which Merkle tree
      blocks have been verified, as PageChecked cannot be used directly.
    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-7-ebiggers@kernel.org
    5306892a
verify.c 13 KB