Message ID | 20220302161723.3910001-2-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | e3d5ea2c011ecb16fb94c56a659364e6b30fac94 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,1/2] bpf, sockmap: Do not ignore orig_len parameter | expand |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 02cb275e5487d98b3e124ee102163aac47b2ad6d..28ff2a820f7c935234e5ab7ecd4ed95fb7c5712a 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1684,11 +1684,13 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc, if (!copied) copied = used; break; - } else if (used <= len) { - seq += used; - copied += used; - offset += used; } + if (WARN_ON_ONCE(used > len)) + used = len; + seq += used; + copied += used; + offset += used; + /* If recv_actor drops the lock (e.g. TCP splice * receive) the skb pointer might be invalid when * getting here: tcp_collapse might have deleted it