diff options
| author | Dominik Maier <dmnk@google.com> | 2026-11-19 20:21:42 +0100 |
|---|---|---|
| committer | Paolo Abeni <pabeni@redhat.com> | 2026-11-26 15:30:00 +0100 |
| commit | d77700039d09479f81f0bc8b73002af8ec95d3f7 (patch) | |
| tree | 78307a41935e1745ab8972ef7ba6beeb31bd66e9 /tools/perf/scripts/python/bin | |
| parent | ae8e5ef9fa9eeaf4ee0a9a9bde0fc63023d9b154 (diff) | |
udp: only quit inuse scan early on identical SO_REUSEPORT sockets
Commit df560056d960 ("udp: inuse checks can quit early for reuseport")
optimized udp_lib_lport_inuse() and udp_lib_lport_inuse2() to return 0
immediately upon encountering the first same-UID SO_REUSEPORT socket
that matches under wildcard conflict rules.
However, a socket that matches under wildcard rules (or shares only a
relaxed subset of bind attributes) does not guarantee that the remaining
sockets in hslot->head or hslot2->head are conflict-free for the new
socket. Because IPv4 UDP sockets prepend to the head of the hash chain,
an unprivileged local user can bind a non-conflicting SO_REUSEPORT
socket (e.g., 127.0.0.2:PORT) ahead of another user's exclusive
127.0.0.1:PORT UDP listener, then bind 0.0.0.0:PORT (returning early on
127.0.0.2:PORT without reaching the exclusive listener), and finally
bind 127.0.0.1:PORT at the head of hslot2->head to intercept cross-UID
UDP datagrams.
Only take the O(1) early exit when sk and sk2 share the exact same
conflict domain (sk_family, ipv6_only_sock(), sk_bound_dev_if,
sk_reuse, and exact receive address via inet_rcv_saddr_equal() with
match_wildcard=false), and continue scanning the hash chain otherwise.
This preserves O(1) bind scaling for identical SO_REUSEPORT groups while
preventing cross-UID conflict checks from being skipped.
This issue was discovered with an AI-assisted code review tool (ARTIST)
and reproduced in QEMU/KVM on an unmodified v7.4-rc3 kernel without
kernel modifications or error injection; a standalone reproducer is
available on request. This revised exact-match fastpath patch was
compile-tested with -Werror and checked with checkpatch.pl --strict; it
has not yet been runtime-tested against the reproducer or kernel
selftests.
Fixes: df560056d960 ("udp: inuse checks can quit early for reuseport")
Cc: stable@vger.kernel.org
Signed-off-by: Dominik Maier <dmnk@google.com>
Link: https://patch.msgid.link/20261119192142.2637952-1-dmnk@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python/bin')
0 files changed, 0 insertions, 0 deletions
