diff options
author | Eric Dumazet <edumazet@google.com> | 2023-03-15 20:57:44 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-08-03 08:49:04 +0200 |
commit | a4391e546bcaebc5f9baf0570fe886f2ca5a379c (patch) | |
tree | 35a6759768e78ea88ac07637038f8d827506bb6a /net/ipv4/tcp_input.c | |
parent | 5921e234666dd848da1d08f54801f329d67d8950 (diff) | |
download | linux-a4391e546bcaebc5f9baf0570fe886f2ca5a379c.tar.gz linux-a4391e546bcaebc5f9baf0570fe886f2ca5a379c.tar.bz2 linux-a4391e546bcaebc5f9baf0570fe886f2ca5a379c.zip |
tcp: annotate lockless access to sk->sk_err
[ Upstream commit e13ec3da05d130f0d10da8e1fbe1be26dcdb0e27 ]
tcp_poll() reads sk->sk_err without socket lock held/owned.
We should used READ_ONCE() here, and update writers
to use WRITE_ONCE().
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: 853c3bd7b791 ("tcp: fix race in tcp_write_err()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r-- | net/ipv4/tcp_input.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index fa15c6951cd7..d72255e5262b 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4370,15 +4370,15 @@ void tcp_reset(struct sock *sk, struct sk_buff *skb) /* We want the right error as BSD sees it (and indeed as we do). */ switch (sk->sk_state) { case TCP_SYN_SENT: - sk->sk_err = ECONNREFUSED; + WRITE_ONCE(sk->sk_err, ECONNREFUSED); break; case TCP_CLOSE_WAIT: - sk->sk_err = EPIPE; + WRITE_ONCE(sk->sk_err, EPIPE); break; case TCP_CLOSE: return; default: - sk->sk_err = ECONNRESET; + WRITE_ONCE(sk->sk_err, ECONNRESET); } /* This barrier is coupled with smp_rmb() in tcp_poll() */ smp_wmb(); |