@@ -253,7 +253,9 @@ static size_t copy_page_to_iter_iovec(struct page *page, size_t offset, size_t b
}
static size_t copy_page_from_iter_iovec(struct page *page, size_t offset, size_t bytes,
- struct iov_iter *i)
+ struct iov_iter *i,
+ unsigned long (*_copyin)(void *to, const void __user *from,
+ unsigned long n))
{
size_t skip, copy, left, wanted;
const struct iovec *iov;
@@ -278,7 +280,7 @@ static size_t copy_page_from_iter_iovec(struct page *page, size_t offset, size_t
to = kaddr + offset;
/* first chunk, usually the only one */
- left = copyin(to, buf, copy);
+ left = _copyin(to, buf, copy);
copy -= left;
skip += copy;
to += copy;
@@ -288,7 +290,7 @@ static size_t copy_page_from_iter_iovec(struct page *page, size_t offset, size_t
iov++;
buf = iov->iov_base;
copy = min(bytes, iov->iov_len);
- left = copyin(to, buf, copy);
+ left = _copyin(to, buf, copy);
copy -= left;
skip = copy;
to += copy;
@@ -307,7 +309,7 @@ static size_t copy_page_from_iter_iovec(struct page *page, size_t offset, size_t
kaddr = kmap(page);
to = kaddr + offset;
- left = copyin(to, buf, copy);
+ left = _copyin(to, buf, copy);
copy -= left;
skip += copy;
to += copy;
@@ -316,7 +318,7 @@ static size_t copy_page_from_iter_iovec(struct page *page, size_t offset, size_t
iov++;
buf = iov->iov_base;
copy = min(bytes, iov->iov_len);
- left = copyin(to, buf, copy);
+ left = _copyin(to, buf, copy);
copy -= left;
skip = copy;
to += copy;
@@ -899,7 +901,7 @@ size_t copy_page_from_iter(struct page *page, size_t offset, size_t bytes,
if (unlikely(!page_copy_sane(page, offset, bytes)))
return 0;
if (likely(iter_is_iovec(i)))
- return copy_page_from_iter_iovec(page, offset, bytes, i);
+ return copy_page_from_iter_iovec(page, offset, bytes, i, raw_copy_from_user);
if (iov_iter_is_bvec(i) || iov_iter_is_kvec(i) || iov_iter_is_xarray(i)) {
void *kaddr = kmap_local_page(page);
size_t wanted = _copy_from_iter(kaddr + offset, bytes, i);
When calling copy_page_from_iter_iovec, allow callers to specify the copy function they'd like to use. The only caller is updated to pass raw_copy_from_user. Signed-off-by: Joe Damato <jdamato@fastly.com> --- lib/iov_iter.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)