1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593SmuzhiyunVerity files 4*4882a593Smuzhiyun------------ 5*4882a593Smuzhiyun 6*4882a593Smuzhiyunext4 supports fs-verity, which is a filesystem feature that provides 7*4882a593SmuzhiyunMerkle tree based hashing for individual readonly files. Most of 8*4882a593Smuzhiyunfs-verity is common to all filesystems that support it; see 9*4882a593Smuzhiyun:ref:`Documentation/filesystems/fsverity.rst <fsverity>` for the 10*4882a593Smuzhiyunfs-verity documentation. However, the on-disk layout of the verity 11*4882a593Smuzhiyunmetadata is filesystem-specific. On ext4, the verity metadata is 12*4882a593Smuzhiyunstored after the end of the file data itself, in the following format: 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun- Zero-padding to the next 65536-byte boundary. This padding need not 15*4882a593Smuzhiyun actually be allocated on-disk, i.e. it may be a hole. 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun- The Merkle tree, as documented in 18*4882a593Smuzhiyun :ref:`Documentation/filesystems/fsverity.rst 19*4882a593Smuzhiyun <fsverity_merkle_tree>`, with the tree levels stored in order from 20*4882a593Smuzhiyun root to leaf, and the tree blocks within each level stored in their 21*4882a593Smuzhiyun natural order. 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun- Zero-padding to the next filesystem block boundary. 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun- The verity descriptor, as documented in 26*4882a593Smuzhiyun :ref:`Documentation/filesystems/fsverity.rst <fsverity_descriptor>`, 27*4882a593Smuzhiyun with optionally appended signature blob. 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun- Zero-padding to the next offset that is 4 bytes before a filesystem 30*4882a593Smuzhiyun block boundary. 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun- The size of the verity descriptor in bytes, as a 4-byte little 33*4882a593Smuzhiyun endian integer. 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunVerity inodes have EXT4_VERITY_FL set, and they must use extents, i.e. 36*4882a593SmuzhiyunEXT4_EXTENTS_FL must be set and EXT4_INLINE_DATA_FL must be clear. 37*4882a593SmuzhiyunThey can have EXT4_ENCRYPT_FL set, in which case the verity metadata 38*4882a593Smuzhiyunis encrypted as well as the data itself. 39*4882a593Smuzhiyun 40*4882a593SmuzhiyunVerity files cannot have blocks allocated past the end of the verity 41*4882a593Smuzhiyunmetadata. 42*4882a593Smuzhiyun 43*4882a593SmuzhiyunVerity and DAX are not compatible and attempts to set both of these flags 44*4882a593Smuzhiyunon a file will fail. 45