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

tcp: Fix a data-race around sysctl_tcp_nometrics_save.

stable inclusion
from stable-v5.10.135
commit 3fb21b67c0fce00dcb6aac5da2aa3f4ab0e89d59
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5ZWFM

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

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

commit 8499a245 upstream.

While reading sysctl_tcp_nometrics_save, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its reader.

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: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 cb8288b7
...@@ -329,7 +329,7 @@ void tcp_update_metrics(struct sock *sk) ...@@ -329,7 +329,7 @@ void tcp_update_metrics(struct sock *sk)
int m; int m;
sk_dst_confirm(sk); sk_dst_confirm(sk);
if (net->ipv4.sysctl_tcp_nometrics_save || !dst) if (READ_ONCE(net->ipv4.sysctl_tcp_nometrics_save) || !dst)
return; return;
rcu_read_lock(); rcu_read_lock();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册