Commit 0920a711 authored by Luis Henriques's avatar Luis Henriques

Revert "[stable-only] net: add length argument to skb_copy_and_csum_datagram_iovec"

This reverts commit fa89ae55.

As reported by Michal Kubecek, the backport of commit 89c22d8c
("net: Fix skb csum races when peeking") exposed an upstream bug.
It is being reverted and replaced by a better fix.
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 0f7b4f79
...@@ -2525,7 +2525,7 @@ unsigned int datagram_poll(struct file *file, struct socket *sock, ...@@ -2525,7 +2525,7 @@ unsigned int datagram_poll(struct file *file, struct socket *sock,
int skb_copy_datagram_iovec(const struct sk_buff *from, int offset, int skb_copy_datagram_iovec(const struct sk_buff *from, int offset,
struct iovec *to, int size); struct iovec *to, int size);
int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, int hlen, int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, int hlen,
struct iovec *iov, int len); struct iovec *iov);
int skb_copy_datagram_from_iovec(struct sk_buff *skb, int offset, int skb_copy_datagram_from_iovec(struct sk_buff *skb, int offset,
const struct iovec *from, int from_offset, const struct iovec *from, int from_offset,
int len); int len);
......
...@@ -818,7 +818,6 @@ EXPORT_SYMBOL(__skb_checksum_complete); ...@@ -818,7 +818,6 @@ EXPORT_SYMBOL(__skb_checksum_complete);
* @skb: skbuff * @skb: skbuff
* @hlen: hardware length * @hlen: hardware length
* @iov: io vector * @iov: io vector
* @len: amount of data to copy from skb to iov
* *
* Caller _must_ check that skb will fit to this iovec. * Caller _must_ check that skb will fit to this iovec.
* *
...@@ -828,14 +827,11 @@ EXPORT_SYMBOL(__skb_checksum_complete); ...@@ -828,14 +827,11 @@ EXPORT_SYMBOL(__skb_checksum_complete);
* can be modified! * can be modified!
*/ */
int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
int hlen, struct iovec *iov, int len) int hlen, struct iovec *iov)
{ {
__wsum csum; __wsum csum;
int chunk = skb->len - hlen; int chunk = skb->len - hlen;
if (chunk > len)
chunk = len;
if (!chunk) if (!chunk)
return 0; return 0;
......
...@@ -4903,7 +4903,7 @@ static int tcp_copy_to_iovec(struct sock *sk, struct sk_buff *skb, int hlen) ...@@ -4903,7 +4903,7 @@ static int tcp_copy_to_iovec(struct sock *sk, struct sk_buff *skb, int hlen)
err = skb_copy_datagram_iovec(skb, hlen, tp->ucopy.iov, chunk); err = skb_copy_datagram_iovec(skb, hlen, tp->ucopy.iov, chunk);
else else
err = skb_copy_and_csum_datagram_iovec(skb, hlen, err = skb_copy_and_csum_datagram_iovec(skb, hlen,
tp->ucopy.iov, chunk); tp->ucopy.iov);
if (!err) { if (!err) {
tp->ucopy.len -= chunk; tp->ucopy.len -= chunk;
......
...@@ -1307,7 +1307,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -1307,7 +1307,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
else { else {
err = skb_copy_and_csum_datagram_iovec(skb, err = skb_copy_and_csum_datagram_iovec(skb,
sizeof(struct udphdr), sizeof(struct udphdr),
msg->msg_iov, copied); msg->msg_iov);
if (err == -EINVAL) if (err == -EINVAL)
goto csum_copy_err; goto csum_copy_err;
......
...@@ -492,7 +492,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -492,7 +492,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
goto csum_copy_err; goto csum_copy_err;
err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
} else { } else {
err = skb_copy_and_csum_datagram_iovec(skb, 0, msg->msg_iov, copied); err = skb_copy_and_csum_datagram_iovec(skb, 0, msg->msg_iov);
if (err == -EINVAL) if (err == -EINVAL)
goto csum_copy_err; goto csum_copy_err;
} }
......
...@@ -428,8 +428,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -428,8 +428,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
msg->msg_iov, copied); msg->msg_iov, copied);
else { else {
err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov);
msg->msg_iov, copied);
if (err == -EINVAL) if (err == -EINVAL)
goto csum_copy_err; goto csum_copy_err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment