From caea963fca61fd5bc360b9c5f23ca2618beb9b00 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 20 Apr 2019 23:50:50 +0000 Subject: [PATCH] scst: Fix scst_readv() and scst_writev() Fixes: a94c8eaf0f68 ("scst: Move the set_fs() calls into scst_{read,write}v()"). See also trunk r8066. Reported-by: Rob Turk git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8261 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 96274fa7a..b472bca5e 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -5969,6 +5969,7 @@ ssize_t scst_readv(struct file *file, const struct iovec *vec, struct iovec *iov = iovstack; struct iov_iter iter; + set_fs(KERNEL_DS); WARN_ON_ONCE(scst_cmp_fs_ds() != 0); result = import_iovec(READ, (const struct iovec __force __user *)vec, @@ -5981,11 +5982,13 @@ ssize_t scst_readv(struct file *file, const struct iovec *vec, #elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) || \ (defined(CONFIG_SUSE_KERNEL) && \ LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) + set_fs(KERNEL_DS); WARN_ON_ONCE(scst_cmp_fs_ds() != 0); result = vfs_readv(file, (const struct iovec __user *)vec, vlen, pos, 0); #else + set_fs(KERNEL_DS); WARN_ON_ONCE(scst_cmp_fs_ds() != 0); result = vfs_readv(file, (const struct iovec __user *)vec, vlen, pos); @@ -6016,6 +6019,7 @@ ssize_t scst_writev(struct file *file, const struct iovec *vec, struct iovec *iov = iovstack; struct iov_iter iter; + set_fs(KERNEL_DS); WARN_ON_ONCE(scst_cmp_fs_ds() != 0); result = import_iovec(WRITE, (const struct iovec __force __user *)vec, @@ -6030,9 +6034,13 @@ ssize_t scst_writev(struct file *file, const struct iovec *vec, #elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) || \ (defined(CONFIG_SUSE_KERNEL) && \ LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) + set_fs(KERNEL_DS); + WARN_ON_ONCE(scst_cmp_fs_ds() != 0); result = vfs_writev(file, (const struct iovec __user *)vec, vlen, pos, 0); #else + set_fs(KERNEL_DS); + WARN_ON_ONCE(scst_cmp_fs_ds() != 0); result = vfs_writev(file, (const struct iovec __user *)vec, vlen, pos); #endif set_fs(old_fs);