Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796230723; b=locYZToCK/o66wJDbktujlSQqhvkCs7GRkZ3JjA5gBzZ4za7l74+x6M4PGLD6hlvhduC /VLOVjX6NQjGroiDBS7sX7ETiLRHMzRGFQDxBisymSKMBpaWX99USYYwdoF/OxG1DZoSZ lzHYRG9D2iiifhWESURzncdLEim9ItYv4pZMkEAbGvdxjJzp3ShrU7uRXeav9TU1dhH+f 1YMomyKvuGcSAD8Bp289djNMEZ2Qgf+lH5PytyqU9I5026rSaYRbre01oX+Huwy/nLzst LPsRpesXOfuyEbiAoyzxVHjdqH8fn3eV9x64s01hZWWZOrXGnRlCqN2hUUb1g5tYo1A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796230723; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=HpOaQD0Cx/AAbBFHN9MH/hBoLl9WFQ34wLjBxlUqOYk=; b=TkJjAsG9ccWkAjUGeCBjR0rPeRjpoL1mAe3+QrUKpnC6dJ1xcAwhtfSLAn/yiUHkOaAx cEmbAQ3Y6Uhj1XN6lCMVgqMhNbnwZqhMav48NDiAHIEtOT05vs1Hz4oIKrYcE6sGFBT8E +NoQsmq/cPeJqVayL3w7s8xDnrJT5g8fV5Hdj673pWaBRCDhfIvaIOOWC8To+LZKO/QJK zLN/Lk0z40U/uXIohCkf/cHojCw83+Xmz2qK1iEuffQ4XlYzj0wmB34bp6jCp4xTbitcC G4MVYRNHpxVU9FIrs75a0HjFN26RuVWeCIYU2KRWj7+oN/4AntfdG1P2jHOcmyV4ldg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RfTW6kVr; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CC35606A327; Wed, 2 Dec 2026 16:58:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RfTW6kVr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 402D81F00932; Wed, 2 Dec 2026 16:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796230722; bh=HpOaQD0Cx/AAbBFHN9MH/hBoLl9WFQ34wLjBxlUqOYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RfTW6kVr1ks9Ac278vI68VNTcP6cto4tjtg25Zh4ttdACp0f/6UQ+TgQe7i+tRZSR mpNf19MuUp75c2IEeL5xzQCodKqRDtNb/qOmJvH99QeVckx/1SrJmDdyLRp8TovJpo HpeWO32fWsCEu5HvzhpQzdQwfqxV4KrYq1x1r3xISXIAwGCTlhqRzwJpoaHzYYNk5h 38UpPqlv76mB28SKlJ0YiaPgGWTB93N/zSgWTiaJ9+WmMTZOfLX/Xkfa1GFikY7mNa hFikkQn5dUkdL9xHDNcYcmClCpe0EzEVShKkKQ541YMEm1HTHjraWc7JxWmvJhGNw6 vqVB4MhDHUHRg== From: Andrey Albershteyn To: "fsdevel" , "linux-ext4" , "linux-btrfs" , "linux-f2fs" , "Eric Biggers" , "Christoph Hellwig" , "Carlos Maiolino" , "fsverity" , "linux-xfs" Cc: "Christian Brauner" , Andrey Albershteyn , david@fromorbit.com Subject: [PATCH v20 17/23] xfs: add fs-verity support Date: Wed, 2 Dec 2026 17:56:47 +0100 Message-ID: <20261202165653.767961-18-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261202165653.767961-1-aalbersh@kernel.org> References: <20261202165653.767961-1-aalbersh@kernel.org> X-Mailing-List: fsverity@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add integration with fs-verity. XFS stores fs-verity descriptor and Merkle tree in the inode data fork at first block aligned to 64k past EOF. The Merkle tree reading/writing is done through iomap interface. The data itself is read to the inode's page cache. When XFS reads from this region iomap doesn't call into fsverity to verify it against Merkle tree. For data, verification is done at ioend completion in a workqueue. The metadata building starts with flushing pagecache and cleaning up any residue extents past EOF. Over whole initialization period I_VERITY_BUILDING indicates that merkle tree building is in progress. No iolock is held over this period. After core fsverity code done with building the tree, XFS stores verity descriptor, then flushes page cache again, then pro-actively remove any delayed allocation and unwritten extents past EOF and ends up with setting inode on-disk flag (XFS_DIFLAG2_VERITY). The descriptor is stored in a new block aligned to 64k after the last Merkle tree block. The size of the descriptor is stored at the end of the last descriptor block (descriptor can be multiple blocks). Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_inode_buf.c | 11 + fs/xfs/xfs_fsverity.c | 456 +++++++++++++++++++++++++++++++++- fs/xfs/xfs_fsverity.h | 2 + fs/xfs/xfs_ioctl.c | 20 ++ fs/xfs/xfs_message.c | 4 + fs/xfs/xfs_message.h | 1 + fs/xfs/xfs_mount.h | 2 + fs/xfs/xfs_super.c | 8 +- 8 files changed, 502 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 13042e1eaf35..fdcfc1f3f472 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -764,6 +764,17 @@ xfs_dinode_verify( return __this_address; if (!S_ISREG(mode)) return __this_address; + /* + * fs-verity stores the Merkle tree past EOF, so it cannot + * coexist with a realtime allocation unit larger than a single + * filesystem block. This is because we remove any unwritten + * extents beyond EOF for fs-verity inodes. The realtime inode + * with larger extents could have EOF in the middle of the + * extent. Enabling fsverity on such inode could lead to removal + * of data before EOF. + */ + if ((flags & XFS_DIFLAG_REALTIME) && mp->m_sb.sb_rextsize > 1) + return __this_address; } if (xfs_has_zoned(mp) && diff --git a/fs/xfs/xfs_fsverity.c b/fs/xfs/xfs_fsverity.c index 8fc3e763c017..1c1cc5a6462b 100644 --- a/fs/xfs/xfs_fsverity.c +++ b/fs/xfs/xfs_fsverity.c @@ -6,13 +6,22 @@ #include "xfs_fs.h" #include "xfs_shared.h" #include "xfs_format.h" -#include "xfs_log_format.h" #include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_inode.h" +#include "xfs_log_format.h" +#include "xfs_trans.h" +#include "xfs_trace.h" +#include "xfs_quota.h" #include "xfs_fsverity.h" +#include "xfs_iomap.h" +#include "xfs_error.h" +#include "xfs_health.h" +#include "xfs_bmap_util.h" +#include "xfs_icache.h" #include #include +#include struct kmem_cache *xfs_fsverity_ioend_cache; mempool_t xfs_fsverity_ioend_pool; @@ -44,3 +53,448 @@ xfs_fsverity_is_file_data( return fsverity_active(VFS_IC(ip)) && offset < xfs_fsverity_metadata_offset(ip); } + +/* + * Retrieve the verity descriptor. + */ +static int +xfs_fsverity_get_descriptor( + struct inode *inode, + void *buf, + size_t buf_size) +{ + struct xfs_inode *ip = XFS_I(inode); + struct xfs_mount *mp = ip->i_mount; + __be32 d_desc_size; + u32 desc_size; + u64 desc_size_pos; + int error; + u64 desc_pos; + struct xfs_bmbt_irec rec; + int is_empty; + uint32_t blocksize = i_blocksize(VFS_I(ip)); + xfs_fileoff_t last_block_offset; + + /* + * fs-verity cannot be used when the filesystem block size exceeds the + * page size, as the Merkle tree folios are compound and PG_checked is + * not supported on compound folios. Reject such inodes so that they + * cannot be opened and read as verity files. + */ + if (mp->m_sb.sb_blocksize > PAGE_SIZE) + return -EOPNOTSUPP; + + xfs_ilock(ip, XFS_ILOCK_EXCL); + /* + * Serialize reading of inode->i_flags with xfs_scrub clearing of this + * flag if inode is corrupted. + */ + if (!(inode->i_flags & S_VERITY)) { + xfs_iunlock(ip, XFS_ILOCK_EXCL); + return -ENODATA; + } + error = xfs_bmap_last_extent(NULL, ip, XFS_DATA_FORK, &rec, &is_empty); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + if (error) + return error; + + if (is_empty) + return -ENODATA; + + /* + * Make sure we can open large file on a 32-bit kernel + */ + if (rec.br_startoff + rec.br_blockcount > + XFS_B_TO_FSB(mp, inode->i_sb->s_maxbytes)) + return -EFBIG; + + last_block_offset = + XFS_FSB_TO_B(mp, rec.br_startoff + rec.br_blockcount); + if (last_block_offset <= xfs_fsverity_metadata_offset(ip)) + return -ENODATA; + + desc_size_pos = last_block_offset - sizeof(__be32); + error = fsverity_pagecache_read(inode, (char *)&d_desc_size, + sizeof(d_desc_size), desc_size_pos); + if (error) + return error; + + desc_size = be32_to_cpu(d_desc_size); + if (XFS_IS_CORRUPT(mp, desc_size > FS_VERITY_MAX_DESCRIPTOR_SIZE)) + return -ERANGE; + if (XFS_IS_CORRUPT(mp, desc_size > desc_size_pos)) + return -ERANGE; + + if (!buf_size) + return desc_size; + + if (desc_size > buf_size) + return -ERANGE; + + if (XFS_IS_CORRUPT(mp, + desc_size < sizeof(struct fsverity_descriptor))) + return -ERANGE; + + desc_pos = round_down(desc_size_pos - desc_size, blocksize); + if (desc_pos < xfs_fsverity_metadata_offset(ip)) + return -ERANGE; + + error = fsverity_pagecache_read(inode, buf, desc_size, desc_pos); + if (error) + return error; + + return desc_size; +} + +static int +xfs_fsverity_write_descriptor( + struct file *file, + const void *desc, + u32 desc_size, + u64 merkle_tree_size) +{ + int error; + struct inode *inode = file_inode(file); + struct xfs_inode *ip = XFS_I(inode); + unsigned int blksize = ip->i_mount->m_sb.sb_blocksize; + u64 tree_last_block = + xfs_fsverity_metadata_offset(ip) + merkle_tree_size; + u64 desc_pos = + round_up(tree_last_block, XFS_FSVERITY_START_ALIGN); + u64 desc_end = desc_pos + desc_size; + __be32 desc_size_disk = cpu_to_be32(desc_size); + u64 desc_size_pos = + round_up(desc_end + sizeof(desc_size_disk), blksize) - + sizeof(desc_size_disk); + + if (desc_size_pos + sizeof(desc_size_disk) > inode->i_sb->s_maxbytes) + return -EFBIG; + + error = iomap_fsverity_write(file, desc_size_pos, sizeof(__be32), + (const void *)&desc_size_disk, + xfs_buffered_write_iomap_next, + &xfs_iomap_write_ops); + if (error) + return error; + + return iomap_fsverity_write(file, desc_pos, desc_size, desc, + xfs_buffered_write_iomap_next, + &xfs_iomap_write_ops); +} + +/* + * Try to remove all the fsverity metadata after a failed enablement. + */ +static int +xfs_fsverity_delete_metadata( + struct xfs_inode *ip) +{ + struct xfs_trans *tp; + struct xfs_mount *mp = ip->i_mount; + int error; + + xfs_ilock(ip, XFS_MMAPLOCK_EXCL); + truncate_inode_pages(VFS_I(ip)->i_mapping, XFS_ISIZE(ip)); + + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); + if (error) { + xfs_iunlock(ip, XFS_MMAPLOCK_EXCL); + return error; + } + + xfs_ilock(ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); + + /* + * We remove post EOF data, no need to update i_size as fsverity + * didn't move i_size in the first place + */ + error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, XFS_ISIZE(ip)); + if (error) + goto err_cancel; + + error = xfs_trans_commit(tp); + xfs_iunlock(ip, XFS_MMAPLOCK_EXCL | XFS_ILOCK_EXCL); + return error; +err_cancel: + xfs_trans_cancel(tp); + xfs_iunlock(ip, XFS_MMAPLOCK_EXCL | XFS_ILOCK_EXCL); + return error; +} + +static int +xfs_fsverity_reset_inode( + struct xfs_inode *ip) +{ + int error; + struct xfs_mount *mp = ip->i_mount; + struct xfs_trans *tp; + + error = xfs_fsverity_delete_metadata(ip); + if (error) + return error; + + /* + * First, let's clean in-memory fsverity flag and then reset it on the + * disk + */ + inode_set_flags(VFS_I(ip), 0, S_VERITY); + + /* + * Set fsverity inode flag + */ + error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_ichange, + 0, 0, false, &tp); + if (error) + return error; + + ip->i_diflags2 &= ~XFS_DIFLAG2_VERITY; + + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); + xfs_trans_set_sync(tp); + + error = xfs_trans_commit(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + return error; +} + +/* + * Prepare to enable fsverity by clearing old metadata. + */ +static int +xfs_fsverity_begin_enable( + struct file *filp) +{ + struct inode *inode = file_inode(filp); + struct xfs_inode *ip = XFS_I(inode); + int error; + + xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL); + + if (IS_DAX(inode) || ip->i_diflags2 & XFS_DIFLAG2_DAX) + return -EINVAL; + + /* + * fs-verity tracks verified Merkle tree pages using PG_checked, which + * is only valid on single-page (non-compound) folios. When the + * filesystem block size is larger than the page size, the page cache + * enforces a minimum folio order > 0, so all Merkle tree folios are + * compound. fs-verity cannot be used on such filesystems. + */ + if (ip->i_mount->m_sb.sb_blocksize > PAGE_SIZE) + return -EOPNOTSUPP; + + /* + * fs-verity doesn't work on zoned + */ + if (xfs_is_zoned_inode(ip)) + return -EOPNOTSUPP; + + /* + * fs-verity stores the Merkle tree past EOF in units of the filesystem + * block size, so it cannot support realtime files whose allocation unit + * (extent size) is larger than the block size. + */ + if (xfs_inode_has_bigrtalloc(ip)) + return -EINVAL; + + if (XFS_B_TO_FSB(ip->i_mount, inode->i_size) > + XFS_FSVERITY_LARGEST_FILE_FSB(ip->i_mount)) + return -EFBIG; + + /* + * Flush pagecache before building Merkle tree. Inode is locked and no + * further writes will happen to the file except fsverity metadata + */ + error = filemap_write_and_wait(inode->i_mapping); + if (error) + return error; + + error = xfs_qm_dqattach(ip); + if (error) + return error; + + return xfs_fsverity_delete_metadata(ip); +} + +/* + * Complete (or fail) the process of enabling fsverity. + */ +static int +xfs_fsverity_end_enable( + struct file *file, + const void *desc, + size_t desc_size, + u64 merkle_tree_size) +{ + struct inode *inode = file_inode(file); + struct xfs_inode *ip = XFS_I(inode); + struct xfs_mount *mp = ip->i_mount; + struct xfs_trans *tp; + int error = 0; + int error2; + loff_t range_start = xfs_fsverity_metadata_offset(ip); + + xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL); + + /* fs-verity failed, just cleanup */ + if (desc == NULL) + goto out; + + error = xfs_fsverity_write_descriptor(file, desc, desc_size, + merkle_tree_size); + if (error) + goto out; + + /* + * Wait for Merkle tree get written to disk before setting on-disk inode + * flag and clearing I_VERITY_BUILDING + */ + error = filemap_write_and_wait_range(inode->i_mapping, range_start, + LLONG_MAX); + if (error) + goto out; + + /* + * Proactively remove unwritten extents left by COW preallocations and + * write preallocation in the merkle tree holes and past descriptor, + * and any delayed preallocations + */ + error = xfs_free_eofblocks(ip); + if (error) + goto out; + + /* + * Set fsverity inode flag + */ + error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_ichange, + 0, 0, false, &tp); + if (error) + goto out; + + /* + * Ensure that we've persisted the verity information before we enable + * it on the inode and tell the caller we have sealed the inode. + */ + ip->i_diflags2 |= XFS_DIFLAG2_VERITY; + + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); + xfs_trans_set_sync(tp); + + error = xfs_trans_commit(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + if (error) + goto out; + + inode_set_flags(inode, S_VERITY, S_VERITY); + return error; + +out: + error2 = xfs_fsverity_reset_inode(ip); + if (error2) + xfs_alert(ip->i_mount, +"ino 0x%llx failed to clean up new fsverity metadata, err %d", + I_INO(ip), error2); + + return error; +} + +/* + * Retrieve a merkle tree block. + */ +static struct page * +xfs_fsverity_read_merkle( + struct inode *inode, + pgoff_t index) +{ + index += xfs_fsverity_metadata_offset(XFS_I(inode)) >> PAGE_SHIFT; + + return generic_read_merkle_tree_page(inode, index); +} + +/* + * Retrieve a merkle tree block. + */ +static void +xfs_fsverity_readahead_merkle_tree( + struct inode *inode, + pgoff_t index, + unsigned long nr_pages) +{ + index += xfs_fsverity_metadata_offset(XFS_I(inode)) >> PAGE_SHIFT; + + generic_readahead_merkle_tree(inode, index, nr_pages); +} + +static inline bool +xfs_fsverity_is_hashes_of_zeroed_blocks( + struct xfs_inode *ip, + const void *buf, + unsigned int size, + const u8 *zero_digest, + unsigned int digest_size) +{ + /* + * If this is a block full of hashes of zeroed blocks, don't bother + * storing the block. We can synthesize them later. + * + * However, do this only in case Merkle tree block == fs block size. + * Iomap synthesizes these blocks based on holes in the merkle tree. We + * won't be able to tell if something need to be synthesizes for the + * range in the fs block. For example, for 4k filesystem block + * + * [ 1k | zero hashes | zero hashes | 1k ] + * + * Iomap won't know about these empty blocks. + */ + if (size != ip->i_mount->m_sb.sb_blocksize) + return false; + /* + * First digest is zero_digest + */ + if (memcmp(buf, zero_digest, digest_size)) + return false; + /* + * Every digest is same as previous, thus all are + * zero_digest + */ + return memcmp(buf + digest_size, buf, size - digest_size) == 0; +} + +/* + * Write a merkle tree block. + */ +static int +xfs_fsverity_write_merkle( + struct file *file, + const void *buf, + u64 pos, + unsigned int size, + const u8 *zero_digest, + unsigned int digest_size) +{ + struct inode *inode = file_inode(file); + struct xfs_inode *ip = XFS_I(inode); + loff_t position = pos + + xfs_fsverity_metadata_offset(ip); + + if (position + size > inode->i_sb->s_maxbytes) + return -EFBIG; + + if (xfs_fsverity_is_hashes_of_zeroed_blocks(ip, buf, size, zero_digest, + digest_size)) + return 0; + + return iomap_fsverity_write(file, position, size, buf, + xfs_buffered_write_iomap_next, + &xfs_iomap_write_ops); +} + +const struct fsverity_operations xfs_fsverity_ops = { + .begin_enable_verity = xfs_fsverity_begin_enable, + .end_enable_verity = xfs_fsverity_end_enable, + .get_verity_descriptor = xfs_fsverity_get_descriptor, + .read_merkle_tree_page = xfs_fsverity_read_merkle, + .readahead_merkle_tree = xfs_fsverity_readahead_merkle_tree, + .write_merkle_tree_block = xfs_fsverity_write_merkle, +}; diff --git a/fs/xfs/xfs_fsverity.h b/fs/xfs/xfs_fsverity.h index 44f7bc7831f2..43f8ef62e12a 100644 --- a/fs/xfs/xfs_fsverity.h +++ b/fs/xfs/xfs_fsverity.h @@ -8,9 +8,11 @@ #include "xfs_platform.h" #include "xfs_verity.h" #include +#include #include #ifdef CONFIG_FS_VERITY +extern const struct fsverity_operations xfs_fsverity_ops; int xfs_fsverity_init(void); void xfs_fsverity_exit(void); bool xfs_fsverity_is_file_data(const struct xfs_inode *ip, loff_t offset); diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index c76e36dadf95..c4199c5f9079 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -49,6 +49,7 @@ #include #include +#include /* Return 0 on success or positive error */ int @@ -562,6 +563,14 @@ xfs_ioctl_setattr_xflags( if (xfs_inode_has_filedata(ip)) return -EINVAL; + /* + * fs-verity is incompatible with a realtime allocation unit + * larger than a single filesystem block, so don't let a file be + * converted to realtime while verity is being enabled. + */ + if (fsverity_is_building(VFS_IC(ip))) + return -EINVAL; + /* * If S_DAX is enabled on this file, we can only switch the * device if both support fsdax, and the zoned code does not. @@ -576,6 +585,17 @@ xfs_ioctl_setattr_xflags( return -EINVAL; } + /* + * fs-verity is incompatible with DAX, and xfs_fsverity_begin_enable() + * verified the inode was not DAX under the inode lock. That lock is + * dropped while the Merkle tree is built, so reject enabling DAX while + * verity is being enabled. + */ + if ((fa->fsx_xflags & FS_XFLAG_DAX) && + !(ip->i_diflags2 & XFS_DIFLAG2_DAX) && + fsverity_is_building(VFS_IC(ip))) + return -EINVAL; + if (rtflag) { /* If realtime flag is set then must have realtime device */ if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 || diff --git a/fs/xfs/xfs_message.c b/fs/xfs/xfs_message.c index 0243e509a468..44b13d46049c 100644 --- a/fs/xfs/xfs_message.c +++ b/fs/xfs/xfs_message.c @@ -149,6 +149,10 @@ xfs_warn_experimental( .opstate = XFS_OPSTATE_WARNED_LARP, .name = "logged extended attributes", }, + [XFS_EXPERIMENTAL_FSVERITY] = { + .opstate = XFS_OPSTATE_WARNED_FSVERITY, + .name = "fsverity", + }, }; ASSERT(feat >= 0 && feat < XFS_EXPERIMENTAL_MAX); BUILD_BUG_ON(ARRAY_SIZE(features) != XFS_EXPERIMENTAL_MAX); diff --git a/fs/xfs/xfs_message.h b/fs/xfs/xfs_message.h index 811b885f41c3..364fcc7e42b0 100644 --- a/fs/xfs/xfs_message.h +++ b/fs/xfs/xfs_message.h @@ -93,6 +93,7 @@ void xfs_buf_alert_ratelimited(struct xfs_buf *bp, const char *rlmsg, enum xfs_experimental_feat { XFS_EXPERIMENTAL_SHRINK, XFS_EXPERIMENTAL_LARP, + XFS_EXPERIMENTAL_FSVERITY, XFS_EXPERIMENTAL_MAX, }; diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 700964048587..0b6463663599 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -599,6 +599,8 @@ __XFS_HAS_FEAT(nouuid, NOUUID) #define XFS_OPSTATE_RESUMING_QUOTAON 18 /* (Zoned) GC is in progress */ #define XFS_OPSTATE_ZONEGC_RUNNING 20 +/* Kernel has logged a warning about fsverity support */ +#define XFS_OPSTATE_WARNED_FSVERITY 21 #define __XFS_IS_OPSTATE(name, NAME) \ static inline bool xfs_is_ ## name (struct xfs_mount *mp) \ diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index c5b0be093605..2b0f38059274 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -30,6 +30,7 @@ #include "xfs_filestream.h" #include "xfs_quota.h" #include "xfs_sysfs.h" +#include "xfs_fsverity.h" #include "xfs_ondisk.h" #include "xfs_rmap_item.h" #include "xfs_refcount_item.h" @@ -50,7 +51,6 @@ #include "xfs_rtalloc.h" #include "xfs_zone_alloc.h" #include "xfs_healthmon.h" -#include "xfs_fsverity.h" #include "scrub/stats.h" #include "scrub/rcbag_btree.h" @@ -1737,6 +1737,9 @@ xfs_fs_fill_super( sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ; #endif sb->s_op = &xfs_super_operations; +#ifdef CONFIG_FS_VERITY + sb->s_vop = &xfs_fsverity_ops; +#endif /* * Delay mount work if the debug hook is set. This is debug @@ -1989,6 +1992,9 @@ xfs_fs_fill_super( if (error) goto out_filestream_unmount; + if (xfs_has_verity(mp)) + xfs_warn_experimental(mp, XFS_EXPERIMENTAL_FSVERITY); + root = igrab(VFS_I(mp->m_rootip)); if (!root) { error = -ENOENT; -- 2.54.0