18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ciVerity files 48c2ecf20Sopenharmony_ci------------ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ciext4 supports fs-verity, which is a filesystem feature that provides 78c2ecf20Sopenharmony_ciMerkle tree based hashing for individual readonly files. Most of 88c2ecf20Sopenharmony_cifs-verity is common to all filesystems that support it; see 98c2ecf20Sopenharmony_ci:ref:`Documentation/filesystems/fsverity.rst <fsverity>` for the 108c2ecf20Sopenharmony_cifs-verity documentation. However, the on-disk layout of the verity 118c2ecf20Sopenharmony_cimetadata is filesystem-specific. On ext4, the verity metadata is 128c2ecf20Sopenharmony_cistored after the end of the file data itself, in the following format: 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci- Zero-padding to the next 65536-byte boundary. This padding need not 158c2ecf20Sopenharmony_ci actually be allocated on-disk, i.e. it may be a hole. 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci- The Merkle tree, as documented in 188c2ecf20Sopenharmony_ci :ref:`Documentation/filesystems/fsverity.rst 198c2ecf20Sopenharmony_ci <fsverity_merkle_tree>`, with the tree levels stored in order from 208c2ecf20Sopenharmony_ci root to leaf, and the tree blocks within each level stored in their 218c2ecf20Sopenharmony_ci natural order. 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci- Zero-padding to the next filesystem block boundary. 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci- The verity descriptor, as documented in 268c2ecf20Sopenharmony_ci :ref:`Documentation/filesystems/fsverity.rst <fsverity_descriptor>`, 278c2ecf20Sopenharmony_ci with optionally appended signature blob. 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci- Zero-padding to the next offset that is 4 bytes before a filesystem 308c2ecf20Sopenharmony_ci block boundary. 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci- The size of the verity descriptor in bytes, as a 4-byte little 338c2ecf20Sopenharmony_ci endian integer. 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciVerity inodes have EXT4_VERITY_FL set, and they must use extents, i.e. 368c2ecf20Sopenharmony_ciEXT4_EXTENTS_FL must be set and EXT4_INLINE_DATA_FL must be clear. 378c2ecf20Sopenharmony_ciThey can have EXT4_ENCRYPT_FL set, in which case the verity metadata 388c2ecf20Sopenharmony_ciis encrypted as well as the data itself. 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciVerity files cannot have blocks allocated past the end of the verity 418c2ecf20Sopenharmony_cimetadata. 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ciVerity and DAX are not compatible and attempts to set both of these flags 448c2ecf20Sopenharmony_cion a file will fail. 45