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

From: willemb

Date: Sun Nov 29 2026 - 09:39:31 EST


Juan Agustin Niccolini wrote:
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


No need to fix the pre-existing issues (connect() address narrowing,
L2TP/IPv6, VRF conflict checks, or the residual ABA window), indeed.

But please respin v2 onto net for the following:

1. Drop Patch 1 and rebase Patches 2-4 onto net: commit d77700039d09
("udp: only quit inuse scan early on identical SO_REUSEPORT
sockets") already landed in net with the same fix. Please keep the
reuseport_* selftests in Patch 4 (with an updated commit message).
2. Patch 2: fix the new unlocked sk->sk_userlocks RMW race in
__udp_disconnect() for ping/raw/L2TP that Sashiko flagged (which
is a regression since __udp_disconnect() previously never wrote
sk_userlocks).
3. Patch 2: address Sashiko's note on the VRF disconnect behavior
change (at minimum move it from the "---" notes into the commit
message, or preserve/restore the pre-connect ifindex).
4. Patch 3 (while rebasing): drop the redundant udp_bound_dev_if()
calls.

-- details

- For (3), see also the parallel patch saving the pre-connect ifindex:
https://lore.kernel.org/r/20261124180603.72523-1-dmnk@xxxxxxxxxx
- For (4), sk is being bound under lock_sock(sk), so read
sk->sk_bound_dev_if directly, and load udp_bound_dev_if(sk2) once
per candidate and pass it to udp_sk_reuseport_match().

--

pw-bot: cr