Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs-verity: mention btrfs support

btrfs supports fs-verity since Linux v5.15. Document this.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: David Sterba <dsterba@suse.com>
Link: https://lore.kernel.org/r/20220610000616.18225-1-ebiggers@kernel.org

+35 -28
+30 -23
Documentation/filesystems/fsverity.rst
··· 11 11 12 12 fs-verity (``fs/verity/``) is a support layer that filesystems can 13 13 hook into to support transparent integrity and authenticity protection 14 - of read-only files. Currently, it is supported by the ext4 and f2fs 15 - filesystems. Like fscrypt, not too much filesystem-specific code is 16 - needed to support fs-verity. 14 + of read-only files. Currently, it is supported by the ext4, f2fs, and 15 + btrfs filesystems. Like fscrypt, not too much filesystem-specific 16 + code is needed to support fs-verity. 17 17 18 18 fs-verity is similar to `dm-verity 19 19 <https://www.kernel.org/doc/Documentation/device-mapper/verity.txt>`_ ··· 473 473 Filesystem support 474 474 ================== 475 475 476 - fs-verity is currently supported by the ext4 and f2fs filesystems. 477 - The CONFIG_FS_VERITY kconfig option must be enabled to use fs-verity 478 - on either filesystem. 476 + fs-verity is supported by several filesystems, described below. The 477 + CONFIG_FS_VERITY kconfig option must be enabled to use fs-verity on 478 + any of these filesystems. 479 479 480 480 ``include/linux/fsverity.h`` declares the interface between the 481 481 ``fs/verity/`` support layer and filesystems. Briefly, filesystems ··· 543 543 Currently, f2fs verity only supports a Merkle tree block size of 4096. 544 544 Also, f2fs doesn't support enabling verity on files that currently 545 545 have atomic or volatile writes pending. 546 + 547 + btrfs 548 + ----- 549 + 550 + btrfs supports fs-verity since Linux v5.15. Verity-enabled inodes are 551 + marked with a RO_COMPAT inode flag, and the verity metadata is stored 552 + in separate btree items. 546 553 547 554 Implementation details 548 555 ====================== ··· 629 622 verification. Finally, pages where no decryption or verity error 630 623 occurred are marked Uptodate, and the pages are unlocked. 631 624 632 - Files on ext4 and f2fs may contain holes. Normally, ``->readahead()`` 633 - simply zeroes holes and sets the corresponding pages Uptodate; no bios 634 - are issued. To prevent this case from bypassing fs-verity, these 635 - filesystems use fsverity_verify_page() to verify hole pages. 625 + On many filesystems, files can contain holes. Normally, 626 + ``->readahead()`` simply zeroes holes and sets the corresponding pages 627 + Uptodate; no bios are issued. To prevent this case from bypassing 628 + fs-verity, these filesystems use fsverity_verify_page() to verify hole 629 + pages. 636 630 637 - ext4 and f2fs disable direct I/O on verity files, since otherwise 638 - direct I/O would bypass fs-verity. (They also do the same for 639 - encrypted files.) 631 + Filesystems also disable direct I/O on verity files, since otherwise 632 + direct I/O would bypass fs-verity. 640 633 641 634 Userspace utility 642 635 ================= ··· 655 648 To test fs-verity, use xfstests. For example, using `kvm-xfstests 656 649 <https://github.com/tytso/xfstests-bld/blob/master/Documentation/kvm-quickstart.md>`_:: 657 650 658 - kvm-xfstests -c ext4,f2fs -g verity 651 + kvm-xfstests -c ext4,f2fs,btrfs -g verity 659 652 660 653 FAQ 661 654 === ··· 778 771 e.g. magically trigger construction of a Merkle tree. 779 772 780 773 :Q: Does fs-verity support remote filesystems? 781 - :A: Only ext4 and f2fs support is implemented currently, but in 782 - principle any filesystem that can store per-file verity metadata 783 - can support fs-verity, regardless of whether it's local or remote. 784 - Some filesystems may have fewer options of where to store the 785 - verity metadata; one possibility is to store it past the end of 786 - the file and "hide" it from userspace by manipulating i_size. The 787 - data verification functions provided by ``fs/verity/`` also assume 788 - that the filesystem uses the Linux pagecache, but both local and 789 - remote filesystems normally do so. 774 + :A: So far all filesystems that have implemented fs-verity support are 775 + local filesystems, but in principle any filesystem that can store 776 + per-file verity metadata can support fs-verity, regardless of 777 + whether it's local or remote. Some filesystems may have fewer 778 + options of where to store the verity metadata; one possibility is 779 + to store it past the end of the file and "hide" it from userspace 780 + by manipulating i_size. The data verification functions provided 781 + by ``fs/verity/`` also assume that the filesystem uses the Linux 782 + pagecache, but both local and remote filesystems normally do so. 790 783 791 784 :Q: Why is anything filesystem-specific at all? Shouldn't fs-verity 792 785 be implemented entirely at the VFS level?
+5 -5
fs/verity/Kconfig
··· 14 14 help 15 15 This option enables fs-verity. fs-verity is the dm-verity 16 16 mechanism implemented at the file level. On supported 17 - filesystems (currently EXT4 and F2FS), userspace can use an 18 - ioctl to enable verity for a file, which causes the filesystem 19 - to build a Merkle tree for the file. The filesystem will then 20 - transparently verify any data read from the file against the 21 - Merkle tree. The file is also made read-only. 17 + filesystems (currently ext4, f2fs, and btrfs), userspace can 18 + use an ioctl to enable verity for a file, which causes the 19 + filesystem to build a Merkle tree for the file. The filesystem 20 + will then transparently verify any data read from the file 21 + against the Merkle tree. The file is also made read-only. 22 22 23 23 This serves as an integrity check, but the availability of the 24 24 Merkle tree root hash also allows efficiently supporting