Commit 59c2cdae authored by David S. Miller's avatar David S. Miller

Revert "udp: remove redundant variable"

This reverts commit 81d54ec8.

If we take the "try_again" goto, due to a checksum error,
the 'len' has already been truncated.  So we won't compute
the same values as the original code did.
Reported-by: default avatarpaul bilke <fsmail@conspiracy.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b03b6dd5
...@@ -1164,7 +1164,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -1164,7 +1164,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
struct sk_buff *skb; struct sk_buff *skb;
unsigned int ulen; unsigned int ulen, copied;
int peeked; int peeked;
int err; int err;
int is_udplite = IS_UDPLITE(sk); int is_udplite = IS_UDPLITE(sk);
...@@ -1186,9 +1186,10 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -1186,9 +1186,10 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
goto out; goto out;
ulen = skb->len - sizeof(struct udphdr); ulen = skb->len - sizeof(struct udphdr);
if (len > ulen) copied = len;
len = ulen; if (copied > ulen)
else if (len < ulen) copied = ulen;
else if (copied < ulen)
msg->msg_flags |= MSG_TRUNC; msg->msg_flags |= MSG_TRUNC;
/* /*
...@@ -1197,14 +1198,14 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -1197,14 +1198,14 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
* coverage checksum (UDP-Lite), do it before the copy. * coverage checksum (UDP-Lite), do it before the copy.
*/ */
if (len < ulen || UDP_SKB_CB(skb)->partial_cov) { if (copied < ulen || UDP_SKB_CB(skb)->partial_cov) {
if (udp_lib_checksum_complete(skb)) if (udp_lib_checksum_complete(skb))
goto csum_copy_err; goto csum_copy_err;
} }
if (skb_csum_unnecessary(skb)) if (skb_csum_unnecessary(skb))
err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
msg->msg_iov, len); msg->msg_iov, copied);
else { else {
err = skb_copy_and_csum_datagram_iovec(skb, err = skb_copy_and_csum_datagram_iovec(skb,
sizeof(struct udphdr), sizeof(struct udphdr),
...@@ -1233,7 +1234,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -1233,7 +1234,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
if (inet->cmsg_flags) if (inet->cmsg_flags)
ip_cmsg_recv(msg, skb); ip_cmsg_recv(msg, skb);
err = len; err = copied;
if (flags & MSG_TRUNC) if (flags & MSG_TRUNC)
err = ulen; err = ulen;
......
...@@ -340,7 +340,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -340,7 +340,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct sk_buff *skb; struct sk_buff *skb;
unsigned int ulen; unsigned int ulen, copied;
int peeked; int peeked;
int err; int err;
int is_udplite = IS_UDPLITE(sk); int is_udplite = IS_UDPLITE(sk);
...@@ -363,9 +363,10 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -363,9 +363,10 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
goto out; goto out;
ulen = skb->len - sizeof(struct udphdr); ulen = skb->len - sizeof(struct udphdr);
if (len > ulen) copied = len;
len = ulen; if (copied > ulen)
else if (len < ulen) copied = ulen;
else if (copied < ulen)
msg->msg_flags |= MSG_TRUNC; msg->msg_flags |= MSG_TRUNC;
is_udp4 = (skb->protocol == htons(ETH_P_IP)); is_udp4 = (skb->protocol == htons(ETH_P_IP));
...@@ -376,14 +377,14 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -376,14 +377,14 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
* coverage checksum (UDP-Lite), do it before the copy. * coverage checksum (UDP-Lite), do it before the copy.
*/ */
if (len < ulen || UDP_SKB_CB(skb)->partial_cov) { if (copied < ulen || UDP_SKB_CB(skb)->partial_cov) {
if (udp_lib_checksum_complete(skb)) if (udp_lib_checksum_complete(skb))
goto csum_copy_err; goto csum_copy_err;
} }
if (skb_csum_unnecessary(skb)) if (skb_csum_unnecessary(skb))
err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
msg->msg_iov,len); msg->msg_iov, copied );
else { else {
err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov); err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov);
if (err == -EINVAL) if (err == -EINVAL)
...@@ -432,7 +433,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -432,7 +433,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
datagram_recv_ctl(sk, msg, skb); datagram_recv_ctl(sk, msg, skb);
} }
err = len; err = copied;
if (flags & MSG_TRUNC) if (flags & MSG_TRUNC)
err = ulen; err = ulen;
......
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