Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21226abb authored by Al Viro's avatar Al Viro
Browse files

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: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 57be5bda
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -2692,8 +2692,7 @@ int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);


static inline int memcpy_from_msg(void *data, struct msghdr *msg, int len)
static inline int memcpy_from_msg(void *data, struct msghdr *msg, int len)
{
{
	/* XXX: stripping const */
	return copy_from_iter(data, len, &msg->msg_iter) == len ? 0 : -EFAULT;
	return memcpy_fromiovec(data, (struct iovec *)msg->msg_iter.iov, len);
}
}


static inline int memcpy_to_msg(struct msghdr *msg, void *data, int len)
static inline int memcpy_to_msg(struct msghdr *msg, void *data, int len)
+1 −2
Original line number Original line Diff line number Diff line
@@ -20,8 +20,7 @@ static __inline__ int udplite_getfrag(void *from, char *to, int offset,
				      int len, int odd, struct sk_buff *skb)
				      int len, int odd, struct sk_buff *skb)
{
{
	struct msghdr *msg = from;
	struct msghdr *msg = from;
	/* XXX: stripping const */
	return copy_from_iter(to, len, &msg->msg_iter) != len ? -EFAULT : 0;
	return memcpy_fromiovecend(to, (struct iovec *)msg->msg_iter.iov, offset, len);
}
}


/* Designate sk as UDP-Lite socket */
/* Designate sk as UDP-Lite socket */
+2 −4
Original line number Original line Diff line number Diff line
@@ -755,13 +755,11 @@ ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk
	struct msghdr *msg = from;
	struct msghdr *msg = from;


	if (skb->ip_summed == CHECKSUM_PARTIAL) {
	if (skb->ip_summed == CHECKSUM_PARTIAL) {
		/* XXX: stripping const */
		if (copy_from_iter(to, len, &msg->msg_iter) != len)
		if (memcpy_fromiovecend(to, (struct iovec *)msg->msg_iter.iov, offset, len) < 0)
			return -EFAULT;
			return -EFAULT;
	} else {
	} else {
		__wsum csum = 0;
		__wsum csum = 0;
		/* XXX: stripping const */
		if (csum_and_copy_from_iter(to, len, &csum, &msg->msg_iter) != len)
		if (csum_partial_copy_fromiovecend(to, (struct iovec *)msg->msg_iter.iov, offset, len, &csum) < 0)
			return -EFAULT;
			return -EFAULT;
		skb->csum = csum_block_add(skb->csum, csum, odd);
		skb->csum = csum_block_add(skb->csum, csum, odd);
	}
	}
+7 −7
Original line number Original line Diff line number Diff line
@@ -599,18 +599,18 @@ int ping_getfrag(void *from, char *to,
	struct pingfakehdr *pfh = (struct pingfakehdr *)from;
	struct pingfakehdr *pfh = (struct pingfakehdr *)from;


	if (offset == 0) {
	if (offset == 0) {
		if (fraglen < sizeof(struct icmphdr))
		fraglen -= sizeof(struct icmphdr);
		if (fraglen < 0)
			BUG();
			BUG();
		if (csum_partial_copy_fromiovecend(to + sizeof(struct icmphdr),
		if (csum_and_copy_from_iter(to + sizeof(struct icmphdr),
			    pfh->msg->msg_iter.iov, 0, fraglen - sizeof(struct icmphdr),
			    fraglen, &pfh->wcheck,
			    &pfh->wcheck))
			    &pfh->msg->msg_iter) != fraglen)
			return -EFAULT;
			return -EFAULT;
	} else if (offset < sizeof(struct icmphdr)) {
	} else if (offset < sizeof(struct icmphdr)) {
			BUG();
			BUG();
	} else {
	} else {
		if (csum_partial_copy_fromiovecend
		if (csum_and_copy_from_iter(to, fraglen, &pfh->wcheck,
				(to, pfh->msg->msg_iter.iov, offset - sizeof(struct icmphdr),
					    &pfh->msg->msg_iter) != fraglen)
				 fraglen, &pfh->wcheck))
			return -EFAULT;
			return -EFAULT;
	}
	}


+1 −1
Original line number Original line Diff line number Diff line
@@ -382,7 +382,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,


	skb->transport_header = skb->network_header;
	skb->transport_header = skb->network_header;
	err = -EFAULT;
	err = -EFAULT;
	if (memcpy_fromiovecend((void *)iph, msg->msg_iter.iov, 0, length))
	if (memcpy_from_msg(iph, msg, length))
		goto error_free;
		goto error_free;


	iphlen = iph->ihl * 4;
	iphlen = iph->ihl * 4;
Loading