aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHarry Lin <mrregi24@gmail.com>2015-07-09 13:00:54 +1000
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-02-22 16:35:29 -0800
commit5080905535c3c977a96a0ef7faaa5095dafd7760 (patch)
tree22ad14e07bf644b33640ded8bfbe6bde6b4b1d99 /net
parent2acd51f51ffd6e14b24d812da47594f53d917378 (diff)
downloadkernel_samsung_smdk4412-5080905535c3c977a96a0ef7faaa5095dafd7760.zip
kernel_samsung_smdk4412-5080905535c3c977a96a0ef7faaa5095dafd7760.tar.gz
kernel_samsung_smdk4412-5080905535c3c977a96a0ef7faaa5095dafd7760.tar.bz2
udp: fix behavior of wrong checksums
We have two problems in UDP stack related to bogus checksums : 1 ) We return -EGAIN to application even if receive queue is not empty. This breaks applications using edge trigger epoll() 2 ) Under UDP flood, we can loop forever without yielding to other processes, potentially hanging the host, especially on non SMP. This patch is an attempt to make things better. We might in the future add extra support for rt applications wanting to better control time spent doing a recv() in a hostile environment. For example we could validate checksums before queuing packets in socket receive queue. Change-Id: Ic25820228fd735e25a850951e059bf75ae39b653 Signed-off-by: Eruc Dumazet <edumazet@google.com> Cc: Willem de Brujin <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/udp.c6
-rw-r--r--net/ipv6/udp.c6
2 files changed, 4 insertions, 8 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 966c3e1..2f00d32 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1249,10 +1249,8 @@ csum_copy_err:
UDP_INC_STATS_USER(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
unlock_sock_fast(sk, slow);
- if (noblock)
- return -EAGAIN;
-
- /* starting over for a new packet */
+ /* starting over for a new packet, but check if we need to yield */
+ cond_resched();
msg->msg_flags &= ~MSG_TRUNC;
goto try_again;
}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 5c363cd..823d1ef 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -453,10 +453,8 @@ csum_copy_err:
}
unlock_sock_fast(sk, slow);
- if (noblock)
- return -EAGAIN;
-
- /* starting over for a new packet */
+ /* starting over for a new packet, but check if we need to yield */
+ cond_resched();
msg->msg_flags &= ~MSG_TRUNC;
goto try_again;
}