aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/socket.c27
-rw-r--r--net/sunrpc/svcsock.c2
2 files changed, 15 insertions, 14 deletions
diff --git a/net/socket.c b/net/socket.c
index b6ceeda65214..21676e469b13 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -610,17 +610,19 @@ void __sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags)
610} 610}
611EXPORT_SYMBOL(__sock_tx_timestamp); 611EXPORT_SYMBOL(__sock_tx_timestamp);
612 612
613static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg, 613static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg)
614 size_t size)
615{ 614{
616 return sock->ops->sendmsg(sock, msg, size); 615 int ret = sock->ops->sendmsg(sock, msg, iov_iter_count(&msg->msg_iter));
616 BUG_ON(ret == -EIOCBQUEUED);
617 return ret;
617} 618}
618 619
619int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) 620int sock_sendmsg(struct socket *sock, struct msghdr *msg)
620{ 621{
621 int err = security_socket_sendmsg(sock, msg, size); 622 int err = security_socket_sendmsg(sock, msg,
623 iov_iter_count(&msg->msg_iter));
622 624
623 return err ?: sock_sendmsg_nosec(sock, msg, size); 625 return err ?: sock_sendmsg_nosec(sock, msg);
624} 626}
625EXPORT_SYMBOL(sock_sendmsg); 627EXPORT_SYMBOL(sock_sendmsg);
626 628
@@ -628,7 +630,7 @@ int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
628 struct kvec *vec, size_t num, size_t size) 630 struct kvec *vec, size_t num, size_t size)
629{ 631{
630 iov_iter_kvec(&msg->msg_iter, WRITE | ITER_KVEC, vec, num, size); 632 iov_iter_kvec(&msg->msg_iter, WRITE | ITER_KVEC, vec, num, size);
631 return sock_sendmsg(sock, msg, size); 633 return sock_sendmsg(sock, msg);
632} 634}
633EXPORT_SYMBOL(kernel_sendmsg); 635EXPORT_SYMBOL(kernel_sendmsg);
634 636
@@ -819,7 +821,7 @@ static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from)
819 if (sock->type == SOCK_SEQPACKET) 821 if (sock->type == SOCK_SEQPACKET)
820 msg.msg_flags |= MSG_EOR; 822 msg.msg_flags |= MSG_EOR;
821 823
822 res = sock_sendmsg(sock, &msg, iov_iter_count(from)); 824 res = sock_sendmsg(sock, &msg);
823 *from = msg.msg_iter; 825 *from = msg.msg_iter;
824 return res; 826 return res;
825} 827}
@@ -1657,7 +1659,7 @@ SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
1657 if (sock->file->f_flags & O_NONBLOCK) 1659 if (sock->file->f_flags & O_NONBLOCK)
1658 flags |= MSG_DONTWAIT; 1660 flags |= MSG_DONTWAIT;
1659 msg.msg_flags = flags; 1661 msg.msg_flags = flags;
1660 err = sock_sendmsg(sock, &msg, iov_iter_count(&msg.msg_iter)); 1662 err = sock_sendmsg(sock, &msg);
1661 1663
1662out_put: 1664out_put:
1663 fput_light(sock->file, fput_needed); 1665 fput_light(sock->file, fput_needed);
@@ -1892,7 +1894,7 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
1892 __attribute__ ((aligned(sizeof(__kernel_size_t)))); 1894 __attribute__ ((aligned(sizeof(__kernel_size_t))));
1893 /* 20 is size of ipv6_pktinfo */ 1895 /* 20 is size of ipv6_pktinfo */
1894 unsigned char *ctl_buf = ctl; 1896 unsigned char *ctl_buf = ctl;
1895 int ctl_len, total_len; 1897 int ctl_len;
1896 ssize_t err; 1898 ssize_t err;
1897 1899
1898 msg_sys->msg_name = &address; 1900 msg_sys->msg_name = &address;
@@ -1903,7 +1905,6 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
1903 err = copy_msghdr_from_user(msg_sys, msg, NULL, &iov); 1905 err = copy_msghdr_from_user(msg_sys, msg, NULL, &iov);
1904 if (err < 0) 1906 if (err < 0)
1905 return err; 1907 return err;
1906 total_len = iov_iter_count(&msg_sys->msg_iter);
1907 1908
1908 err = -ENOBUFS; 1909 err = -ENOBUFS;
1909 1910
@@ -1950,10 +1951,10 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
1950 used_address->name_len == msg_sys->msg_namelen && 1951 used_address->name_len == msg_sys->msg_namelen &&
1951 !memcmp(&used_address->name, msg_sys->msg_name, 1952 !memcmp(&used_address->name, msg_sys->msg_name,
1952 used_address->name_len)) { 1953 used_address->name_len)) {
1953 err = sock_sendmsg_nosec(sock, msg_sys, total_len); 1954 err = sock_sendmsg_nosec(sock, msg_sys);
1954 goto out_freectl; 1955 goto out_freectl;
1955 } 1956 }
1956 err = sock_sendmsg(sock, msg_sys, total_len); 1957 err = sock_sendmsg(sock, msg_sys);
1957 /* 1958 /*
1958 * If this is sendmmsg() and sending to current destination address was 1959 * If this is sendmmsg() and sending to current destination address was
1959 * successful, remember it. 1960 * successful, remember it.
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index cc331b6cf573..0c8120229a03 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -257,7 +257,7 @@ static int svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
257 257
258 svc_set_cmsg_data(rqstp, cmh); 258 svc_set_cmsg_data(rqstp, cmh);
259 259
260 if (sock_sendmsg(sock, &msg, 0) < 0) 260 if (sock_sendmsg(sock, &msg) < 0)
261 goto out; 261 goto out;
262 } 262 }
263 263