162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ciVerity files
462306a36Sopenharmony_ci------------
562306a36Sopenharmony_ci
662306a36Sopenharmony_ciext4 supports fs-verity, which is a filesystem feature that provides
762306a36Sopenharmony_ciMerkle tree based hashing for individual readonly files.  Most of
862306a36Sopenharmony_cifs-verity is common to all filesystems that support it; see
962306a36Sopenharmony_ci:ref:`Documentation/filesystems/fsverity.rst <fsverity>` for the
1062306a36Sopenharmony_cifs-verity documentation.  However, the on-disk layout of the verity
1162306a36Sopenharmony_cimetadata is filesystem-specific.  On ext4, the verity metadata is
1262306a36Sopenharmony_cistored after the end of the file data itself, in the following format:
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci- Zero-padding to the next 65536-byte boundary.  This padding need not
1562306a36Sopenharmony_ci  actually be allocated on-disk, i.e. it may be a hole.
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci- The Merkle tree, as documented in
1862306a36Sopenharmony_ci  :ref:`Documentation/filesystems/fsverity.rst
1962306a36Sopenharmony_ci  <fsverity_merkle_tree>`, with the tree levels stored in order from
2062306a36Sopenharmony_ci  root to leaf, and the tree blocks within each level stored in their
2162306a36Sopenharmony_ci  natural order.
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci- Zero-padding to the next filesystem block boundary.
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci- The verity descriptor, as documented in
2662306a36Sopenharmony_ci  :ref:`Documentation/filesystems/fsverity.rst <fsverity_descriptor>`,
2762306a36Sopenharmony_ci  with optionally appended signature blob.
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci- Zero-padding to the next offset that is 4 bytes before a filesystem
3062306a36Sopenharmony_ci  block boundary.
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci- The size of the verity descriptor in bytes, as a 4-byte little
3362306a36Sopenharmony_ci  endian integer.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciVerity inodes have EXT4_VERITY_FL set, and they must use extents, i.e.
3662306a36Sopenharmony_ciEXT4_EXTENTS_FL must be set and EXT4_INLINE_DATA_FL must be clear.
3762306a36Sopenharmony_ciThey can have EXT4_ENCRYPT_FL set, in which case the verity metadata
3862306a36Sopenharmony_ciis encrypted as well as the data itself.
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciVerity files cannot have blocks allocated past the end of the verity
4162306a36Sopenharmony_cimetadata.
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciVerity and DAX are not compatible and attempts to set both of these flags
4462306a36Sopenharmony_cion a file will fail.
45