Article View: linux.kernel.netdev
Article #19084Re: [PATCH net 1/2] udp: fix reuseport rescore fallback
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 09:57
Date: Thu, 19 Nov 2026 09:57
118 lines
12194 bytes
12194 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The patch adds a rescore branch to udp4_lib_lookup2()
(net/ipv4/udp.c:478-484) and udp6_lib_lookup2()…
--
udp: fix reuseport rescore fallback
This changes the UDP lookup rescore path in udp4_lib_lookup2() and
udp6_lib_lookup2(). When the reuseport group has connected sockets, the
socket selected by reuseport is now kept only if its rescored value is
strictly higher than the current badness. Otherwise the lookup goes back to
the socket that set the current score.
Link: https://bugtracker.nebusec.ai/f/net/ipv6/udp.c||udp6_lib_lookup2||socket-hijack||m7q
> diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> index 2e5562f353f85..23a8c951559c7 100644
> --- a/net/ipv4/udp.c
> +++ b/net/ipv4/udp.c
> @@ -475,12 +475,17 @@ static struct sock *udp4_lib_lookup2(const struct net *net,
> rescore:
> score = compute_score(need_rescore ? result : sk, net, saddr,
> sport, daddr, hnum, dif, sdif);
> + if (need_rescore) {
> + if (score > badness)
> + badness = score;
> + else
> + result = sk;
> + continue;
> + }
[Severity: High]
Does this throw away the reuseport selection whenever the selected socket
only ties with sk, and not just when it fails to match the packet?
All unconnected members of a reuseport group get the same base score from
compute_score(). udp_reuseport_add_sock() requires the same family,
ipv6_only, bound device and rcv_saddr, and unconnected sockets have no
daddr or dport. The only thing that can differ is the incoming CPU bonus:
net/ipv4/udp.c:compute_score() {
...
if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
score++;
return score;
}
The hash path only ever returns a non-established socket:
net/core/sock_reuseport.c:reuseport_select_sock_by_hash() {
...
if (sk->sk_state != TCP_ESTABLISHED) {
if (!READ_ONCE(reuse->incoming_cpu))
return sk;
...
}
Once the group has at least one connected socket, reuseport_has_conns() is
true and the lookup goes like this:
udp4_lib_lookup2()
first unconnected member sk scores > badness
inet_lookup_reuseport() picks unconnected socket X
goto rescore
compute_score(X) == badness
result = sk
If so, all traffic for the unconnected members would go to the first group
member in the hslot2 chain. Wouldn't SK_REUSEPORT BPF and
SO_ATTACH_REUSEPORT_CBPF steering to unconnected members also be ignored
without any warning?
That looks like the behaviour that efc6b6f6c311, the Fixes: target of this
patch, removed. Its commit message says:
"unconnected sockets have the same score, hence only does the first
unconnected socket in udp_hslot always receive all packets ... the
result of reuseport_select_sock() should be used for load balancing."
The old code kept X on a tie. The problem described in this commit message
is the case where X does not match the packet at all: compute_score()
returns -1, for example when BPF selects a socket connected to a different
peer.
Could the fallback to sk happen only when score < 0 (or at most when
score < badness)? That would fix that case and keep load balancing.
The same logic is added to udp6_lib_lookup2(), where badness starts at -1
and the rescored unconnected socket also ties with sk.
The commit message says "Keep the selected socket only when its score is
higher". It does not mention the effect on load balancing or BPF steering.
Also, the selftest added later in this series ("selftests: net: cover
connected UDP reuseport rescore") only checks a CBPF program that selects
the connected socket. It never selects an unconnected peer, so it would not
catch this.
> +
> if (score > badness) {
> badness = score;
>
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794759652.git.zihanx%40nebusec.ai
Technical Details
Message-ID:
<179508226205.3136.710014559426997072@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366922-linux-kernel-netdev=dewy.ruReferences:
<8c46325c4a433f02fdc7241c0c3884126cb502af.1794759652.git.zihanx@nebusec.ai>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366922-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 1/2] udp: fix reuseport rescore fallback Date: Thu, 19 Nov 2026 09:57:42 +0000 Organization: Usenet Network Message-ID: <179508226205.3136.710014559426997072@kernel.org> References: <8c46325c4a433f02fdc7241c0c3884126cb502af.1794759652.git.zihanx@nebusec.ai> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2842998"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:nHvnqtAVevO9KTMzXdqkTxSOUug= sha256:KEbdeoBvewv+bAC9yPm5Y2Df38lBN9CjAeOIKObgY9U= sha1:dTZ2Fzg00G96WQxfSAtCzDJKocY= sha256:Qr7QxBYA9xxwleixLG4//8QdtibR4BR7RJpFh8ODxcY= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 949E5115597; Thu, 19 Nov 2026 12:58:09 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id osqsyQGQpAp6; Thu, 19 Nov 2026 12:58:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-366922-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 102BC1155A6; Thu, 19 Nov 2026 12:57:52 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id A39A0A40FF; Thu, 19 Nov 2026 09:57:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795082269; b=oDLBDDRSe5OKA+PiTdKybYOge3MLCca5B4e7O+3Oyy/sHxX1+cucBh6MjxouEbJQ1Hfa Br6wcyv5JeNrpnwyh+f9dHotqpA21TYu2lIghS0na89ociXYQx2P+K4T2zQz0yC0x47el 01yc83Z0Ryyyww48DjNmQSr/GokhVGs97RQ/RcPnDNu7V+8eSp15pOOxiL8GNzX4KyNWm hyWxhnEHa1zYSXfsiv5JkSHQTEGHUISz0ot5UqJeDr0CtqlgvrDVaaTV9zUIXtyIh3F4o cxuZoLfaaCeOYPxznzgC2pYGHbyKPOsKhUgrtUaCcTOL+cQbGdMZmnQV4/MPPv51nHQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795082269; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=y625Etk8u3ex3Tjo/KtPtgnQQJTTr3iIXOZEFCoS/aI=; b=X1RQWNbH+iVc1GeGO5aozAFZLeUXoVND3OzTGqrtAuBpz9ShOmw7cvm9yKjr8eL15nyc tMTcQ2/824c1lLdtNMJo/k18aqMaAcy3vyBj7D+tnqBJ8XSqPszLDv1xwrPKf9xSQ5eMq 7dHqShcceqbRtkPz9y96bSlWVT+Vr05SHcHsTD7sxPdYe6kZAyOgcPKjz04qH7ph9w/PV Ormj0s1MdCeulq59Bp43IlnSB6FQs8XH5jPQBsg2Ty02eG2B6Ebk8/3jSPWTQKcoCPLb3 ksIWa9Ot7pkCOLzpDK/2CsBoVGP4XVO/gq4NmwuOG4lMLp530O2FSKAS1Yloxvawejw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="ibQzUq/W"; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 612F460A2606; Thu, 19 Nov 2026 09:57:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ibQzUq/W X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795082263; b=Z4Er0hX2TS3URaEcOuAfgOCyJkyPzh3E1/LA4Hhn4F/yxJBgjhm2wfgi0M3+8NXlfrwY 6fnhJ2b6kcX+niix2UDhjuxlm0x18dbBvfkNsoZ0JUwpvNoGuf9Y+WrHcMRSvtioOohzb JoItI5XhC5jeHjeN86vMydYVZzbMROCYbr9ZF7Y+79mpY5e2qfdgdY4WO8ppYSoov8yue OezzJVf/n5rtF7/4019M8aLiH9PCS84csYXVZrvBvVT5pAl5/EKR1b7ulerBS6oq07gk2 cBIxVQmrZ4vquIY0gdzKtUsXsoXkYyqmn8EB5TJt5+0aDvVyjatYxtrW4rbnfBGzrwQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795082263; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=y625Etk8u3ex3Tjo/KtPtgnQQJTTr3iIXOZEFCoS/aI=; b=PALSRU8LemJffuMbGnk37mn1rUd5RICviz5K57HkKyS4mjVY+cB0cFiTWLYNt9m46FBZ uPOwk+6VmAJ2FDNQHj3yq7RGwNu0vwuw2A9dcsUO8b7WxeXy5YRZbtsNstKRnSM5CA5LM JRdFJUbfeXFn7AfTNLX+lUmgRXveeeoJoCSXAf+LzrSiXCAqRI31p6zIOnjxRsn+E0fP7 sVSJ0v09O9Lcp+wv+XJpJyabWqb/t7WE+KV/5QKPqOqGkI5XjyFei73czT4oJ818CdfWM 7OMZzMpQOSNTViQVGb3Q2m4FUffMar4RD1UnNmuWvkyoKjRIGaCBED9fQnBfnW4YJ2w== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="ibQzUq/W"; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80A75606A334; Thu, 19 Nov 2026 09:57:43 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 771AA1F000C4; Thu, 19 Nov 2026 09:57:42 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795082263; bh=y625Etk8u3ex3Tjo/KtPtgnQQJTTr3iIXOZEFCoS/aI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=ibQzUq/WD1r0LCCNo4i7pLHQGP5FKraIKKbL8BLCEx20NkLSPeWkX04Zg6y1k11TX ecq5T6YUSu5D3nbL73Vr2NxFII6EXoz81xW1BXPq4UryKceAcQKsJYe9+S+ISwJlk9 YxKmPVYIYFUCta1I3TuyYWkG+T/TAwIh+7CkcnwRhlsg+DHmLSgri0PV3n+kcyB70n vTXjCzReqxFMLltvD2kUKEiEes8TnJSbFdNAYJvWVxcuIhs5LFStxKZ2RHztxv03ty NRUmuGvO9ARdEn0YViyLmxb50k9bjhwl4g+86sNEGygSk5zDQU1IqIalIn0MD9rNIV Ymw0FesoPvgig== X-Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, willemdebruijn.kernel@gmail.com, davem@davemloft.net, edumazet@kernel.org, pabeni@redhat.com, horms@kernel.org, benh@amazon.com, kuniyu@google.com, shuah@kernel.org, vega@nebusec.ai, kuba@kernel.org X-In-Reply-To: <8c46325c4a433f02fdc7241c0c3884126cb502af.1794759652.git.zihanx@nebusec.ai> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list