diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2013-05-16 19:35:21 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-05-19 20:54:22 -0400 |
commit | d2f83e9078b8114e3b9d09082856c1aac299aa37 (patch) | |
tree | 707f0d810d28e000eb3f9a775be880687dde1030 | |
parent | d5fe85af85367d5892e4308f596de4e2a5fb9017 (diff) |
Hoist memcpy_fromiovec/memcpy_toiovec into lib/
ERROR: "memcpy_fromiovec" [drivers/vhost/vhost_scsi.ko] undefined!
That function is only present with CONFIG_NET. Turns out that
crypto/algif_skcipher.c also uses that outside net, but it actually
needs sockets anyway.
In addition, commit 6d4f0139d642c45411a47879325891ce2a7c164a added
CONFIG_NET dependency to CONFIG_VMCI for memcpy_toiovec, so hoist
that function and revert that commit too.
socket.h already includes uio.h, so no callers need updating; trying
only broke things fo x86_64 randconfig (thanks Fengguang!).
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r-- | drivers/misc/vmw_vmci/Kconfig | 2 | ||||
-rw-r--r-- | drivers/misc/vmw_vmci/vmci_queue_pair.c | 2 | ||||
-rw-r--r-- | include/linux/socket.h | 2 | ||||
-rw-r--r-- | include/linux/uio.h | 3 | ||||
-rw-r--r-- | lib/Makefile | 2 | ||||
-rw-r--r-- | lib/iovec.c | 53 | ||||
-rw-r--r-- | net/core/iovec.c | 50 |
7 files changed, 59 insertions, 55 deletions
diff --git a/drivers/misc/vmw_vmci/Kconfig b/drivers/misc/vmw_vmci/Kconfig index ea98f7e9ccd1..39c2ecadb273 100644 --- a/drivers/misc/vmw_vmci/Kconfig +++ b/drivers/misc/vmw_vmci/Kconfig | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | config VMWARE_VMCI | 5 | config VMWARE_VMCI |
6 | tristate "VMware VMCI Driver" | 6 | tristate "VMware VMCI Driver" |
7 | depends on X86 && PCI && NET | 7 | depends on X86 && PCI |
8 | help | 8 | help |
9 | This is VMware's Virtual Machine Communication Interface. It enables | 9 | This is VMware's Virtual Machine Communication Interface. It enables |
10 | high-speed communication between host and guest in a virtual | 10 | high-speed communication between host and guest in a virtual |
diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c index d94245dbd765..8ff2e5ee8fb8 100644 --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/pagemap.h> | 23 | #include <linux/pagemap.h> |
24 | #include <linux/sched.h> | 24 | #include <linux/sched.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/socket.h> | 26 | #include <linux/uio.h> |
27 | #include <linux/wait.h> | 27 | #include <linux/wait.h> |
28 | #include <linux/vmalloc.h> | 28 | #include <linux/vmalloc.h> |
29 | 29 | ||
diff --git a/include/linux/socket.h b/include/linux/socket.h index 428c37a1f95c..33bf2dfab19d 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h | |||
@@ -305,7 +305,6 @@ struct ucred { | |||
305 | 305 | ||
306 | extern void cred_to_ucred(struct pid *pid, const struct cred *cred, struct ucred *ucred); | 306 | extern void cred_to_ucred(struct pid *pid, const struct cred *cred, struct ucred *ucred); |
307 | 307 | ||
308 | extern int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len); | ||
309 | extern int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov, | 308 | extern int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov, |
310 | int offset, int len); | 309 | int offset, int len); |
311 | extern int csum_partial_copy_fromiovecend(unsigned char *kdata, | 310 | extern int csum_partial_copy_fromiovecend(unsigned char *kdata, |
@@ -314,7 +313,6 @@ extern int csum_partial_copy_fromiovecend(unsigned char *kdata, | |||
314 | unsigned int len, __wsum *csump); | 313 | unsigned int len, __wsum *csump); |
315 | 314 | ||
316 | extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *address, int mode); | 315 | extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *address, int mode); |
317 | extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len); | ||
318 | extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata, | 316 | extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata, |
319 | int offset, int len); | 317 | int offset, int len); |
320 | extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr); | 318 | extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr); |
diff --git a/include/linux/uio.h b/include/linux/uio.h index 629aaf51f30b..c55ce243cc09 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h | |||
@@ -35,4 +35,7 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs) | |||
35 | } | 35 | } |
36 | 36 | ||
37 | unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to); | 37 | unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to); |
38 | |||
39 | int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len); | ||
40 | int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len); | ||
38 | #endif | 41 | #endif |
diff --git a/lib/Makefile b/lib/Makefile index e9c52e1b853a..237721165035 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -9,7 +9,7 @@ endif | |||
9 | 9 | ||
10 | lib-y := ctype.o string.o vsprintf.o cmdline.o \ | 10 | lib-y := ctype.o string.o vsprintf.o cmdline.o \ |
11 | rbtree.o radix-tree.o dump_stack.o timerqueue.o\ | 11 | rbtree.o radix-tree.o dump_stack.o timerqueue.o\ |
12 | idr.o int_sqrt.o extable.o \ | 12 | idr.o int_sqrt.o extable.o iovec.o \ |
13 | sha1.o md5.o irq_regs.o reciprocal_div.o argv_split.o \ | 13 | sha1.o md5.o irq_regs.o reciprocal_div.o argv_split.o \ |
14 | proportions.o flex_proportions.o prio_heap.o ratelimit.o show_mem.o \ | 14 | proportions.o flex_proportions.o prio_heap.o ratelimit.o show_mem.o \ |
15 | is_single_threaded.o plist.o decompress.o kobject_uevent.o \ | 15 | is_single_threaded.o plist.o decompress.o kobject_uevent.o \ |
diff --git a/lib/iovec.c b/lib/iovec.c new file mode 100644 index 000000000000..454baa88bf27 --- /dev/null +++ b/lib/iovec.c | |||
@@ -0,0 +1,53 @@ | |||
1 | #include <linux/uaccess.h> | ||
2 | #include <linux/export.h> | ||
3 | #include <linux/uio.h> | ||
4 | |||
5 | /* | ||
6 | * Copy iovec to kernel. Returns -EFAULT on error. | ||
7 | * | ||
8 | * Note: this modifies the original iovec. | ||
9 | */ | ||
10 | |||
11 | int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len) | ||
12 | { | ||
13 | while (len > 0) { | ||
14 | if (iov->iov_len) { | ||
15 | int copy = min_t(unsigned int, len, iov->iov_len); | ||
16 | if (copy_from_user(kdata, iov->iov_base, copy)) | ||
17 | return -EFAULT; | ||
18 | len -= copy; | ||
19 | kdata += copy; | ||
20 | iov->iov_base += copy; | ||
21 | iov->iov_len -= copy; | ||
22 | } | ||
23 | iov++; | ||
24 | } | ||
25 | |||
26 | return 0; | ||
27 | } | ||
28 | EXPORT_SYMBOL(memcpy_fromiovec); | ||
29 | |||
30 | /* | ||
31 | * Copy kernel to iovec. Returns -EFAULT on error. | ||
32 | * | ||
33 | * Note: this modifies the original iovec. | ||
34 | */ | ||
35 | |||
36 | int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len) | ||
37 | { | ||
38 | while (len > 0) { | ||
39 | if (iov->iov_len) { | ||
40 | int copy = min_t(unsigned int, iov->iov_len, len); | ||
41 | if (copy_to_user(iov->iov_base, kdata, copy)) | ||
42 | return -EFAULT; | ||
43 | kdata += copy; | ||
44 | len -= copy; | ||
45 | iov->iov_len -= copy; | ||
46 | iov->iov_base += copy; | ||
47 | } | ||
48 | iov++; | ||
49 | } | ||
50 | |||
51 | return 0; | ||
52 | } | ||
53 | EXPORT_SYMBOL(memcpy_toiovec); | ||
diff --git a/net/core/iovec.c b/net/core/iovec.c index 7e7aeb01de45..de178e462682 100644 --- a/net/core/iovec.c +++ b/net/core/iovec.c | |||
@@ -75,31 +75,6 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a | |||
75 | 75 | ||
76 | /* | 76 | /* |
77 | * Copy kernel to iovec. Returns -EFAULT on error. | 77 | * Copy kernel to iovec. Returns -EFAULT on error. |
78 | * | ||
79 | * Note: this modifies the original iovec. | ||
80 | */ | ||
81 | |||
82 | int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len) | ||
83 | { | ||
84 | while (len > 0) { | ||
85 | if (iov->iov_len) { | ||
86 | int copy = min_t(unsigned int, iov->iov_len, len); | ||
87 | if (copy_to_user(iov->iov_base, kdata, copy)) | ||
88 | return -EFAULT; | ||
89 | kdata += copy; | ||
90 | len -= copy; | ||
91 | iov->iov_len -= copy; | ||
92 | iov->iov_base += copy; | ||
93 | } | ||
94 | iov++; | ||
95 | } | ||
96 | |||
97 | return 0; | ||
98 | } | ||
99 | EXPORT_SYMBOL(memcpy_toiovec); | ||
100 | |||
101 | /* | ||
102 | * Copy kernel to iovec. Returns -EFAULT on error. | ||
103 | */ | 78 | */ |
104 | 79 | ||
105 | int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata, | 80 | int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata, |
@@ -125,31 +100,6 @@ int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata, | |||
125 | EXPORT_SYMBOL(memcpy_toiovecend); | 100 | EXPORT_SYMBOL(memcpy_toiovecend); |
126 | 101 | ||
127 | /* | 102 | /* |
128 | * Copy iovec to kernel. Returns -EFAULT on error. | ||
129 | * | ||
130 | * Note: this modifies the original iovec. | ||
131 | */ | ||
132 | |||
133 | int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len) | ||
134 | { | ||
135 | while (len > 0) { | ||
136 | if (iov->iov_len) { | ||
137 | int copy = min_t(unsigned int, len, iov->iov_len); | ||
138 | if (copy_from_user(kdata, iov->iov_base, copy)) | ||
139 | return -EFAULT; | ||
140 | len -= copy; | ||
141 | kdata += copy; | ||
142 | iov->iov_base += copy; | ||
143 | iov->iov_len -= copy; | ||
144 | } | ||
145 | iov++; | ||
146 | } | ||
147 | |||
148 | return 0; | ||
149 | } | ||
150 | EXPORT_SYMBOL(memcpy_fromiovec); | ||
151 | |||
152 | /* | ||
153 | * Copy iovec from kernel. Returns -EFAULT on error. | 103 | * Copy iovec from kernel. Returns -EFAULT on error. |
154 | */ | 104 | */ |
155 | 105 | ||