All of lore.kernel.org
 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 5/7] tcp: Fix a data-race around sysctl_tcp_comp_sack_nr.
Date: Fri, 22 Jul 2022 11:22:03 -0700	[thread overview]
Message-ID: <20220722182205.96838-6-kuniyu@amazon.com> (raw)
In-Reply-To: <20220722182205.96838-1-kuniyu@amazon.com>

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

Fixes: 9c21d2fc41c0 ("tcp: add tcp_comp_sack_nr sysctl")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/ipv4/tcp_input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a4d8851d83ff..b1637990d570 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5521,7 +5521,7 @@ static void __tcp_ack_snd_check(struct sock *sk, int ofo_possible)
 	}
 
 	if (!tcp_is_sack(tp) ||
-	    tp->compressed_ack >= sock_net(sk)->ipv4.sysctl_tcp_comp_sack_nr)
+	    tp->compressed_ack >= READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_comp_sack_nr))
 		goto send_now;
 
 	if (tp->compressed_ack_rcv_nxt != tp->rcv_nxt) {
-- 
2.30.2


  parent reply	other threads:[~2022-07-22 18:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-22 18:21 [PATCH v1 net 0/7] sysctl: Fix data-races around ipv4_net_table (Round 6, Final) Kuniyuki Iwashima
2022-07-22 18:21 ` [PATCH v1 net 1/7] tcp: Fix data-races around sk_pacing_rate Kuniyuki Iwashima
2022-07-22 18:22 ` [PATCH v1 net 2/7] net: Fix data-races around sysctl_[rw]mem(_offset)? Kuniyuki Iwashima
2022-07-22 18:22 ` [PATCH v1 net 3/7] tcp: Fix a data-race around sysctl_tcp_comp_sack_delay_ns Kuniyuki Iwashima
2022-07-22 18:22 ` [PATCH v1 net 4/7] tcp: Fix a data-race around sysctl_tcp_comp_sack_slack_ns Kuniyuki Iwashima
2022-07-22 18:22 ` Kuniyuki Iwashima [this message]
2022-07-22 18:22 ` [PATCH v1 net 6/7] tcp: Fix data-races around sysctl_tcp_reflect_tos Kuniyuki Iwashima
2022-07-22 18:58   ` Wei Wang
2022-07-22 18:22 ` [PATCH v1 net 7/7] ipv4: Fix data-races around sysctl_fib_notify_on_flag_change Kuniyuki Iwashima
2022-07-25 12:30 ` [PATCH v1 net 0/7] sysctl: Fix data-races around ipv4_net_table (Round 6, Final) 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=20220722182205.96838-6-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.