From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com,
Eric Dumazet <edumazet@google.com>
Subject: [PATCH net 07/11] tcp: annotate data-races around tp->linger2
Date: Wed, 19 Jul 2023 21:28:53 +0000 [thread overview]
Message-ID: <20230719212857.3943972-8-edumazet@google.com> (raw)
In-Reply-To: <20230719212857.3943972-1-edumazet@google.com>
do_tcp_getsockopt() reads tp->linger2 while another cpu
might change its value.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv4/tcp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 9f74ac16f1c1e53353bd14c6a04e1fa9e3de0c15..2cf129a0c00bfef813e1f1e12cb247ef8107fa88 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3585,11 +3585,11 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname,
case TCP_LINGER2:
if (val < 0)
- tp->linger2 = -1;
+ WRITE_ONCE(tp->linger2, -1);
else if (val > TCP_FIN_TIMEOUT_MAX / HZ)
- tp->linger2 = TCP_FIN_TIMEOUT_MAX;
+ WRITE_ONCE(tp->linger2, TCP_FIN_TIMEOUT_MAX);
else
- tp->linger2 = val * HZ;
+ WRITE_ONCE(tp->linger2, val * HZ);
break;
case TCP_DEFER_ACCEPT:
@@ -3997,7 +3997,7 @@ int do_tcp_getsockopt(struct sock *sk, int level,
READ_ONCE(net->ipv4.sysctl_tcp_syn_retries);
break;
case TCP_LINGER2:
- val = tp->linger2;
+ val = READ_ONCE(tp->linger2);
if (val >= 0)
val = (val ? : READ_ONCE(net->ipv4.sysctl_tcp_fin_timeout)) / HZ;
break;
--
2.41.0.255.g8b1d071c50-goog
next prev parent reply other threads:[~2023-07-19 21:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-19 21:28 [PATCH net 00/11] tcp: add missing annotations Eric Dumazet
2023-07-19 21:28 ` [PATCH net 01/11] tcp: annotate data-races around tp->tcp_tx_delay Eric Dumazet
2023-07-19 21:28 ` [PATCH net 02/11] tcp: annotate data-races around tp->tsoffset Eric Dumazet
2023-07-19 21:28 ` [PATCH net 03/11] tcp: annotate data-races around tp->keepalive_time Eric Dumazet
2023-07-19 21:28 ` [PATCH net 04/11] tcp: annotate data-races around tp->keepalive_intvl Eric Dumazet
2023-07-19 21:28 ` [PATCH net 05/11] tcp: annotate data-races around tp->keepalive_probes Eric Dumazet
2023-07-19 21:28 ` [PATCH net 06/11] tcp: annotate data-races around icsk->icsk_syn_retries Eric Dumazet
2023-07-19 21:28 ` Eric Dumazet [this message]
2023-07-19 21:28 ` [PATCH net 08/11] tcp: annotate data-races around rskq_defer_accept Eric Dumazet
2023-07-19 21:28 ` [PATCH net 09/11] tcp: annotate data-races around tp->notsent_lowat Eric Dumazet
2023-07-19 21:28 ` [PATCH net 10/11] tcp: annotate data-races around icsk->icsk_user_timeout Eric Dumazet
2023-07-19 21:28 ` [PATCH net 11/11] tcp: annotate data-races around fastopenq.max_qlen Eric Dumazet
2023-07-20 19:50 ` [PATCH net 00/11] tcp: add missing annotations patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230719212857.3943972-8-edumazet@google.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).