aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-28 12:43:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-28 12:43:58 -0400
commiteb477e03feb8dacb3a9e3b2f750ff6c6eeffee33 (patch)
tree7ee3465e09d972d1e03fc5c38bd281a4e30567e4 /lib
parent3e7b256cba330240c8fcde3d01c65bfda12a2847 (diff)
parent81a9c5e72bdf7109a65102ca61d8cbd722cf4021 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull SCSI target fixes from Nicholas Bellinger: "Mostly minor fixes this time around. The highlights include: - iscsi-target CHAP authentication fixes to enforce explicit key values (Tejas Vaykole + rahul.rane) - fix a long-standing OOPs in target-core when a alua configfs attribute is accessed after port symlink has been removed. (Sebastian Herbszt) - fix a v3.10.y iscsi-target regression causing the login reject status class/detail to be ignored (Christoph Vu-Brugier) - fix a v3.10.y iscsi-target regression to avoid rejecting an existing ITT during Data-Out when data-direction is wrong (Santosh Kulkarni + Arshad Hussain) - fix a iscsi-target related shutdown deadlock on UP kernels (Mikulas Patocka) - fix a v3.16-rc1 build issue with vhost-scsi + !CONFIG_NET (MST)" * git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: iscsi-target: fix iscsit_del_np deadlock on unload iovec: move memcpy_from/toiovecend to lib/iovec.c iscsi-target: Avoid rejecting incorrect ITT for Data-Out tcm_loop: Fix memory leak in tcm_loop_submission_work error path iscsi-target: Explicily clear login response PDU in exception path target: Fix left-over se_lun->lun_sep pointer OOPs iscsi-target; Enforce 1024 byte maximum for CHAP_C key value iscsi-target: Convert chap_server_compute_md5 to use kstrtoul
Diffstat (limited to 'lib')
-rw-r--r--lib/iovec.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/iovec.c b/lib/iovec.c
index 454baa88bf27..7a7c2da4cddf 100644
--- a/lib/iovec.c
+++ b/lib/iovec.c
@@ -51,3 +51,58 @@ int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
51 return 0; 51 return 0;
52} 52}
53EXPORT_SYMBOL(memcpy_toiovec); 53EXPORT_SYMBOL(memcpy_toiovec);
54
55/*
56 * Copy kernel to iovec. Returns -EFAULT on error.
57 */
58
59int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata,
60 int offset, int len)
61{
62 int copy;
63 for (; len > 0; ++iov) {
64 /* Skip over the finished iovecs */
65 if (unlikely(offset >= iov->iov_len)) {
66 offset -= iov->iov_len;
67 continue;
68 }
69 copy = min_t(unsigned int, iov->iov_len - offset, len);
70 if (copy_to_user(iov->iov_base + offset, kdata, copy))
71 return -EFAULT;
72 offset = 0;
73 kdata += copy;
74 len -= copy;
75 }
76
77 return 0;
78}
79EXPORT_SYMBOL(memcpy_toiovecend);
80
81/*
82 * Copy iovec to kernel. Returns -EFAULT on error.
83 */
84
85int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
86 int offset, int len)
87{
88 /* Skip over the finished iovecs */
89 while (offset >= iov->iov_len) {
90 offset -= iov->iov_len;
91 iov++;
92 }
93
94 while (len > 0) {
95 u8 __user *base = iov->iov_base + offset;
96 int copy = min_t(unsigned int, len, iov->iov_len - offset);
97
98 offset = 0;
99 if (copy_from_user(kdata, base, copy))
100 return -EFAULT;
101 len -= copy;
102 kdata += copy;
103 iov++;
104 }
105
106 return 0;
107}
108EXPORT_SYMBOL(memcpy_fromiovecend);