mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 05:55:44 +02:00
tcp: make tcp_read_sock() more robust
[ Upstream commit e3d5ea2c01 ]
If recv_actor() returns an incorrect value, tcp_read_sock()
might loop forever.
Instead, issue a one time warning and make sure to make progress.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Jakub Sitnicki <jakub@cloudflare.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20220302161723.3910001-2-eric.dumazet@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
3f9a8f8a95
commit
2fad5b6948
|
|
@ -1652,11 +1652,13 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
|
||||||
if (!copied)
|
if (!copied)
|
||||||
copied = used;
|
copied = used;
|
||||||
break;
|
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
|
/* If recv_actor drops the lock (e.g. TCP splice
|
||||||
* receive) the skb pointer might be invalid when
|
* receive) the skb pointer might be invalid when
|
||||||
* getting here: tcp_collapse might have deleted it
|
* getting here: tcp_collapse might have deleted it
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user