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

tcp: Fix a data-race around sysctl_tcp_autocorking.

stable inclusion
from stable-v5.10.135
commit c4e6029a85c8459482284f0edabd1b8fe2909011
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=c4e6029a85c8459482284f0edabd1b8fe2909011

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

[ 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: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 eb6b1e50
...@@ -702,7 +702,7 @@ static bool tcp_should_autocork(struct sock *sk, struct sk_buff *skb, ...@@ -702,7 +702,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.
先完成此消息的编辑!
想要评论请 注册