Ext4 and F2FS store verity metadata beyond i_size. This commit adds a call back pointer to "struct fsverity_operations" which helps in determining the the real file size limit upto which data can be read from the file.
This call back will be required in order to get do_mpage_readpage() to read files having verity metadata appended beyond i_size. Signed-off-by: Chandan Rajendra <chan...@linux.ibm.com> --- fs/ext4/super.c | 18 ++++++++++++++++++ include/linux/fsverity.h | 1 + 2 files changed, 19 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 63d73b360f1d..cadf50f9503f 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1428,6 +1428,23 @@ static struct page *ext4_read_verity_metadata_page(struct inode *inode, return read_mapping_page(inode->i_mapping, index, NULL); } +static loff_t ext4_readpage_limit(struct inode *inode) +{ +#ifdef CONFIG_FS_VERITY + if (IS_VERITY(inode)) { + if (inode->i_verity_info) + /* limit to end of metadata region */ + return fsverity_full_i_size(inode); + /* + * fsverity_info is currently being set up and no user reads are + * allowed yet. It's easiest to just not enforce a limit yet. + */ + return inode->i_sb->s_maxbytes; + } +#endif + return i_size_read(inode); +} + static bool ext4_verity_required(struct inode *inode, pgoff_t index) { return index < (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT; @@ -1438,6 +1455,7 @@ static const struct fsverity_operations ext4_verityops = { .get_metadata_end = ext4_get_verity_metadata_end, .read_metadata_page = ext4_read_verity_metadata_page, .verity_required = ext4_verity_required, + .readpage_limit = ext4_readpage_limit, }; #endif /* CONFIG_FS_VERITY */ diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h index b83712d6c79a..fc8113acbbfe 100644 --- a/include/linux/fsverity.h +++ b/include/linux/fsverity.h @@ -19,6 +19,7 @@ struct fsverity_operations { int (*get_metadata_end)(struct inode *inode, loff_t *metadata_end_ret); struct page *(*read_metadata_page)(struct inode *inode, pgoff_t index); bool (*verity_required)(struct inode *inode, pgoff_t index); + loff_t (*readpage_limit)(struct inode *inode); }; #ifdef CONFIG_FS_VERITY -- 2.19.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel