mbox series

[RFC,net,0/2] Fix race between datagram socket address change and rehash

Message ID 20241114215414.3357873-1-sbrivio@redhat.com (mailing list archive)
Headers show
Series Fix race between datagram socket address change and rehash | expand

Message

Stefano Brivio Nov. 14, 2024, 9:54 p.m. UTC
Patch 2/2 fixes a race condition in the lookup of datagram sockets
between address change (triggered by connect()) and rehashing.

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

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/sock.h  |  2 +-
 include/net/udp.h   |  3 +-
 net/core/sock.c     | 13 ++++++--
 net/ipv4/datagram.c |  7 +++--
 net/ipv4/udp.c      | 76 +++++++++++++++++++++++++++++++--------------
 net/ipv4/udp_impl.h |  2 +-
 net/ipv4/udplite.c  |  2 +-
 net/ipv6/datagram.c | 30 +++++++++++++-----
 net/ipv6/udp.c      | 17 ++++++----
 net/ipv6/udp_impl.h |  2 +-
 net/ipv6/udplite.c  |  2 +-
 11 files changed, 108 insertions(+), 48 deletions(-)

Comments

David Gibson Nov. 15, 2024, 3:01 a.m. UTC | #1
On Thu, Nov 14, 2024 at 10:54:12PM +0100, Stefano Brivio wrote:
> Patch 2/2 fixes a race condition in the lookup of datagram sockets
> between address change (triggered by connect()) and rehashing.
> 
> Patch 1/2 is a small optimisation to simplify 2/2.

These both LGTM, but I don't know the code in question well enough to
claim to have done a full review.