Subject: [PATCH net 0/2] udplookup: Rescan udp hash chains if cross-linked

From: David Laight <[email-masked]>
Date: Mon, 27 Jan 2025 19:40:22 +0000

udp_lib_rehash() can get called at any time and will move a
socket to a different hash2 chain.
This can cause udp[46]_lib_lookup2() (processing incoming UDP) to
fail to find a socket and an ICMP port unreachable be sent.

Prior to ca065d0cf80fa the lookup used 'hlist_nulls' and checked
that the 'end if list' marker was on the correct list.

The cross-linking can definitely happen (see earlier issues with
it looping forever because gcc cached the list head).

I can't see an easy way around adding another two parameters to
udp[46]_lib lookup().
However once udp-lite is removed 'mask' can be obtained from 'net'.
'net' itself could be obtained from 'sk'.

Not addressed here, but the 'reuseport' code doesn't look right to me.

David Laight (2):
  IPv4: Rescan the hash2 list if the hash chains have got cross-linked.
  IPv6: Rescan the hash2 list if the hash chains have got cross-linked.

 net/ipv4/udp.c | 19 +++++++++++++++++--
 net/ipv6/udp.c | 22 +++++++++++++++++++---
 2 files changed, 36 insertions(+), 5 deletions(-)

-- 
2.39.5