This function will be used by XFS's scrub to force fsverity activation, therefore, to read fsverity context. Signed-off-by: Andrey Albershteyn Reviewed-by: "Darrick J. Wong" --- fs/verity/open.c | 5 +++-- include/linux/fsverity.h | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/fs/verity/open.c b/fs/verity/open.c index dfa0d1afe0fe..0483db672526 100644 --- a/fs/verity/open.c +++ b/fs/verity/open.c @@ -344,7 +344,7 @@ int fsverity_get_descriptor(struct inode *inode, return 0; } -static int ensure_verity_info(struct inode *inode) +int fsverity_ensure_verity_info(struct inode *inode) { struct fsverity_info *vi = fsverity_get_info(inode), *found; struct fsverity_descriptor *desc; @@ -380,12 +380,13 @@ static int ensure_verity_info(struct inode *inode) kfree(desc); return err; } +EXPORT_SYMBOL_GPL(fsverity_ensure_verity_info); int __fsverity_file_open(struct inode *inode, struct file *filp) { if (filp->f_mode & FMODE_WRITE) return -EPERM; - return ensure_verity_info(inode); + return fsverity_ensure_verity_info(inode); } EXPORT_SYMBOL_GPL(__fsverity_file_open); diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h index a8f9aa75b792..2e3a90aff11e 100644 --- a/include/linux/fsverity.h +++ b/include/linux/fsverity.h @@ -309,6 +309,19 @@ static inline int fsverity_file_open(struct inode *inode, struct file *filp) return 0; } +/** + * fsverity_ensure_verity_info() - create verity info if it's not in memory yet + * @inode: the inode for which verity info should be created + * + * Ensure this inode has verity info attached to it. Read fsverity descriptor + * and creates verity based on that. Inodes opened outside of + * file_operations->open will not have any verity info attached. This + * info is required for any fsverity related operations. + * + * Return: 0 on success, -errno on failure + */ +int fsverity_ensure_verity_info(struct inode *inode); + void fsverity_cleanup_inode(struct inode *inode); struct page *generic_read_merkle_tree_page(struct inode *inode, pgoff_t index); -- 2.51.2