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]
Date: Wed, 2 Aug 2023 10:42:45 -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 5/6] tcp_metrics: annotate data-races around tm->tcpm_net

From: Eric Dumazet <edumazet@...gle.com>
Date: Wed,  2 Aug 2023 13:14:59 +0000
> tm->tcpm_net can be read or written locklessly.
> 
> Instead of changing write_pnet() and read_pnet() and potentially
> hurt performance, add the needed READ_ONCE()/WRITE_ONCE()
> in tm_net() and tcpm_new().
> 
> Fixes: 849e8a0ca8d5 ("tcp_metrics: Add a field tcpm_net and verify it matches on lookup")
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>

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


> ---
>  net/ipv4/tcp_metrics.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
> index fd4ab7a51cef210005146dfbc3235a2db717a44f..4fd274836a48f73d0b1206adfa14c17c3b28bc30 100644
> --- a/net/ipv4/tcp_metrics.c
> +++ b/net/ipv4/tcp_metrics.c
> @@ -40,7 +40,7 @@ struct tcp_fastopen_metrics {
>  
>  struct tcp_metrics_block {
>  	struct tcp_metrics_block __rcu	*tcpm_next;
> -	possible_net_t			tcpm_net;
> +	struct net			*tcpm_net;
>  	struct inetpeer_addr		tcpm_saddr;
>  	struct inetpeer_addr		tcpm_daddr;
>  	unsigned long			tcpm_stamp;
> @@ -51,9 +51,10 @@ struct tcp_metrics_block {
>  	struct rcu_head			rcu_head;
>  };
>  
> -static inline struct net *tm_net(struct tcp_metrics_block *tm)
> +static inline struct net *tm_net(const struct tcp_metrics_block *tm)
>  {
> -	return read_pnet(&tm->tcpm_net);
> +	/* Paired with the WRITE_ONCE() in tcpm_new() */
> +	return READ_ONCE(tm->tcpm_net);
>  }
>  
>  static bool tcp_metric_locked(struct tcp_metrics_block *tm,
> @@ -197,7 +198,9 @@ static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst,
>  		if (!tm)
>  			goto out_unlock;
>  	}
> -	write_pnet(&tm->tcpm_net, net);
> +	/* Paired with the READ_ONCE() in tm_net() */
> +	WRITE_ONCE(tm->tcpm_net, net);
> +
>  	tm->tcpm_saddr = *saddr;
>  	tm->tcpm_daddr = *daddr;
>  
> -- 
> 2.41.0.640.ga95def55d0-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ