net: datagram: fix unbounded loop in __skb_try_recv_datagram()
authorPaolo Abeni <pabeni@redhat.com>
Mon, 25 Mar 2019 13:18:06 +0000 (14:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2019 04:26:16 +0000 (06:26 +0200)
commit88c64f9c7d3ffaca070c01c1564afeeaffd472f1
treeb894fadbadf6297fce6096ed081085bb68f70d75
parente4ff39e1ba80a2b2284e217525e9aea07aae76e2
net: datagram: fix unbounded loop in __skb_try_recv_datagram()

[ Upstream commit 0b91bce1ebfc797ff3de60c8f4a1e6219a8a3187 ]

Christoph reported a stall while peeking datagram with an offset when
busy polling is enabled. __skb_try_recv_datagram() uses as the loop
termination condition 'queue empty'. When peeking, the socket
queue can be not empty, even when no additional packets are received.

Address the issue explicitly checking for receive queue changes,
as currently done by __skb_wait_for_more_packets().

Fixes: 2b5cd0dfa384 ("net: Change return type of sk_busy_loop from bool to void")
Reported-and-tested-by: Christoph Paasch <cpaasch@apple.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/datagram.c