Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: switch memcpy_fromiovec()/memcpy_fromiovecend() users to copy_from_iter()

That takes care of the majority of ->sendmsg() instances - most of them
via memcpy_to_msg() or assorted getfrag() callbacks. One place where we
still keep memcpy_fromiovecend() is tipc - there we potentially read the
same data over and over; separate patch, that...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 21226abb 57be5bda

+14 -18
+1 -2
include/linux/skbuff.h
··· 2692 2692 2693 2693 static inline int memcpy_from_msg(void *data, struct msghdr *msg, int len) 2694 2694 { 2695 - /* XXX: stripping const */ 2696 - return memcpy_fromiovec(data, (struct iovec *)msg->msg_iter.iov, len); 2695 + return copy_from_iter(data, len, &msg->msg_iter) == len ? 0 : -EFAULT; 2697 2696 } 2698 2697 2699 2698 static inline int memcpy_to_msg(struct msghdr *msg, void *data, int len)
+1 -2
include/net/udplite.h
··· 20 20 int len, int odd, struct sk_buff *skb) 21 21 { 22 22 struct msghdr *msg = from; 23 - /* XXX: stripping const */ 24 - return memcpy_fromiovecend(to, (struct iovec *)msg->msg_iter.iov, offset, len); 23 + return copy_from_iter(to, len, &msg->msg_iter) != len ? -EFAULT : 0; 25 24 } 26 25 27 26 /* Designate sk as UDP-Lite socket */
+2 -4
net/ipv4/ip_output.c
··· 755 755 struct msghdr *msg = from; 756 756 757 757 if (skb->ip_summed == CHECKSUM_PARTIAL) { 758 - /* XXX: stripping const */ 759 - if (memcpy_fromiovecend(to, (struct iovec *)msg->msg_iter.iov, offset, len) < 0) 758 + if (copy_from_iter(to, len, &msg->msg_iter) != len) 760 759 return -EFAULT; 761 760 } else { 762 761 __wsum csum = 0; 763 - /* XXX: stripping const */ 764 - if (csum_partial_copy_fromiovecend(to, (struct iovec *)msg->msg_iter.iov, offset, len, &csum) < 0) 762 + if (csum_and_copy_from_iter(to, len, &csum, &msg->msg_iter) != len) 765 763 return -EFAULT; 766 764 skb->csum = csum_block_add(skb->csum, csum, odd); 767 765 }
+7 -7
net/ipv4/ping.c
··· 599 599 struct pingfakehdr *pfh = (struct pingfakehdr *)from; 600 600 601 601 if (offset == 0) { 602 - if (fraglen < sizeof(struct icmphdr)) 602 + fraglen -= sizeof(struct icmphdr); 603 + if (fraglen < 0) 603 604 BUG(); 604 - if (csum_partial_copy_fromiovecend(to + sizeof(struct icmphdr), 605 - pfh->msg->msg_iter.iov, 0, fraglen - sizeof(struct icmphdr), 606 - &pfh->wcheck)) 605 + if (csum_and_copy_from_iter(to + sizeof(struct icmphdr), 606 + fraglen, &pfh->wcheck, 607 + &pfh->msg->msg_iter) != fraglen) 607 608 return -EFAULT; 608 609 } else if (offset < sizeof(struct icmphdr)) { 609 610 BUG(); 610 611 } else { 611 - if (csum_partial_copy_fromiovecend 612 - (to, pfh->msg->msg_iter.iov, offset - sizeof(struct icmphdr), 613 - fraglen, &pfh->wcheck)) 612 + if (csum_and_copy_from_iter(to, fraglen, &pfh->wcheck, 613 + &pfh->msg->msg_iter) != fraglen) 614 614 return -EFAULT; 615 615 } 616 616
+1 -1
net/ipv4/raw.c
··· 382 382 383 383 skb->transport_header = skb->network_header; 384 384 err = -EFAULT; 385 - if (memcpy_fromiovecend((void *)iph, msg->msg_iter.iov, 0, length)) 385 + if (memcpy_from_msg(iph, msg, length)) 386 386 goto error_free; 387 387 388 388 iphlen = iph->ihl * 4;
+1 -1
net/ipv4/tcp_input.c
··· 4368 4368 if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) 4369 4369 goto err_free; 4370 4370 4371 - if (copy_from_iter(skb_put(skb, size), size, &msg->msg_iter) != size) 4371 + if (memcpy_from_msg(skb_put(skb, size), msg, size)) 4372 4372 goto err_free; 4373 4373 4374 4374 TCP_SKB_CB(skb)->seq = tcp_sk(sk)->rcv_nxt;
+1 -1
net/ipv6/raw.c
··· 648 648 skb->ip_summed = CHECKSUM_NONE; 649 649 650 650 skb->transport_header = skb->network_header; 651 - err = memcpy_fromiovecend((void *)iph, msg->msg_iter.iov, 0, length); 651 + err = memcpy_from_msg(iph, msg, length); 652 652 if (err) 653 653 goto error_fault; 654 654