Whamcloud - gitweb
LU-13373 llite: fix to verify write in ll_file_get_iov_count() 88/37988/3
authorWang Shilong <wshilong@ddn.com>
Thu, 19 Mar 2020 14:56:07 +0000 (22:56 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 23 Apr 2020 16:49:29 +0000 (16:49 +0000)
should pass VERIFY_WRITE to access_ok() if this is writing
rather than VERIFY_READ.

Change-Id: I8c6fd6696437e1d2a964728b456ea1df05daa183
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/37988
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/llite/file.c

index b140514..4e76c47 100644 (file)
@@ -1879,7 +1879,8 @@ out:
  * XXX: exact copy from kernel code (__generic_file_aio_write_nolock)
  */
 static int ll_file_get_iov_count(const struct iovec *iov,
-                                unsigned long *nr_segs, size_t *count)
+                                unsigned long *nr_segs, size_t *count,
+                                int access_flags)
 {
        size_t cnt = 0;
        unsigned long seg;
@@ -1894,7 +1895,7 @@ static int ll_file_get_iov_count(const struct iovec *iov,
                cnt += iv->iov_len;
                if (unlikely((ssize_t)(cnt|iv->iov_len) < 0))
                        return -EINVAL;
-               if (access_ok(VERIFY_READ, iv->iov_base, iv->iov_len))
+               if (access_ok(access_flags, iv->iov_base, iv->iov_len))
                        continue;
                if (seg == 0)
                        return -EFAULT;
@@ -1914,7 +1915,7 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
        ssize_t result;
        ENTRY;
 
-       result = ll_file_get_iov_count(iov, &nr_segs, &iov_count);
+       result = ll_file_get_iov_count(iov, &nr_segs, &iov_count, VERIFY_READ);
        if (result)
                RETURN(result);
 
@@ -1970,7 +1971,7 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
        ssize_t result;
        ENTRY;
 
-       result = ll_file_get_iov_count(iov, &nr_segs, &iov_count);
+       result = ll_file_get_iov_count(iov, &nr_segs, &iov_count, VERIFY_WRITE);
        if (result)
                RETURN(result);