Skip to content

Commit ccf7abb

Browse files
Eric Dumazetdavem330
authored andcommitted
tcp: avoid infinite loop in tcp_splice_read()
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: 9c55e01 ("[TCP]: Splice receive support.") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: Dmitry Vyukov <[email protected]> Cc: Willy Tarreau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b3f2d07 commit ccf7abb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/ipv4/tcp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,12 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
770770
ret = -EAGAIN;
771771
break;
772772
}
773+
/* if __tcp_splice_read() got nothing while we have
774+
* an skb in receive queue, we do not want to loop.
775+
* This might happen with URG data.
776+
*/
777+
if (!skb_queue_empty(&sk->sk_receive_queue))
778+
break;
773779
sk_wait_data(sk, &timeo, NULL);
774780
if (signal_pending(current)) {
775781
ret = sock_intr_errno(timeo);

0 commit comments

Comments
 (0)