提交 81fa3529 编写于 作者: K Kuniyuki Iwashima 提交者: Zheng Zengkai

tcp: Fix a data-race around sysctl_tcp_max_orphans.

stable inclusion
from stable-v5.10.132
commit 6481a8a72a746dc96e3aa70a9f9f6d3daf0f88c2
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5YS3T

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

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

[ Upstream commit 47e6ab24 ]

While reading sysctl_tcp_max_orphans, it can be changed concurrently.
So, we need to add READ_ONCE() to avoid a data-race.

Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Signed-off-by: NKuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 b6795871
...@@ -2494,7 +2494,8 @@ static void tcp_orphan_update(struct timer_list *unused) ...@@ -2494,7 +2494,8 @@ static void tcp_orphan_update(struct timer_list *unused)
static bool tcp_too_many_orphans(int shift) static bool tcp_too_many_orphans(int shift)
{ {
return READ_ONCE(tcp_orphan_cache) << shift > sysctl_tcp_max_orphans; return READ_ONCE(tcp_orphan_cache) << shift >
READ_ONCE(sysctl_tcp_max_orphans);
} }
bool tcp_check_oom(struct sock *sk, int shift) bool tcp_check_oom(struct sock *sk, int shift)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册