From ab6ddccf78d37afe4f941b6a2074dca25a65cfe7 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Thu, 19 Mar 2020 22:56:07 +0800 Subject: [PATCH] LU-13373 llite: fix to verify write in ll_file_get_iov_count() should pass VERIFY_WRITE to access_ok() if this is writing rather than VERIFY_READ. Change-Id: I8c6fd6696437e1d2a964728b456ea1df05daa183 Signed-off-by: Wang Shilong Reviewed-on: https://review.whamcloud.com/37988 Reviewed-by: Andreas Dilger Reviewed-by: Gu Zheng Tested-by: jenkins Tested-by: Maloo --- lustre/llite/file.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index b140514..4e76c47 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -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); -- 1.8.3.1