aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-22 10:16:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-22 10:16:49 -0400
commit94f1be9798c88b030256bdeb533008c3d55ec2c6 (patch)
treee73baba68b700e50cab2a22025f85c0455df5470
parent519fe2ecb755b875d9814cdda19778c2e88c6901 (diff)
parent6407d75afd08545f2252bb39806ffd3f10c7faac (diff)
Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull virtio fixes from Rusty Russell: "A build fix and a uapi exposure fix. The build fix is later than I liked, but my first version broke linux-next due to overzealous header clean." * tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: virtio_console: fix uapi header Hoist memcpy_fromiovec/memcpy_toiovec into lib/
-rw-r--r--drivers/misc/vmw_vmci/Kconfig2
-rw-r--r--drivers/misc/vmw_vmci/vmci_queue_pair.c2
-rw-r--r--include/linux/socket.h2
-rw-r--r--include/linux/uio.h3
-rw-r--r--include/uapi/linux/virtio_console.h2
-rw-r--r--lib/Makefile2
-rw-r--r--lib/iovec.c53
-rw-r--r--net/core/iovec.c50
8 files changed, 60 insertions, 56 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
5config VMWARE_VMCI 5config 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
306extern void cred_to_ucred(struct pid *pid, const struct cred *cred, struct ucred *ucred); 306extern void cred_to_ucred(struct pid *pid, const struct cred *cred, struct ucred *ucred);
307 307
308extern int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
309extern int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov, 308extern int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
310 int offset, int len); 309 int offset, int len);
311extern int csum_partial_copy_fromiovecend(unsigned char *kdata, 310extern 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
316extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *address, int mode); 315extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *address, int mode);
317extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len);
318extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata, 316extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata,
319 int offset, int len); 317 int offset, int len);
320extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr); 318extern 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
37unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to); 37unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
38
39int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
40int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len);
38#endif 41#endif
diff --git a/include/uapi/linux/virtio_console.h b/include/uapi/linux/virtio_console.h
index ee13ab6c3614..c312f16bc4e7 100644
--- a/include/uapi/linux/virtio_console.h
+++ b/include/uapi/linux/virtio_console.h
@@ -39,7 +39,7 @@
39#define VIRTIO_CONSOLE_F_SIZE 0 /* Does host provide console size? */ 39#define VIRTIO_CONSOLE_F_SIZE 0 /* Does host provide console size? */
40#define VIRTIO_CONSOLE_F_MULTIPORT 1 /* Does host provide multiple ports? */ 40#define VIRTIO_CONSOLE_F_MULTIPORT 1 /* Does host provide multiple ports? */
41 41
42#define VIRTIO_CONSOLE_BAD_ID (~(u32)0) 42#define VIRTIO_CONSOLE_BAD_ID (~(__u32)0)
43 43
44struct virtio_console_config { 44struct virtio_console_config {
45 /* colums of the screens */ 45 /* colums of the screens */
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
10lib-y := ctype.o string.o vsprintf.o cmdline.o \ 10lib-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
11int 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}
28EXPORT_SYMBOL(memcpy_fromiovec);
29
30/*
31 * Copy kernel to iovec. Returns -EFAULT on error.
32 *
33 * Note: this modifies the original iovec.
34 */
35
36int 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}
53EXPORT_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
82int 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}
99EXPORT_SYMBOL(memcpy_toiovec);
100
101/*
102 * Copy kernel to iovec. Returns -EFAULT on error.
103 */ 78 */
104 79
105int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata, 80int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata,
@@ -125,31 +100,6 @@ int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata,
125EXPORT_SYMBOL(memcpy_toiovecend); 100EXPORT_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
133int 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}
150EXPORT_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