提交 9778283c 编写于 作者: E Eric Dumazet 提交者: Zheng Zengkai

tcp: make tcp_read_sock() more robust

stable inclusion
from stable-v5.10.107
commit 2fad5b6948963bac235eac8261d4cd9165eaf1c2
bugzilla: https://gitee.com/openeuler/kernel/issues/I574A2

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2fad5b6948963bac235eac8261d4cd9165eaf1c2

--------------------------------

[ Upstream commit e3d5ea2c ]

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: NEric Dumazet <edumazet@google.com>
Acked-by: NJohn Fastabend <john.fastabend@gmail.com>
Acked-by: NJakub Sitnicki <jakub@cloudflare.com>
Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20220302161723.3910001-2-eric.dumazet@gmail.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYu Liao <liaoyu15@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 76fad1d3
...@@ -1656,11 +1656,13 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc, ...@@ -1656,11 +1656,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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册