]> Git Repo - linux.git/blobdiff - lib/iov_iter.c
Merge tag 'xfs-4.21-merge-3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[linux.git] / lib / iov_iter.c
index 621984743268db52dd6b8a8e1401d00ebc942588..be4bd627caf060cd89aa41ac88208946da568035 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/vmalloc.h>
 #include <linux/splice.h>
 #include <net/checksum.h>
+#include <linux/scatterlist.h>
 
 #define PIPE_PARANOIA /* for now */
 
 
 static int copyout(void __user *to, const void *from, size_t n)
 {
-       if (access_ok(VERIFY_WRITE, to, n)) {
+       if (access_ok(to, n)) {
                kasan_check_read(from, n);
                n = raw_copy_to_user(to, from, n);
        }
@@ -144,7 +145,7 @@ static int copyout(void __user *to, const void *from, size_t n)
 
 static int copyin(void *to, const void __user *from, size_t n)
 {
-       if (access_ok(VERIFY_READ, from, n)) {
+       if (access_ok(from, n)) {
                kasan_check_write(to, n);
                n = raw_copy_from_user(to, from, n);
        }
@@ -619,7 +620,7 @@ EXPORT_SYMBOL(_copy_to_iter);
 #ifdef CONFIG_ARCH_HAS_UACCESS_MCSAFE
 static int copyout_mcsafe(void __user *to, const void *from, size_t n)
 {
-       if (access_ok(VERIFY_WRITE, to, n)) {
+       if (access_ok(to, n)) {
                kasan_check_read(from, n);
                n = copy_to_user_mcsafe((__force void *) to, from, n);
        }
@@ -1466,10 +1467,11 @@ bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum,
 }
 EXPORT_SYMBOL(csum_and_copy_from_iter_full);
 
-size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum,
+size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump,
                             struct iov_iter *i)
 {
        const char *from = addr;
+       __wsum *csum = csump;
        __wsum sum, next;
        size_t off = 0;
 
@@ -1510,6 +1512,21 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum,
 }
 EXPORT_SYMBOL(csum_and_copy_to_iter);
 
+size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,
+               struct iov_iter *i)
+{
+       struct ahash_request *hash = hashp;
+       struct scatterlist sg;
+       size_t copied;
+
+       copied = copy_to_iter(addr, bytes, i);
+       sg_init_one(&sg, addr, copied);
+       ahash_request_set_crypt(hash, &sg, NULL, copied);
+       crypto_ahash_update(hash);
+       return copied;
+}
+EXPORT_SYMBOL(hash_and_copy_to_iter);
+
 int iov_iter_npages(const struct iov_iter *i, int maxpages)
 {
        size_t size = i->count;
@@ -1646,7 +1663,7 @@ int import_single_range(int rw, void __user *buf, size_t len,
 {
        if (len > MAX_RW_COUNT)
                len = MAX_RW_COUNT;
-       if (unlikely(!access_ok(!rw, buf, len)))
+       if (unlikely(!access_ok(buf, len)))
                return -EFAULT;
 
        iov->iov_base = buf;
This page took 0.035987 seconds and 4 git commands to generate.