Skip to content

udp: Fix bind conflict check bypasses

Juan Agustin Niccolini linux-kselftest lkml netdev 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4udp: Fix bind conflict check stopping at the first reuseport socketnet/ipv4/udp.c+16 -20 replies
2/4udp: Keep the bound device on disconnect unless connect() set itinclude/net/sock.h net/core/sock.c net/ipv4/udp.c +1 more+29 -60 replies
3/4udp: Ignore a connect()-set device in the bind conflict checknet/core/sock.c net/ipv4/udp.c net/ipv6/datagram.c+48 -120 replies
4/4selftests: net: Add UDP bind conflict teststools/testing/selftests/net/.gitignore tools/testing/selftests/net/Makefile tools/testing/selftests/net/udp_bind_conflict.c+230 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH net 0/4] udp: Fix bind conflict check bypasses

An unprivileged user can get a UDP socket bound to an address and port that another user's socket holds, in a state bind() would have refused, and receive that socket's datagrams. This series fixes three bugs that allow that and adds a selftest.

These are sibling vulnerabilities of the TCP one fixed by my commit f675070191f2 ("tcp: Fix the SO_REUSEPORT bind cache admitting a conflicting socket"). The one in patch 1 has the same kind of cause: a SO_REUSEPORT shortcut that lets one matching socket stand for every socket on the port. The other two predate git. All were discovered during an LLM-based audit.

Juan Agustin Niccolini (4):
udp: Fix bind conflict check stopping at the first reuseport socket
udp: Keep the bound device on disconnect unless connect() set it
udp: Ignore a connect()-set device in the bind conflict check
selftests: net: Add UDP bind conflict tests

 include/net/sock.h                            |   4 +
 net/core/sock.c                               |   3 +
 net/ipv4/udp.c                                |  69 +++++-
 net/ipv6/datagram.c                           |  25 +-
 tools/testing/selftests/net/.gitignore        |   1 +
 tools/testing/selftests/net/Makefile          |   1 +
 .../testing/selftests/net/udp_bind_conflict.c | 228 ++++++++++++++++++
 7 files changed, 317 insertions(+), 14 deletions(-)

base-commit: 19a227903e65c7a9c179156485660a4e017575fe

Signature · 1 line
2.43.0