Skip to content

Commit b6653b3

Browse files
edumazetdavem330
authored andcommitted
tcp: refine memory limit test in tcp_fragment()
tcp_fragment() might be called for skbs in the write queue. Memory limits might have been exceeded because tcp_sendmsg() only checks limits at full skb (64KB) boundaries. Therefore, we need to make sure tcp_fragment() wont punish applications that might have setup very low SO_SNDBUF values. Fixes: f070ef2 ("tcp: tcp_fragment() should apply sane memory limits") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: Christoph Paasch <[email protected]> Tested-by: Christoph Paasch <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 85f9aa7 commit b6653b3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/ipv4/tcp_output.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,8 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue,
12961296
if (nsize < 0)
12971297
nsize = 0;
12981298

1299-
if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf)) {
1299+
if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf &&
1300+
tcp_queue != TCP_FRAG_IN_WRITE_QUEUE)) {
13001301
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPWQUEUETOOBIG);
13011302
return -ENOMEM;
13021303
}

0 commit comments

Comments
 (0)