mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
fsverity: expose ensure_fsverity_info()
This function will be used by XFS's scrub to force fsverity activation, therefore, to read fsverity context. Reviewed-by: Darrick J. Wong <djwong@kernel.org> Acked-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20261002223705.2175542-3-aalbersh@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
This commit is contained in:
parent
1ab73b0f96
commit
7a59a56fe4
|
|
@ -347,7 +347,28 @@ int fsverity_get_descriptor(struct inode *inode,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ensure_verity_info(struct inode *inode)
|
||||
/**
|
||||
* fsverity_ensure_verity_info() - cache verity info if it's not already cached
|
||||
* @inode: the inode for which verity info should be cached
|
||||
*
|
||||
* Ensure this inode has verity info attached to it, it's assumed the inode
|
||||
* already has fsverity enabled. Read fsverity descriptor and creates verity
|
||||
* based on that.
|
||||
*
|
||||
* This needs to be called at least once before any of the inode's data
|
||||
* can be verified (and thus read at all) or the inode's fsverity digest
|
||||
* retrieved. fsverity_file_open() calls this already, which handles
|
||||
* normal file accesses. If a filesystem does any internal (i.e. not
|
||||
* associated with a file descriptor) reads of the file's data or
|
||||
* fsverity digest, it must call this explicitly before doing so.
|
||||
*
|
||||
* In case filesystem supports both fscrypt and fsverity, this should be called
|
||||
* after fscrypt's encryption key is set up. Otherwise, the fsverity metadata is
|
||||
* still encrypted. See fscrypt_file_open().
|
||||
*
|
||||
* Return: 0 on success, -errno on failure
|
||||
*/
|
||||
int fsverity_ensure_verity_info(struct inode *inode)
|
||||
{
|
||||
struct fsverity_info *vi = fsverity_get_info(inode), *found;
|
||||
struct fsverity_descriptor *desc;
|
||||
|
|
@ -383,12 +404,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);
|
||||
|
||||
|
|
|
|||
|
|
@ -317,6 +317,8 @@ static inline int fsverity_file_open(struct inode *inode, struct file *filp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user