scst: Complain loudly if 'fs' is incorrect (merge r7873 from trunk)

git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.3.x@7895 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2019-01-13 21:44:01 +00:00
parent c87ada6fb6
commit 8956c74b67

View File

@@ -5843,6 +5843,14 @@ static void scst_complete_request_sense(struct scst_cmd *req_cmd)
return;
}
static int scst_cmp_fs_ds(void)
{
mm_segment_t fs = get_fs();
mm_segment_t ds = get_ds();
return memcmp(&fs, &ds, sizeof(fs));
}
ssize_t scst_read(struct file *file, void *buf, size_t count, loff_t *pos)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
@@ -5851,6 +5859,8 @@ ssize_t scst_read(struct file *file, void *buf, size_t count, loff_t *pos)
.iov_len = count
};
WARN_ON_ONCE(scst_cmp_fs_ds() != 0);
return scst_readv(file, &iov, 1, pos);
#else
WARN_ON_ONCE(scst_cmp_fs_ds() != 0);
@@ -5869,6 +5879,8 @@ ssize_t scst_write(struct file *file, const void *buf, size_t count,
.iov_len = count
};
WARN_ON_ONCE(scst_cmp_fs_ds() != 0);
return scst_writev(file, &iov, 1, pos);
#else
WARN_ON_ONCE(scst_cmp_fs_ds() != 0);
@@ -5887,6 +5899,8 @@ ssize_t scst_readv(struct file *file, const struct iovec *vec,
struct iov_iter iter;
ssize_t ret;
WARN_ON_ONCE(scst_cmp_fs_ds() != 0);
ret = import_iovec(READ, (const struct iovec __force __user *)vec, vlen,
ARRAY_SIZE(iovstack), &iov, &iter);
if (ret < 0)
@@ -5927,6 +5941,8 @@ ssize_t scst_writev(struct file *file, const struct iovec *vec,
struct iov_iter iter;
ssize_t ret;
WARN_ON_ONCE(scst_cmp_fs_ds() != 0);
ret = import_iovec(WRITE, (const struct iovec __force __user *)vec,
vlen, ARRAY_SIZE(iovstack), &iov, &iter);
if (ret < 0)