Filesystems implementing fsverity store fsverity metadata on similar offsets in pagecache. Prepare fsverity for consolidating this offset to the first folio after EOF folio. The max folio size is used to guarantee that mapped file will not expose fsverity metadata to userspace. So far, only XFS uses this in futher patches. Signed-off-by: Andrey Albershteyn --- fs/verity/pagecache.c | 6 ++++++ include/linux/fsverity.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/fs/verity/pagecache.c b/fs/verity/pagecache.c index 1819314ecaa3..73f03b48d42d 100644 --- a/fs/verity/pagecache.c +++ b/fs/verity/pagecache.c @@ -56,3 +56,9 @@ void generic_readahead_merkle_tree(struct inode *inode, pgoff_t index, folio_put(folio); } EXPORT_SYMBOL_GPL(generic_readahead_merkle_tree); + +loff_t fsverity_metadata_offset(const struct inode *inode) +{ + return roundup(i_size_read(inode), mapping_max_folio_size_supported()); +} +EXPORT_SYMBOL_GPL(fsverity_metadata_offset); diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h index 16740a331020..278c6340849f 100644 --- a/include/linux/fsverity.h +++ b/include/linux/fsverity.h @@ -214,6 +214,7 @@ bool fsverity_verify_blocks(struct fsverity_info *vi, struct folio *folio, size_t len, size_t offset); void fsverity_verify_bio(struct fsverity_info *vi, struct bio *bio); void fsverity_enqueue_verify_work(struct work_struct *work); +loff_t fsverity_metadata_offset(const struct inode *inode); #else /* !CONFIG_FS_VERITY */ @@ -295,6 +296,12 @@ static inline int fsverity_ensure_verity_info(struct inode *inode) return -EOPNOTSUPP; } +static inline loff_t fsverity_metadata_offset(const struct inode *inode) +{ + WARN_ON_ONCE(1); + return ULLONG_MAX; +} + #endif /* !CONFIG_FS_VERITY */ static inline bool fsverity_verify_folio(struct fsverity_info *vi, -- 2.51.2