lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230802173535.51811-1-kuniyu@amazon.com>
Date: Wed, 2 Aug 2023 10:35:35 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <edumazet@...gle.com>
CC: <davem@...emloft.net>, <dsahern@...nel.org>, <eric.dumazet@...il.com>,
	<kuba@...nel.org>, <kuniyu@...zon.com>, <netdev@...r.kernel.org>,
	<pabeni@...hat.com>
Subject: Re: [PATCH net 3/6] tcp_metrics: annotate data-races around tm->tcpm_lock

From: Eric Dumazet <edumazet@...gle.com>
Date: Wed,  2 Aug 2023 13:14:57 +0000
> tm->tcpm_lock can be read or written locklessly.
> 
> Add needed READ_ONCE()/WRITE_ONCE() to document this.
> 
> Fixes: 51c5d0c4b169 ("tcp: Maintain dynamic metrics in local cache.")
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>

Reviewed-by: Kuniyuki Iwashima <kuniyu@...zon.com>


> ---
>  net/ipv4/tcp_metrics.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
> index 83861658879638149d2746290a285a4f75fc3117..131fa300496914f78c682182f0db480ceb71b6a0 100644
> --- a/net/ipv4/tcp_metrics.c
> +++ b/net/ipv4/tcp_metrics.c
> @@ -59,7 +59,8 @@ static inline struct net *tm_net(struct tcp_metrics_block *tm)
>  static bool tcp_metric_locked(struct tcp_metrics_block *tm,
>  			      enum tcp_metric_index idx)
>  {
> -	return tm->tcpm_lock & (1 << idx);
> +	/* Paired with WRITE_ONCE() in tcpm_suck_dst() */
> +	return READ_ONCE(tm->tcpm_lock) & (1 << idx);
>  }
>  
>  static u32 tcp_metric_get(struct tcp_metrics_block *tm,
> @@ -110,7 +111,8 @@ static void tcpm_suck_dst(struct tcp_metrics_block *tm,
>  		val |= 1 << TCP_METRIC_CWND;
>  	if (dst_metric_locked(dst, RTAX_REORDERING))
>  		val |= 1 << TCP_METRIC_REORDERING;
> -	tm->tcpm_lock = val;
> +	/* Paired with READ_ONCE() in tcp_metric_locked() */
> +	WRITE_ONCE(tm->tcpm_lock, val);
>  
>  	msval = dst_metric_raw(dst, RTAX_RTT);
>  	tm->tcpm_vals[TCP_METRIC_RTT] = msval * USEC_PER_MSEC;
> -- 
> 2.41.0.640.ga95def55d0-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ