aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-03-21 19:56:16 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-04-09 00:02:34 -0400
commit6aa248145ab0b1809de2411cf129ec1fc315a46f (patch)
tree264f1d52216a267aea823443e728771c9a35a400
parentda18428498fb24438a23d982259461fe22bc1f46 (diff)
switch kernel_sendmsg() and kernel_recvmsg() to iov_iter_kvec()
For kernel_sendmsg() that eliminates the need to play with setfs(); for kernel_recvmsg() it does *not* - a couple of callers are using it with non-NULL ->msg_control, which would be treated as userland address on recvmsg side of things. In all cases we are really setting a kvec-backed iov_iter, though. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--net/socket.c20
1 files changed, 3 insertions, 17 deletions
diff --git a/net/socket.c b/net/socket.c
index e5669cee0759..b6ceeda65214 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -627,18 +627,8 @@ EXPORT_SYMBOL(sock_sendmsg);
627int kernel_sendmsg(struct socket *sock, struct msghdr *msg, 627int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
628 struct kvec *vec, size_t num, size_t size) 628 struct kvec *vec, size_t num, size_t size)
629{ 629{
630 mm_segment_t oldfs = get_fs(); 630 iov_iter_kvec(&msg->msg_iter, WRITE | ITER_KVEC, vec, num, size);
631 int result; 631 return sock_sendmsg(sock, msg, size);
632
633 set_fs(KERNEL_DS);
634 /*
635 * the following is safe, since for compiler definitions of kvec and
636 * iovec are identical, yielding the same in-core layout and alignment
637 */
638 iov_iter_init(&msg->msg_iter, WRITE, (struct iovec *)vec, num, size);
639 result = sock_sendmsg(sock, msg, size);
640 set_fs(oldfs);
641 return result;
642} 632}
643EXPORT_SYMBOL(kernel_sendmsg); 633EXPORT_SYMBOL(kernel_sendmsg);
644 634
@@ -755,12 +745,8 @@ int kernel_recvmsg(struct socket *sock, struct msghdr *msg,
755 mm_segment_t oldfs = get_fs(); 745 mm_segment_t oldfs = get_fs();
756 int result; 746 int result;
757 747
748 iov_iter_kvec(&msg->msg_iter, READ | ITER_KVEC, vec, num, size);
758 set_fs(KERNEL_DS); 749 set_fs(KERNEL_DS);
759 /*
760 * the following is safe, since for compiler definitions of kvec and
761 * iovec are identical, yielding the same in-core layout and alignment
762 */
763 iov_iter_init(&msg->msg_iter, READ, (struct iovec *)vec, num, size);
764 result = sock_recvmsg(sock, msg, size, flags); 750 result = sock_recvmsg(sock, msg, size, flags);
765 set_fs(oldfs); 751 set_fs(oldfs);
766 return result; 752 return result;