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

tcp: Fix data-races around keepalive sysctl knobs.

stable inclusion
from stable-v5.10.134
commit fc489055e7e8abe409224ff18863999cede92fbf
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5ZVR7

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

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

[ Upstream commit f2f316e2 ]

While reading sysctl_tcp_keepalive_(time|probes|intvl), they can be changed
concurrently.  Thus, we need to add READ_ONCE() to their readers.

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>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 ce48818f
...@@ -1449,21 +1449,24 @@ static inline int keepalive_intvl_when(const struct tcp_sock *tp) ...@@ -1449,21 +1449,24 @@ static inline int keepalive_intvl_when(const struct tcp_sock *tp)
{ {
struct net *net = sock_net((struct sock *)tp); struct net *net = sock_net((struct sock *)tp);
return tp->keepalive_intvl ? : net->ipv4.sysctl_tcp_keepalive_intvl; return tp->keepalive_intvl ? :
READ_ONCE(net->ipv4.sysctl_tcp_keepalive_intvl);
} }
static inline int keepalive_time_when(const struct tcp_sock *tp) static inline int keepalive_time_when(const struct tcp_sock *tp)
{ {
struct net *net = sock_net((struct sock *)tp); struct net *net = sock_net((struct sock *)tp);
return tp->keepalive_time ? : net->ipv4.sysctl_tcp_keepalive_time; return tp->keepalive_time ? :
READ_ONCE(net->ipv4.sysctl_tcp_keepalive_time);
} }
static inline int keepalive_probes(const struct tcp_sock *tp) static inline int keepalive_probes(const struct tcp_sock *tp)
{ {
struct net *net = sock_net((struct sock *)tp); struct net *net = sock_net((struct sock *)tp);
return tp->keepalive_probes ? : net->ipv4.sysctl_tcp_keepalive_probes; return tp->keepalive_probes ? :
READ_ONCE(net->ipv4.sysctl_tcp_keepalive_probes);
} }
static inline u32 keepalive_time_elapsed(const struct tcp_sock *tp) static inline u32 keepalive_time_elapsed(const struct tcp_sock *tp)
......
...@@ -1787,7 +1787,7 @@ void smc_llc_lgr_init(struct smc_link_group *lgr, struct smc_sock *smc) ...@@ -1787,7 +1787,7 @@ void smc_llc_lgr_init(struct smc_link_group *lgr, struct smc_sock *smc)
init_waitqueue_head(&lgr->llc_flow_waiter); init_waitqueue_head(&lgr->llc_flow_waiter);
init_waitqueue_head(&lgr->llc_msg_waiter); init_waitqueue_head(&lgr->llc_msg_waiter);
mutex_init(&lgr->llc_conf_mutex); mutex_init(&lgr->llc_conf_mutex);
lgr->llc_testlink_time = net->ipv4.sysctl_tcp_keepalive_time; lgr->llc_testlink_time = READ_ONCE(net->ipv4.sysctl_tcp_keepalive_time);
} }
/* called after lgr was removed from lgr_list */ /* called after lgr was removed from lgr_list */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册