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]
Message-ID: <febf62f6-7439-4628-ad47-041ebbb86ede@linux.alibaba.com>
Date: Tue, 31 Dec 2024 15:55:39 +0800
From: Philo Lu <lulie@...ux.alibaba.com>
To: Paolo Abeni <pabeni@...hat.com>, Eric Dumazet <edumazet@...gle.com>
Cc: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
 David Ahern <dsahern@...nel.org>, Jakub Kicinski <kuba@...nel.org>,
 Simon Horman <horms@...nel.org>, Fred Chen <fred.cc@...baba-inc.com>,
 Cambda Zhu <cambda@...ux.alibaba.com>, Willem de Bruijn
 <willemb@...gle.com>, Stefano Brivio <sbrivio@...hat.com>
Subject: Re: [PATCH net] udp: fix l4 hash after reconnect

Hi Paolo, hi Eric,

On 2024/12/10 16:32, Paolo Abeni wrote:
> On 12/7/24 03:34, Philo Lu wrote:
>> On 2024/12/7 00:23, Paolo Abeni wrote:
>>> On 12/6/24 17:01, Eric Dumazet wrote:
>>>> BTW, it seems that udp_lib_rehash() does the udp_rehash4()
>>>> only if the hash2 has changed.
>>>
>>> Oh, you are right, that requires a separate fix.
>>>
>>> @Philo: could you please have a look at that? basically you need to
>>> check separately for hash2 and hash4 changes.
>>
>> This is a good question. IIUC, the only affected case is when trying to
>> re-connect another remote address with the same local address
> 
> AFAICS, there is also another case: when re-connection using a different
> local addresses with the same l2 hash...
> 
>> (i.e.,
>> hash2 unchanged). And this will be handled by udp_lib_hash4(). So in
>> udp_lib_rehash() I put rehash4() inside hash2 checking, which means a
>> passive rehash4 following rehash2.
> 
> ... but even the latter case should be covered from the above.
> 
>> So I think it's more about the convention for rehash. We can choose the
>> better one.
> 
> IIRC a related question raised during code review for the udp L4 hash
> patches. Perhaps refactoring the code slightly to let udp_rehash()
> really doing the re-hashing and udp_hash really doing only the hashing
> could be worth.
> 

I'm trying to unify rehash() for both hash2 and hash4 in 
__ip4_datagram_connect, when I noticed the inet_rcv_saddr checking 
before calling rehash():

```
if (!inet->inet_rcv_saddr) {
	inet->inet_rcv_saddr = fl4->saddr;
	if (sk->sk_prot->rehash)
		sk->sk_prot->rehash(sk);
}
```
This means inet_rcv_saddr is reset at most once no matter how many times 
connect() is called. I'm not sure if this is by-design for some reason? 
Or can I remove this checking? like:

--- a/net/ipv4/datagram.c
+++ b/net/ipv4/datagram.c
@@ -67,11 +67,9 @@ int __ip4_datagram_connect(struct sock *sk, struct 
sockaddr *uaddr, int addr_len
         inet->inet_dport = usin->sin_port;
         if (!inet->inet_saddr)
                 inet->inet_saddr = fl4->saddr;
-       if (!inet->inet_rcv_saddr) {
-               inet->inet_rcv_saddr = fl4->saddr;
-               if (sk->sk_prot->rehash)
-                       sk->sk_prot->rehash(sk);
-       }
+       inet->inet_rcv_saddr = fl4->saddr;
+       if (sk->sk_prot->rehash)
+               sk->sk_prot->rehash(sk);
         reuseport_has_conns_set(sk);
         sk->sk_state = TCP_ESTABLISHED;
         sk_set_txhash(sk);


Thanks.
-- 
Philo


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ