]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
tcp: Fix data-races around sysctl_tcp_base_mss.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Wed, 13 Jul 2022 20:52:01 +0000 (13:52 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Jul 2022 15:19:13 +0000 (17:19 +0200)
[ Upstream commit 88d78bc097cd8ebc6541e93316c9d9bf651b13e8 ]

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

Fixes: 5d424d5a674f ("[TCP]: MTU probing")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/tcp_output.c
net/ipv4/tcp_timer.c

index 423ec09ad83167d814824b468c4cca2623a2e330..9f3eec8e7e4c5d73a30df271863962a0b974d8ef 100644 (file)
@@ -1766,7 +1766,7 @@ void tcp_mtup_init(struct sock *sk)
        icsk->icsk_mtup.enabled = READ_ONCE(net->ipv4.sysctl_tcp_mtu_probing) > 1;
        icsk->icsk_mtup.search_high = tp->rx_opt.mss_clamp + sizeof(struct tcphdr) +
                               icsk->icsk_af_ops->net_header_len;
-       icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, net->ipv4.sysctl_tcp_base_mss);
+       icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, READ_ONCE(net->ipv4.sysctl_tcp_base_mss));
        icsk->icsk_mtup.probe_size = 0;
        if (icsk->icsk_mtup.enabled)
                icsk->icsk_mtup.probe_timestamp = tcp_jiffies32;
index 3c0d689cafaca0b5e054942d6d6395bf73e7bf34..795716fd37611144ee6969003cfebfca62d21444 100644 (file)
@@ -171,7 +171,7 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk)
                icsk->icsk_mtup.probe_timestamp = tcp_jiffies32;
        } else {
                mss = tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1;
-               mss = min(net->ipv4.sysctl_tcp_base_mss, mss);
+               mss = min(READ_ONCE(net->ipv4.sysctl_tcp_base_mss), mss);
                mss = max(mss, net->ipv4.sysctl_tcp_mtu_probe_floor);
                mss = max(mss, net->ipv4.sysctl_tcp_min_snd_mss);
                icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss);