[PATCH 06/10] fs: set kernel address limit in do_loop_readv_writev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This will allow to use all iov_iter based read/write for ITER_KVEC
without having to check if the file has the iter version of the
read/write ops, which will allow us to get rid of a large number
of get_fs/set_fs calls in drivers.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 fs/read_write.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fs/read_write.c b/fs/read_write.c
index 64b61a032a56..60c64a996ab2 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -704,9 +704,18 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter,
 		loff_t *ppos, int type, int flags)
 {
 	ssize_t ret = 0;
+	mm_segment_t uninitialized_var(old_fs);
 
 	if (flags & ~RWF_HIPRI)
 		return -EOPNOTSUPP;
+	if (iter->type & (ITER_BVEC | ITER_PIPE))
+		return -EOPNOTSUPP;
+
+	/* adjust the address limit for in-kernel I/O */
+	if (iter->type & ITER_KVEC) {
+		old_fs = get_fs();
+		set_fs(get_ds());
+	}
 
 	while (iov_iter_count(iter)) {
 		struct iovec iovec = iov_iter_iovec(iter);
@@ -731,6 +740,8 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter,
 		iov_iter_advance(iter, nr);
 	}
 
+	if (iter->type & ITER_KVEC)
+		set_fs(old_fs);
 	return ret;
 }
 
-- 
2.11.0




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux