summaryrefslogtreecommitdiff
path: root/lib/iov_iter.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2023-01-05 22:07:30 +0300
committerJens Axboe <axboe@kernel.dk>2023-01-09 06:59:17 +0300
commit2ad9bd8332ac1bc072cc7d785e7cb09d6ad36f4c (patch)
treeed34d7b63923379b890e9b6ff9d185b95dad1d7c /lib/iov_iter.c
parentb7bfaa761d760e72a969d116517eaa12e404c262 (diff)
downloadlinux-2ad9bd8332ac1bc072cc7d785e7cb09d6ad36f4c.tar.xz
iov: add import_ubuf()
Like import_single_range(), but for ITER_UBUF. Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'lib/iov_iter.c')
-rw-r--r--lib/iov_iter.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index f9a3ff37ecd1..f036760b66e2 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1877,6 +1877,17 @@ int import_single_range(int rw, void __user *buf, size_t len,
}
EXPORT_SYMBOL(import_single_range);
+int import_ubuf(int rw, void __user *buf, size_t len, struct iov_iter *i)
+{
+ if (len > MAX_RW_COUNT)
+ len = MAX_RW_COUNT;
+ if (unlikely(!access_ok(buf, len)))
+ return -EFAULT;
+
+ iov_iter_ubuf(i, rw, buf, len);
+ return 0;
+}
+
/**
* iov_iter_restore() - Restore a &struct iov_iter to the same state as when
* iov_iter_save_state() was called.