netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	David Ahern <dsahern@kernel.org>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>,
	Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>
Subject: [PATCH v1 net 07/15] tcp: Fix data-races around sysctl_tcp_moderate_rcvbuf.
Date: Wed, 20 Jul 2022 09:50:18 -0700	[thread overview]
Message-ID: <20220720165026.59712-8-kuniyu@amazon.com> (raw)
In-Reply-To: <20220720165026.59712-1-kuniyu@amazon.com>

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

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/ipv4/tcp_input.c | 2 +-
 net/mptcp/protocol.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index af376d7423d1..debfff94f3af 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -724,7 +724,7 @@ void tcp_rcv_space_adjust(struct sock *sk)
 	 * <prev RTT . ><current RTT .. ><next RTT .... >
 	 */
 
-	if (sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf &&
+	if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf) &&
 	    !(sk->sk_userlocks & SOCK_RCVBUF_LOCK)) {
 		int rcvmem, rcvbuf;
 		u64 rcvwin, grow;
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 21a3ed64226e..9bbd8cbe0acb 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1908,7 +1908,7 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)
 	if (msk->rcvq_space.copied <= msk->rcvq_space.space)
 		goto new_measure;
 
-	if (sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf &&
+	if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf) &&
 	    !(sk->sk_userlocks & SOCK_RCVBUF_LOCK)) {
 		int rcvmem, rcvbuf;
 		u64 rcvwin, grow;
-- 
2.30.2


  parent reply	other threads:[~2022-07-20 16:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20 16:50 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 5) Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 01/15] tcp: Fix data-races around sysctl_tcp_dsack Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 02/15] tcp: Fix a data-race around sysctl_tcp_app_win Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 03/15] tcp: Fix a data-race around sysctl_tcp_adv_win_scale Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 04/15] tcp: Fix a data-race around sysctl_tcp_frto Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 05/15] tcp: Fix a data-race around sysctl_tcp_nometrics_save Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 06/15] tcp: Fix data-races around sysctl_tcp_no_ssthresh_metrics_save Kuniyuki Iwashima
2022-07-20 16:50 ` Kuniyuki Iwashima [this message]
2022-07-20 16:50 ` [PATCH v1 net 08/15] tcp: Fix data-races around sysctl_tcp_workaround_signed_windows Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 09/15] tcp: Fix a data-race around sysctl_tcp_limit_output_bytes Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 10/15] tcp: Fix a data-race around sysctl_tcp_challenge_ack_limit Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 11/15] tcp: Fix a data-race around sysctl_tcp_min_tso_segs Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 12/15] tcp: Fix a data-race around sysctl_tcp_tso_rtt_log Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 13/15] tcp: Fix a data-race around sysctl_tcp_min_rtt_wlen Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 14/15] tcp: Fix a data-race around sysctl_tcp_autocorking Kuniyuki Iwashima
2022-07-20 16:50 ` [PATCH v1 net 15/15] tcp: Fix a data-race around sysctl_tcp_invalid_ratelimit Kuniyuki Iwashima
2022-07-20 17:17 ` [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 5) Eric Dumazet
2022-07-22 11:10 ` 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=20220720165026.59712-8-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --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).