diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-14 21:19:05 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-14 21:19:05 -0400 |
| commit | b26b5ef5ec7eab0e1d84c5b281e87b2f2a5e0586 (patch) | |
| tree | 3fd57787765f05a19b85b384bd2a68cb4f9276d4 /fs/read_write.c | |
| parent | 87dbe42a16b654e33665756c63e96c0fa73eb003 (diff) | |
| parent | 2692a71bbd40160165e89d5505c5c28144ec5a42 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more misc uaccess and vfs updates from Al Viro:
"The rest of the stuff from -next (more uaccess work) + assorted fixes"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
score: traps: Add missing include file to fix build error
fs/super.c: don't fool lockdep in freeze_super() and thaw_super() paths
fs/super.c: fix race between freeze_super() and thaw_super()
overlayfs: Fix setting IOP_XATTR flag
iov_iter: kernel-doc import_iovec() and rw_copy_check_uvector()
blackfin: no access_ok() for __copy_{to,from}_user()
arm64: don't zero in __copy_from_user{,_inatomic}
arm: don't zero in __copy_from_user_inatomic()/__copy_from_user()
arc: don't leak bits of kernel stack into coredump
alpha: get rid of tail-zeroing in __copy_user()
Diffstat (limited to 'fs/read_write.c')
| -rw-r--r-- | fs/read_write.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/fs/read_write.c b/fs/read_write.c index 66215a7b17cf..190e0d362581 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
| @@ -730,6 +730,35 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter, | |||
| 730 | /* A write operation does a read from user space and vice versa */ | 730 | /* A write operation does a read from user space and vice versa */ |
| 731 | #define vrfy_dir(type) ((type) == READ ? VERIFY_WRITE : VERIFY_READ) | 731 | #define vrfy_dir(type) ((type) == READ ? VERIFY_WRITE : VERIFY_READ) |
| 732 | 732 | ||
| 733 | /** | ||
| 734 | * rw_copy_check_uvector() - Copy an array of &struct iovec from userspace | ||
| 735 | * into the kernel and check that it is valid. | ||
| 736 | * | ||
| 737 | * @type: One of %CHECK_IOVEC_ONLY, %READ, or %WRITE. | ||
| 738 | * @uvector: Pointer to the userspace array. | ||
| 739 | * @nr_segs: Number of elements in userspace array. | ||
| 740 | * @fast_segs: Number of elements in @fast_pointer. | ||
| 741 | * @fast_pointer: Pointer to (usually small on-stack) kernel array. | ||
| 742 | * @ret_pointer: (output parameter) Pointer to a variable that will point to | ||
| 743 | * either @fast_pointer, a newly allocated kernel array, or NULL, | ||
| 744 | * depending on which array was used. | ||
| 745 | * | ||
| 746 | * This function copies an array of &struct iovec of @nr_segs from | ||
| 747 | * userspace into the kernel and checks that each element is valid (e.g. | ||
| 748 | * it does not point to a kernel address or cause overflow by being too | ||
| 749 | * large, etc.). | ||
| 750 | * | ||
| 751 | * As an optimization, the caller may provide a pointer to a small | ||
| 752 | * on-stack array in @fast_pointer, typically %UIO_FASTIOV elements long | ||
| 753 | * (the size of this array, or 0 if unused, should be given in @fast_segs). | ||
| 754 | * | ||
| 755 | * @ret_pointer will always point to the array that was used, so the | ||
| 756 | * caller must take care not to call kfree() on it e.g. in case the | ||
| 757 | * @fast_pointer array was used and it was allocated on the stack. | ||
| 758 | * | ||
| 759 | * Return: The total number of bytes covered by the iovec array on success | ||
| 760 | * or a negative error code on error. | ||
| 761 | */ | ||
| 733 | ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, | 762 | ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, |
| 734 | unsigned long nr_segs, unsigned long fast_segs, | 763 | unsigned long nr_segs, unsigned long fast_segs, |
| 735 | struct iovec *fast_pointer, | 764 | struct iovec *fast_pointer, |
