@@ -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)
{
if (index < ((i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT))
@@ -1441,6 +1458,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 */
@@ -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
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 <chandan@linux.ibm.com> --- fs/ext4/super.c | 18 ++++++++++++++++++ include/linux/fsverity.h | 1 + 2 files changed, 19 insertions(+)