netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] Fix race between datagram socket address change and rehash
@ 2024-12-04 22:12 Stefano Brivio
  2024-12-04 22:12 ` [PATCH net-next 1/2] datagram: Rehash sockets only if local address changed for their family Stefano Brivio
  2024-12-04 22:12 ` [PATCH net-next 2/2] datagram, udp: Set local address and rehash socket atomically against lookup Stefano Brivio
  0 siblings, 2 replies; 17+ messages in thread
From: Stefano Brivio @ 2024-12-04 22:12 UTC (permalink / raw)
  To: Willem de Bruijn
  Cc: Eric Dumazet, netdev, Kuniyuki Iwashima, Mike Manning,
	David Gibson, Paul Holzinger, Philo Lu, Cambda Zhu, Fred Chen,
	Yubing Qiu

Patch 2/2 fixes a race condition in the lookup of datagram sockets
between address change (triggered by connect()) and rehashing. The
issue occurs regardless of the type of hash, that is, it happens with
updates to the secondary hash as well as to the newly introduced
four-tuple hash.

Patch 1/2 is a small optimisation to simplify 2/2.

This is essentially a rebase onto current net-next of the RFC I
originally posted against 'net', before the 6.13 merge window,
at:

  https://lore.kernel.org/netdev/20241114215414.3357873-1-sbrivio@redhat.com/

with a couple of minor changes described in the single patch messages.

The rebase is not trivial as four-tuple hashes were introduced
meanwhile, with commits 1b29a730ef8b ("ipv6/udp: Add 4-tuple hash for
connected socket"), 78c91ae2c6de ("ipv4/udp: Add 4-tuple hash for
connected socket"), and their dependencies, but the race condition,
described in detail in the commit message for 1/2, is exactly the same
as before.

Stefano Brivio (2):
  datagram: Rehash sockets only if local address changed for their
    family
  datagram, udp: Set local address and rehash socket atomically against
    lookup

 include/net/inet_hashtables.h | 13 ++++++
 include/net/sock.h            |  2 +-
 include/net/udp.h             |  3 +-
 net/core/sock.c               | 12 ++++-
 net/ipv4/datagram.c           |  7 +--
 net/ipv4/inet_hashtables.c    | 13 ------
 net/ipv4/udp.c                | 84 +++++++++++++++++++++++------------
 net/ipv4/udp_impl.h           |  2 +-
 net/ipv4/udplite.c            |  2 +-
 net/ipv6/datagram.c           | 30 +++++++++----
 net/ipv6/udp.c                | 31 +++++++------
 net/ipv6/udp_impl.h           |  2 +-
 net/ipv6/udplite.c            |  2 +-
 13 files changed, 130 insertions(+), 73 deletions(-)

-- 
2.40.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2024-12-18 16:21 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-04 22:12 [PATCH net-next 0/2] Fix race between datagram socket address change and rehash Stefano Brivio
2024-12-04 22:12 ` [PATCH net-next 1/2] datagram: Rehash sockets only if local address changed for their family Stefano Brivio
2024-12-04 22:12 ` [PATCH net-next 2/2] datagram, udp: Set local address and rehash socket atomically against lookup Stefano Brivio
2024-12-05  9:30   ` Paolo Abeni
2024-12-05 15:58     ` Stefano Brivio
2024-12-05 16:53       ` Paolo Abeni
2024-12-06 10:50         ` Stefano Brivio
2024-12-06 12:36           ` Paolo Abeni
2024-12-06 13:35             ` Stefano Brivio
2024-12-06 15:10               ` Paolo Abeni
2024-12-18 16:21               ` Stefano Brivio
2024-12-05 16:35   ` Eric Dumazet
2024-12-05 22:32     ` David Gibson
2024-12-05 22:52       ` Eric Dumazet
2024-12-06  2:16         ` David Gibson
2024-12-06  9:04           ` Eric Dumazet
2024-12-09  2:20             ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).