netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 01/11] tcp: annotate data-races around tp->tcp_tx_delay
Date: Wed, 19 Jul 2023 21:28:47 +0000	[thread overview]
Message-ID: <20230719212857.3943972-2-edumazet@google.com> (raw)
In-Reply-To: <20230719212857.3943972-1-edumazet@google.com>

do_tcp_getsockopt() reads tp->tcp_tx_delay while another cpu
might change its value.

Fixes: a842fe1425cb ("tcp: add optional per socket transmit delay")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index e03e08745308189c9d64509c2cff94da56c86a0c..bd6400e1ae9f8ae595bbe759ff3dfb1bd02765e2 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3674,7 +3674,7 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname,
 	case TCP_TX_DELAY:
 		if (val)
 			tcp_enable_tx_delay();
-		tp->tcp_tx_delay = val;
+		WRITE_ONCE(tp->tcp_tx_delay, val);
 		break;
 	default:
 		err = -ENOPROTOOPT;
@@ -4154,7 +4154,7 @@ int do_tcp_getsockopt(struct sock *sk, int level,
 		break;
 
 	case TCP_TX_DELAY:
-		val = tp->tcp_tx_delay;
+		val = READ_ONCE(tp->tcp_tx_delay);
 		break;
 
 	case TCP_TIMESTAMP:
-- 
2.41.0.255.g8b1d071c50-goog


  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 ` Eric Dumazet [this message]
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 ` [PATCH net 07/11] tcp: annotate data-races around tp->linger2 Eric Dumazet
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-2-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).