diff options
author | Eric Dumazet <edumazet@google.com> | 2017-02-03 17:59:38 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-02-18 09:11:42 -0500 |
commit | 0f895f51a831d73ce24158534784aba5b2a72a9e (patch) | |
tree | 8e0b251b227eb198f69730b3e412f8d4d1cda52d /net/ipv4/tcp.c | |
parent | 1e340bb22af3afc881db78c17b73eaf3d26fb8fe (diff) |
tcp: avoid infinite loop in tcp_splice_read()
[ Upstream commit ccf7abb93af09ad0868ae9033d1ca8108bdaec82 ]
Splicing from TCP socket is vulnerable when a packet with URG flag is
received and stored into receive queue.
__tcp_splice_read() returns 0, and sk_wait_data() immediately
returns since there is the problematic skb in queue.
This is a nice way to burn cpu (aka infinite loop) and trigger
soft lockups.
Again, this gem was found by syzkaller tool.
Fixes: 9c55e01c0cc8 ("[TCP]: Splice receive support.")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 814af89c1bd3..6a90a0e130dc 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -772,6 +772,12 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos, | |||
772 | ret = -EAGAIN; | 772 | ret = -EAGAIN; |
773 | break; | 773 | break; |
774 | } | 774 | } |
775 | /* if __tcp_splice_read() got nothing while we have | ||
776 | * an skb in receive queue, we do not want to loop. | ||
777 | * This might happen with URG data. | ||
778 | */ | ||
779 | if (!skb_queue_empty(&sk->sk_receive_queue)) | ||
780 | break; | ||
775 | sk_wait_data(sk, &timeo, NULL); | 781 | sk_wait_data(sk, &timeo, NULL); |
776 | if (signal_pending(current)) { | 782 | if (signal_pending(current)) { |
777 | ret = sock_intr_errno(timeo); | 783 | ret = sock_intr_errno(timeo); |