提交 3dd5b8ef 编写于 作者: K Kuniyuki Iwashima 提交者: Yongqiang Liu

tcp: Fix a data-race around sysctl_tcp_autocorking.

stable inclusion
from stable-v4.19.255
commit 5e3d32bb5884cd0c992542f7a887e26d4118b415
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5Q0SQ
CVE: NA

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

[ Upstream commit 85225e6f ]

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

Fixes: f54b3111 ("tcp: auto corking")
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: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 cbf4b012
...@@ -711,7 +711,7 @@ static bool tcp_should_autocork(struct sock *sk, struct sk_buff *skb, ...@@ -711,7 +711,7 @@ static bool tcp_should_autocork(struct sock *sk, struct sk_buff *skb,
int size_goal) int size_goal)
{ {
return skb->len < size_goal && return skb->len < size_goal &&
sock_net(sk)->ipv4.sysctl_tcp_autocorking && READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_autocorking) &&
!tcp_rtx_queue_empty(sk) && !tcp_rtx_queue_empty(sk) &&
refcount_read(&sk->sk_wmem_alloc) > skb->truesize; refcount_read(&sk->sk_wmem_alloc) > skb->truesize;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册