summaryrefslogtreecommitdiffstats
path: root/fs/fuse
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-09-21 18:37:42 -0400
committerMiklos Szeredi <mszeredi@redhat.com>2016-10-01 07:32:33 +0200
commit3daa9c51651f2631be373840db0f82a8efb1c63d (patch)
tree0298d00eb0e9f60176b795bac6c7fee3c57dc39c /fs/fuse
parent29433a2991fa636c1fcd5bf5893cf92c37e0b26c (diff)
downloadlinux-3daa9c51651f2631be373840db0f82a8efb1c63d.tar.bz2
fuse_ioctl_copy_user(): don't open-code copy_page_{to,from}_iter()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse')
-rw-r--r--fs/fuse/file.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 3988b43c2f5a..4c1db6ce7c48 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2339,31 +2339,15 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov,
while (iov_iter_count(&ii)) {
struct page *page = pages[page_idx++];
- size_t todo = min_t(size_t, PAGE_SIZE, iov_iter_count(&ii));
- void *kaddr;
+ size_t copied;
- kaddr = kmap(page);
-
- while (todo) {
- char __user *uaddr = ii.iov->iov_base + ii.iov_offset;
- size_t iov_len = ii.iov->iov_len - ii.iov_offset;
- size_t copy = min(todo, iov_len);
- size_t left;
-
- if (!to_user)
- left = copy_from_user(kaddr, uaddr, copy);
- else
- left = copy_to_user(uaddr, kaddr, copy);
-
- if (unlikely(left))
- return -EFAULT;
-
- iov_iter_advance(&ii, copy);
- todo -= copy;
- kaddr += copy;
- }
+ if (!to_user)
+ copied = copy_page_from_iter(page, 0, PAGE_SIZE, &ii);
+ else
+ copied = copy_page_to_iter(page, 0, PAGE_SIZE, &ii);
- kunmap(page);
+ if (unlikely(copied != PAGE_SIZE && iov_iter_count(&ii)))
+ return -EFAULT;
}
return 0;