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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 27 Nov 2023 12:41:57 +0100
From: Paolo Abeni <pabeni@...hat.com>
To: Dmitry Safonov <dima@...sta.com>, David Ahern <dsahern@...nel.org>, Eric
 Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, "David S.
 Miller" <davem@...emloft.net>
Cc: linux-kernel@...r.kernel.org, Dmitry Safonov <0x7f454c46@...il.com>, 
 Francesco Ruggeri <fruggeri05@...il.com>, Salam Noureddine
 <noureddine@...sta.com>, Simon Horman <horms@...nel.org>, 
 netdev@...r.kernel.org
Subject: Re: [PATCH v2 6/7] net/tcp: Add sne_lock to access SNEs

On Fri, 2023-11-24 at 00:27 +0000, Dmitry Safonov wrote:
> RFC 5925 (6.2):
> > TCP-AO emulates a 64-bit sequence number space by inferring when to
> > increment the high-order 32-bit portion (the SNE) based on
> > transitions in the low-order portion (the TCP sequence number).
> 
> snd_sne and rcv_sne are the upper 4 bytes of extended SEQ number.
> Unfortunately, reading two 4-bytes pointers can't be performed
> atomically (without synchronization).
> 
> Let's keep it KISS and add an rwlock - that shouldn't create much
> contention as SNE are updated every 4Gb of traffic and the atomic region
> is quite small.
> 
> Fixes: 64382c71a557 ("net/tcp: Add TCP-AO SNE support")
> Signed-off-by: Dmitry Safonov <dima@...sta.com>
> ---
>  include/net/tcp_ao.h |  2 +-
>  net/ipv4/tcp_ao.c    | 34 +++++++++++++++++++++-------------
>  net/ipv4/tcp_input.c | 16 ++++++++++++++--
>  3 files changed, 36 insertions(+), 16 deletions(-)
> 
> diff --git a/include/net/tcp_ao.h b/include/net/tcp_ao.h
> index 647781080613..beea3e6b39e2 100644
> --- a/include/net/tcp_ao.h
> +++ b/include/net/tcp_ao.h
> @@ -123,6 +123,7 @@ struct tcp_ao_info {
>  	 */
>  	u32			snd_sne;
>  	u32			rcv_sne;
> +	rwlock_t		sne_lock;

RW lock are problematic in the networking code, see commit
dbca1596bbb08318f5e3b3b99f8ca0a0d3830a65.

I think you can use a plain spinlock here, as both read and write
appears to be in the fastpath (?!?)

> @@ -781,8 +780,10 @@ int tcp_ao_prepare_reset(const struct sock *sk, struct sk_buff *skb,
>  		*traffic_key = snd_other_key(*key);
>  		rnext_key = READ_ONCE(ao_info->rnext_key);
>  		*keyid = rnext_key->rcvid;
> -		*sne = tcp_ao_compute_sne(READ_ONCE(ao_info->snd_sne),
> -					  snd_basis, seq);
> +		read_lock_irqsave(&ao_info->sne_lock, flags);
> +		*sne = tcp_ao_compute_sne(ao_info->snd_sne,
> +					  READ_ONCE(*snd_basis), seq);
> +		read_unlock_irqrestore(&ao_info->sne_lock, flags);

Why are you using the irqsave variant? bh should suffice.

Cheers,

Paolo


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ