Lines Matching +full:page +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0-only
10 #include <linux/backing-dev.h>
17 void __user *buf, u64 offset, int length) in fsverity_read_merkle_tree() argument
19 const struct fsverity_operations *vops = inode->i_sb->s_vop; in fsverity_read_merkle_tree()
26 end_offset = min(offset + length, vi->tree_params.tree_size); in fsverity_read_merkle_tree()
27 if (offset >= end_offset) in fsverity_read_merkle_tree()
29 offs_in_page = offset_in_page(offset); in fsverity_read_merkle_tree()
30 last_index = (end_offset - 1) >> PAGE_SHIFT; in fsverity_read_merkle_tree()
33 * Iterate through each Merkle tree page in the requested range and copy in fsverity_read_merkle_tree()
38 for (index = offset >> PAGE_SHIFT; index <= last_index; index++) { in fsverity_read_merkle_tree()
40 min_t(unsigned long, last_index - index + 1, in fsverity_read_merkle_tree()
41 inode->i_sb->s_bdi->io_pages); in fsverity_read_merkle_tree()
42 unsigned int bytes_to_copy = min_t(u64, end_offset - offset, in fsverity_read_merkle_tree()
43 PAGE_SIZE - offs_in_page); in fsverity_read_merkle_tree()
44 struct page *page; in fsverity_read_merkle_tree() local
47 page = vops->read_merkle_tree_page(inode, index, num_ra_pages); in fsverity_read_merkle_tree()
48 if (IS_ERR(page)) { in fsverity_read_merkle_tree()
49 err = PTR_ERR(page); in fsverity_read_merkle_tree()
51 "Error %d reading Merkle tree page %lu", in fsverity_read_merkle_tree()
56 virt = kmap_local_page(page); in fsverity_read_merkle_tree()
59 put_page(page); in fsverity_read_merkle_tree()
60 err = -EFAULT; in fsverity_read_merkle_tree()
64 put_page(page); in fsverity_read_merkle_tree()
68 offset += bytes_to_copy; in fsverity_read_merkle_tree()
71 err = -EINTR; in fsverity_read_merkle_tree()
81 static int fsverity_read_buffer(void __user *dst, u64 offset, int length, in fsverity_read_buffer() argument
84 if (offset >= src_length) in fsverity_read_buffer()
86 src += offset; in fsverity_read_buffer()
87 src_length -= offset; in fsverity_read_buffer()
92 return -EFAULT; in fsverity_read_buffer()
98 void __user *buf, u64 offset, int length) in fsverity_read_descriptor() argument
110 desc->sig_size = 0; in fsverity_read_descriptor()
112 res = fsverity_read_buffer(buf, offset, length, desc, desc_size); in fsverity_read_descriptor()
119 void __user *buf, u64 offset, int length) in fsverity_read_signature() argument
128 if (desc->sig_size == 0) { in fsverity_read_signature()
129 res = -ENODATA; in fsverity_read_signature()
135 * already verified that sig_size is in-bounds. in fsverity_read_signature()
137 res = fsverity_read_buffer(buf, offset, length, desc->signature, in fsverity_read_signature()
138 le32_to_cpu(desc->sig_size)); in fsverity_read_signature()
145 * fsverity_ioctl_read_metadata() - read verity metadata from a file
149 * Return: length read on success, 0 on EOF, -errno on failure
161 return -ENODATA; /* not a verity file */ in fsverity_ioctl_read_metadata()
168 return -EFAULT; in fsverity_ioctl_read_metadata()
171 return -EINVAL; in fsverity_ioctl_read_metadata()
173 /* offset + length must not overflow. */ in fsverity_ioctl_read_metadata()
174 if (arg.offset + arg.length < arg.offset) in fsverity_ioctl_read_metadata()
175 return -EINVAL; in fsverity_ioctl_read_metadata()
184 return fsverity_read_merkle_tree(inode, vi, buf, arg.offset, in fsverity_ioctl_read_metadata()
187 return fsverity_read_descriptor(inode, buf, arg.offset, length); in fsverity_ioctl_read_metadata()
189 return fsverity_read_signature(inode, buf, arg.offset, length); in fsverity_ioctl_read_metadata()
191 return -EINVAL; in fsverity_ioctl_read_metadata()