tcp: stronger sk_rcvbuf checks
authorEric Dumazet <edumazet@google.com>
Fri, 11 Jul 2025 11:40:05 +0000 (11:40 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 15 Jul 2025 01:41:43 +0000 (18:41 -0700)
commit1d2fbaad7cd8cc96899179f9898ad2787a15f0a0
tree5dae8f99d03471467256e6bcac1ffb02ec00cda5
parent75dff0584cce79203ee9968c66c7589150fed591
tcp: stronger sk_rcvbuf checks

Currently, TCP stack accepts incoming packet if sizes of receive queues
are below sk->sk_rcvbuf limit.

This can cause memory overshoot if the packet is big, like an 1/2 MB
BIG TCP one.

Refine the check to take into account the incoming skb truesize.

Note that we still accept the packet if the receive queue is empty,
to not completely freeze TCP flows in pathological conditions.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250711114006.480026-8-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/tcp_input.c