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: <20241115195521.63675-1-kuniyu@amazon.com>
Date: Fri, 15 Nov 2024 11:55:21 -0800
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <sbrivio@...hat.com>
CC: <david@...son.dropbear.id.au>, <edumazet@...gle.com>,
	<mmanning@...tta.att-mail.com>, <netdev@...r.kernel.org>,
	<pholzing@...hat.com>, <santiago@...hat.com>,
	<willemdebruijn.kernel@...il.com>, <kuniyu@...zon.com>
Subject: Re: [PATCH RFC net 2/2] datagram, udp: Set local address and rehash socket atomically against lookup

From: Stefano Brivio <sbrivio@...hat.com>
Date: Thu, 14 Nov 2024 22:54:14 +0100
> diff --git a/net/core/sock.c b/net/core/sock.c
> index da50df485090..fcd2e2b89876 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -643,8 +643,17 @@ static int sock_bindtoindex_locked(struct sock *sk, int ifindex)
>  	/* Paired with all READ_ONCE() done locklessly. */
>  	WRITE_ONCE(sk->sk_bound_dev_if, ifindex);
>  
> -	if (sk->sk_prot->rehash)
> -		sk->sk_prot->rehash(sk);
> +	/* Force rehash if protocol needs it */
> +	if (sk->sk_prot->set_rcv_saddr) {
> +		if (IS_ENABLED(CONFIG_IPV6) && sk->sk_family == AF_INET6) {
> +			sk->sk_prot->set_rcv_saddr(sk, &sk->sk_v6_rcv_saddr);

sk_v6_rcv_saddr is not defined without CONFIG_IPV6 so I think the
compiler will complain ?  see net/ipv4/inet_connection_sock.c


> +		} else if (sk->sk_family == AF_INET) {
> +			struct inet_sock *inet = inet_sk(sk);
> +
> +			sk->sk_prot->set_rcv_saddr(sk, &inet->inet_rcv_saddr);

simply use &sk->sk_rcv_saddr.


> +		}
> +	}
> +
>  	sk_dst_reset(sk);
>  
>  	ret = 0;
[...]
> @@ -2034,20 +2052,32 @@ void udp_lib_rehash(struct sock *sk, u16 newhash)
>  				nhslot2->count++;
>  				spin_unlock(&nhslot2->lock);
>  			}
> -
> -			spin_unlock_bh(&hslot->lock);
>  		}
>  	}
> +
> +	if (sk->sk_family == AF_INET)
> +		sk->sk_rcv_saddr = *(__be32 *)addr;
> +	else if (sk->sk_family == AF_INET6)
> +		sk->sk_v6_rcv_saddr = *(struct in6_addr *)addr;

inet_update_saddr() can be reused ?  at least we should
use sk_rcv_saddr_set().

Same for other places.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ