lkml.org 
[lkml]   [2022]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.10 13/65] tcp: Fix data-races around sysctl_tcp_no_ssthresh_metrics_save.
    Date
    From: Kuniyuki Iwashima <kuniyu@amazon.com>

    commit ab1ba21b523ab496b1a4a8e396333b24b0a18f9a upstream.

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

    Fixes: 65e6d90168f3 ("net-tcp: Disable TCP ssthresh metrics cache by default")
    Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    net/ipv4/tcp_metrics.c | 8 ++++----
    1 file changed, 4 insertions(+), 4 deletions(-)

    --- a/net/ipv4/tcp_metrics.c
    +++ b/net/ipv4/tcp_metrics.c
    @@ -385,7 +385,7 @@ void tcp_update_metrics(struct sock *sk)

    if (tcp_in_initial_slowstart(tp)) {
    /* Slow start still did not finish. */
    - if (!net->ipv4.sysctl_tcp_no_ssthresh_metrics_save &&
    + if (!READ_ONCE(net->ipv4.sysctl_tcp_no_ssthresh_metrics_save) &&
    !tcp_metric_locked(tm, TCP_METRIC_SSTHRESH)) {
    val = tcp_metric_get(tm, TCP_METRIC_SSTHRESH);
    if (val && (tp->snd_cwnd >> 1) > val)
    @@ -401,7 +401,7 @@ void tcp_update_metrics(struct sock *sk)
    } else if (!tcp_in_slow_start(tp) &&
    icsk->icsk_ca_state == TCP_CA_Open) {
    /* Cong. avoidance phase, cwnd is reliable. */
    - if (!net->ipv4.sysctl_tcp_no_ssthresh_metrics_save &&
    + if (!READ_ONCE(net->ipv4.sysctl_tcp_no_ssthresh_metrics_save) &&
    !tcp_metric_locked(tm, TCP_METRIC_SSTHRESH))
    tcp_metric_set(tm, TCP_METRIC_SSTHRESH,
    max(tp->snd_cwnd >> 1, tp->snd_ssthresh));
    @@ -418,7 +418,7 @@ void tcp_update_metrics(struct sock *sk)
    tcp_metric_set(tm, TCP_METRIC_CWND,
    (val + tp->snd_ssthresh) >> 1);
    }
    - if (!net->ipv4.sysctl_tcp_no_ssthresh_metrics_save &&
    + if (!READ_ONCE(net->ipv4.sysctl_tcp_no_ssthresh_metrics_save) &&
    !tcp_metric_locked(tm, TCP_METRIC_SSTHRESH)) {
    val = tcp_metric_get(tm, TCP_METRIC_SSTHRESH);
    if (val && tp->snd_ssthresh > val)
    @@ -463,7 +463,7 @@ void tcp_init_metrics(struct sock *sk)
    if (tcp_metric_locked(tm, TCP_METRIC_CWND))
    tp->snd_cwnd_clamp = tcp_metric_get(tm, TCP_METRIC_CWND);

    - val = net->ipv4.sysctl_tcp_no_ssthresh_metrics_save ?
    + val = READ_ONCE(net->ipv4.sysctl_tcp_no_ssthresh_metrics_save) ?
    0 : tcp_metric_get(tm, TCP_METRIC_SSTHRESH);
    if (val) {
    tp->snd_ssthresh = val;

    \
     
     \ /
      Last update: 2022-08-01 13:53    [W:2.585 / U:0.148 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site