xref: /openbmc/linux/Documentation/filesystems/ext4/verity.rst (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
184fb7ca4SEric Biggers.. SPDX-License-Identifier: GPL-2.0
284fb7ca4SEric Biggers
384fb7ca4SEric BiggersVerity files
484fb7ca4SEric Biggers------------
584fb7ca4SEric Biggers
684fb7ca4SEric Biggersext4 supports fs-verity, which is a filesystem feature that provides
784fb7ca4SEric BiggersMerkle tree based hashing for individual readonly files.  Most of
884fb7ca4SEric Biggersfs-verity is common to all filesystems that support it; see
984fb7ca4SEric Biggers:ref:`Documentation/filesystems/fsverity.rst <fsverity>` for the
1084fb7ca4SEric Biggersfs-verity documentation.  However, the on-disk layout of the verity
1184fb7ca4SEric Biggersmetadata is filesystem-specific.  On ext4, the verity metadata is
1284fb7ca4SEric Biggersstored after the end of the file data itself, in the following format:
1384fb7ca4SEric Biggers
1484fb7ca4SEric Biggers- Zero-padding to the next 65536-byte boundary.  This padding need not
1584fb7ca4SEric Biggers  actually be allocated on-disk, i.e. it may be a hole.
1684fb7ca4SEric Biggers
1784fb7ca4SEric Biggers- The Merkle tree, as documented in
1884fb7ca4SEric Biggers  :ref:`Documentation/filesystems/fsverity.rst
1984fb7ca4SEric Biggers  <fsverity_merkle_tree>`, with the tree levels stored in order from
2084fb7ca4SEric Biggers  root to leaf, and the tree blocks within each level stored in their
2184fb7ca4SEric Biggers  natural order.
2284fb7ca4SEric Biggers
2384fb7ca4SEric Biggers- Zero-padding to the next filesystem block boundary.
2484fb7ca4SEric Biggers
2584fb7ca4SEric Biggers- The verity descriptor, as documented in
2684fb7ca4SEric Biggers  :ref:`Documentation/filesystems/fsverity.rst <fsverity_descriptor>`,
2784fb7ca4SEric Biggers  with optionally appended signature blob.
2884fb7ca4SEric Biggers
2984fb7ca4SEric Biggers- Zero-padding to the next offset that is 4 bytes before a filesystem
3084fb7ca4SEric Biggers  block boundary.
3184fb7ca4SEric Biggers
3284fb7ca4SEric Biggers- The size of the verity descriptor in bytes, as a 4-byte little
3384fb7ca4SEric Biggers  endian integer.
3484fb7ca4SEric Biggers
3584fb7ca4SEric BiggersVerity inodes have EXT4_VERITY_FL set, and they must use extents, i.e.
3684fb7ca4SEric BiggersEXT4_EXTENTS_FL must be set and EXT4_INLINE_DATA_FL must be clear.
3784fb7ca4SEric BiggersThey can have EXT4_ENCRYPT_FL set, in which case the verity metadata
3884fb7ca4SEric Biggersis encrypted as well as the data itself.
3984fb7ca4SEric Biggers
4084fb7ca4SEric BiggersVerity files cannot have blocks allocated past the end of the verity
4184fb7ca4SEric Biggersmetadata.
42*6c0d077fSIra Weiny
43*6c0d077fSIra WeinyVerity and DAX are not compatible and attempts to set both of these flags
44*6c0d077fSIra Weinyon a file will fail.
45