]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
iov_iter: add __iovec_copy_to_user()
authorDave Kleikamp <dave.kleikamp@oracle.com>
Fri, 14 Jun 2013 20:54:11 +0000 (15:54 -0500)
committerDave Kleikamp <dave.kleikamp@oracle.com>
Wed, 18 Sep 2013 15:16:25 +0000 (10:16 -0500)
This patch adds __iovec_copy_to_user() which doesn't verify write access
to the user memory to be called from code where that verification has
already been done.

Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
fs/iov-iter.c
include/linux/fs.h

index 0b2407e9877cbca4a8c8ec723005a8e7295614ac..6cecab49b7caa3295a2b86e4d1064f99a9343d33 100644 (file)
@@ -19,7 +19,7 @@ static size_t __iovec_copy_to_user(char *vaddr, const struct iovec *iov,
                if (atomic)
                        left = __copy_to_user_inatomic(buf, vaddr, copy);
                else
-                       left = copy_to_user(buf, vaddr, copy);
+                       left = __copy_to_user(buf, vaddr, copy);
                copied += copy;
                bytes -= copy;
                vaddr += copy;
@@ -65,7 +65,7 @@ EXPORT_SYMBOL(iov_iter_copy_to_user_atomic);
  * The difference is that it attempts to resolve faults.
  * Page must not be locked.
  */
-size_t iov_iter_copy_to_user(struct page *page,
+size_t __iov_iter_copy_to_user(struct page *page,
                struct iov_iter *i, unsigned long offset, size_t bytes)
 {
        char *kaddr;
@@ -84,6 +84,16 @@ size_t iov_iter_copy_to_user(struct page *page,
        kunmap(page);
        return copied;
 }
+EXPORT_SYMBOL(__iov_iter_copy_to_user);
+
+size_t iov_iter_copy_to_user(struct page *page,
+               struct iov_iter *i, unsigned long offset, size_t bytes)
+{
+       might_sleep();
+       if (generic_segment_checks(i->iov, &i->nr_segs, &bytes, VERIFY_WRITE))
+               return 0;
+       return __iov_iter_copy_to_user(page, i, offset, bytes);
+}
 EXPORT_SYMBOL(iov_iter_copy_to_user);
 
 static size_t __iovec_copy_from_user(char *vaddr, const struct iovec *iov,
index 11647fe75ac6ae0a5611387f7b2ce6f9acd92258..b7a0ff8585c29eabb641b179c17c23c787375e1c 100644 (file)
@@ -297,7 +297,9 @@ struct iov_iter {
        size_t count;
 };
 
-size_t iov_iter_copy_to_user_atomic(struct page *page,
+size_t __iov_iter_copy_to_user_atomic(struct page *page,
+               struct iov_iter *i, unsigned long offset, size_t bytes);
+size_t __iov_iter_copy_to_user(struct page *page,
                struct iov_iter *i, unsigned long offset, size_t bytes);
 size_t iov_iter_copy_to_user(struct page *page,
                struct iov_iter *i, unsigned long offset, size_t bytes);