Article View: linux.kernel.netdev
Article #15788Re: [PATCH net 2/2] net: core: take the reuseport migration reference with acquire ordering
From: netdev-bot+sashiko
Date: Fri, 13 Nov 2026 13:05
Date: Fri, 13 Nov 2026 13:05
128 lines
13048 bytes
13048 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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).
- [Medium] The commit message says the reuseport_migrate_sock() refcount
change prevents a listener that is concurrently removed from the…
- [Low] The comment in inet_reqsk_clone()
(net/ipv4/inet_connection_sock.c:925) says its sock_put(sk) on the…
--
net: core: take the reuseport migration reference with acquire ordering
This commit changes reuseport_migrate_sock() to take the reference on the
selected listener with refcount_inc_not_zero_acquire() instead of
refcount_inc_not_zero(). The stated goal is to stop callers from observing
a listener in a half-torn-down state when it is removed from the reuseport
group at the same time. The patch carries Fixes: and Cc: stable tags.
> diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
> index b9e5648fa4c51..56230aa55a3e2 100644
> --- a/net/core/sock_reuseport.c
> +++ b/net/core/sock_reuseport.c
> @@ -667,7 +667,8 @@ struct sock *reuseport_migrate_sock(struct sock *sk,
> if (!nsk)
> nsk = reuseport_select_sock_by_hash(reuse, hash, socks);
>
> - if (IS_ERR_OR_NULL(nsk) || unlikely(!refcount_inc_not_zero(&nsk->sk_refcnt))) {
> + if (IS_ERR_OR_NULL(nsk) ||
> + unlikely(!refcount_inc_not_zero_acquire(&nsk->sk_refcnt))) {
[Severity: Medium]
What does the acquire ordering on this increment order against? The commit
message says:
A listener removed from the reuseport group concurrently with that
lookup must not be observed in a half-torn-down state after the
reference was successfully taken.
reuseport_migrate_sock() picks nsk from reuse->socks[] while holding
rcu_read_lock(). Every hashed listener gets SOCK_RCU_FREE in
__inet_hash():
net/ipv4/inet_hashtables.c:__inet_hash() {
...
sock_set_flag(sk, SOCK_RCU_FREE);
...
}
So the listener's memory cannot be freed or reused for another socket
inside this RCU section. Also, nothing after the increment re-validates
nsk. There is no sk_state or sk_reuseport_cb re-check before nsk is
returned.
The contract for the helper in include/linux/refcount.h limits it to that
reuse case:
refcount_{add|inc}_not_zero_acquire() and refcount_set_release() provide
acquire and release ordering for cases when the memory occupied by the
object might be reused to store another object. This is important for the
cases where secondary validation is required to detect such reuse, e.g.
SLAB_TYPESAFE_BY_RCU. The secondary validation checks have to happen after
the refcount is taken, hence acquire order is necessary.
Neither condition holds here. Commit 5b5d8f351dd9, cited as precedent, only
changed sites where the socket is validated again after the reference is
taken. __inet_lookup_established() re-runs inet_match() and checks the
unhashed state, and inet_twsk_purge() re-checks check_net(). Its
bpf_sk_assign() change had a separate justification: a BTF socket pointer
obtained without a reference.
A listener that is being closed is torn down while the closer still holds
its own reference. That teardown is not published through a release on
sk_refcnt. So even with the acquire, can't a caller still see the closing
listener?
Callers already handle that state with an explicit check, for example in
inet_csk_reqsk_queue_add():
spin_lock(&queue->rskq_lock);
if (unlikely(sk->sk_state != TCP_LISTEN)) {
inet_child_forget(sk, req, child);
The same pattern also exists elsewhere and is left alone. inet_lookup(),
inet6_lookup(), and nf_tproxy_get_sock_v4()/nf_tproxy_get_sock_v6() all
take a reference on an unreferenced listener with plain
refcount_inc_not_zero() and then use it. Those sites look correct for the
same RCU-stable reason, which suggests this one is correct as well without
the change.
Given that, are the Fixes: fb041bb7c0a9 and Cc: stable tags justified?
Could the commit message name a concrete load that can see stale data here,
or include a reproducer? As written, the patch adds a barrier on weakly
ordered architectures but does not change what callers can observe.
> nsk = NULL;
> goto failure;
> }
[Severity: Low]
This isn't a bug, but the comment on the matching release in
inet_reqsk_clone() still names the old primitive:
net/ipv4/inet_connection_sock.c:inet_reqsk_clone() {
...
if (!nreq) {
__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMIGRATEREQFAILURE);
/* paired with refcount_inc_not_zero() in reuseport_migrate_sock() */
sock_put(sk);
return NULL;
}
...
}
Should this comment be updated if the switch to
refcount_inc_not_zero_acquire() is kept?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/tencent_28A2BD1631FE531992E91753BA6419FFC506%40qq.com
Technical Details
Message-ID:
<179457511118.2199510.8206170775718086732@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362664-linux-kernel-netdev=dewy.ruReferences:
<tencent_AE3D481F5F51E98E657317C2F664C4FA4F08@qq.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362664-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 2/2] net: core: take the reuseport migration reference with acquire ordering Date: Fri, 13 Nov 2026 13:05:11 +0000 Organization: Usenet Network Message-ID: <179457511118.2199510.8206170775718086732@kernel.org> References: <tencent_AE3D481F5F51E98E657317C2F664C4FA4F08@qq.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1369329"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:lngmC4izAZirJ/KXODeoLdDUpI4= sha256:u1AgTBvQs+lRb8GvhPFk55IOCuWFlHn5AWIdV5nqSR4= sha1:wAcUSUu/0UW4/gb036kdR2kXaQc= sha256:AfTVtPp5/t5FS1At75uAmwdW8u8k5O9CA2HiNZpCcGI= 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 D48B9114578; Fri, 13 Nov 2026 18:06:27 +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 pSswKDywPqnx; Fri, 13 Nov 2026 18:06:23 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-362664-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 16234114576; Fri, 13 Nov 2026 18:06:14 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 6161A360FF8; Fri, 13 Nov 2026 13:05:44 +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=1794575113; b=y+cYXMCFN51dhWMSjkk413qU1CwtZoHqUXdHSzGUFaiBR9+7TzbR9gz43543fVKg5JKq gWqPfx4Nuj6FFXJs0yivgZSSb8vlu/DnHBD0vO+Dxeofb2zRJBHq0k91/gUskcvS6GtSB B4lCACmOlTtUnC+eNs0SFCjAdbR2abipTGDvRL/JEQPi3VAt0/X2ipPkN/V7c6ysxS/E4 54/L+SQhboonbE3s/yceNt4B/c152PJAvslsQie0G7dJRPUzfVHwBMdThpZjmaExhxCqE qZ/UDx21xeKEZDJSc7kR4ltXnFHmXQz4gJaN9wtfB34LYT4RhDS5ijGdbZn8RPcz6uA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794575113; 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=l9v3zwMWD2nkh/ZKIRfl7G0ROqQEok64RLBR5wNEh5I=; b=GiULri1yvJifHs1vy7GD6MRBcdAltc/fiqW/WsJz3CwizlhCfKYdmGPGBMWUhxEZ3Yn1 C1L7SXfWBWf3Nw1rIrJC+tsd0RBaG+I3El7ybmESuzf1VHhuVxFRK5zOJQ6Y7Zt1g3zel BGbpY/iZxMYyBCOc0hbP/zkeegUw09IOIutO86t4K42ekFI4Nvn+a8c1PPwF+S3FndBKq YIyswy2uVrCdFUwvv2ceuh6scJs3IIO4+hnPVXGfgyF6yQ0F/ggTqpv7r/oQREkO+EN21 uZE1E8+E8djyMcOsOd8TAojicqBi1KZHJwbcCP7cAOmvclvOfi0prEQhyLxEOnpiJaA== 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=Px8Cxf1H; 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 8B85B60A260E; Fri, 13 Nov 2026 13:05:13 +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=Px8Cxf1H 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=1794575112; b=FzctZ2lC86mydcPko9FHXYVI0wSUMfHVfkPuog4xfTldPj9WzSSKibgyRCE+d9UU+lAU sH56HZuNQEyRiG0bgjN0HxwI/ncMbNped8BS44JQjPffjKR872SIXtvNBmz8PVed1m9fo or2KJ5fxA7au1eXqmMy9Bs+s8VMbkGz1rJ7zyyTEHxIM1zfT1vdZy72o/J/hLFBZx6xWH rDZBN0AhCn4CtxnFaXxgRhyXAm9Mm4wxTEStWLgbVENhdJwlTVZQMRwwSH5hVOrGenUsM Uq1dib/JflqkqblEcNRm+mDcG1AiMJC4UjaSEvZE7xTrGTrUNkreiRAm9lGnOap9QYg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794575112; 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=l9v3zwMWD2nkh/ZKIRfl7G0ROqQEok64RLBR5wNEh5I=; b=caiTG0cqtC6lEokyoEq1fSgRle67N0VFYbFUR6pBxz9hIQtTHZ6RYMGeZxgyw5+zvCSL xWQP39bi0/Bm/Ol5oUNzwAfqjo+o/BA8jYTDnmM3P+IfET7CA/Gnw9Z2Xpbz2yyN0Y/c0 RNIwJj0HkxaIr1+fDToYVwEkEy8ixyAURp3XW+LFn7x9ueAds4SrZwv2iUUrgsKiqCybX 87ffX2ydFxp0Si1L1P9BbcybkrkW9ADeZw8uGL90iI4b3tpcchZeBbeo6+38/cTd3Dqxo KRPt6ye8f9K2mLtL/Vk9uYvwuTN00qaNKv9ggUPWwyqbx+QSNZ4RERCpiU2welrnkCQ== 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=Px8Cxf1H; 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 AAE37606A89B; Fri, 13 Nov 2026 13:05:12 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3A661F000C4; Fri, 13 Nov 2026 13:05:11 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794575112; bh=l9v3zwMWD2nkh/ZKIRfl7G0ROqQEok64RLBR5wNEh5I=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Px8Cxf1Hxtkyyn3O8M7ApHDT1lRij38hb+z4J454s13ojdy6ZOij5HTe9Groa/gT2 yLan5U4EMd266Xnc7i/1Kx2zkHRctMunDsY1sMrkN77+JKcCHYzpb0J1BOE9J+6pq9 0Z9ginPxEv0uwPueUCOZhA7M0FjjBLgbO/26SwDz85Pu1jELebiqmA1kVLGkd3CANu OCd8fliUGFriMRX0w0FXYbVKU/u05NxaE/yC9JrrDKaZ9BUUMI/F7XWKKWPeuLVRhQ ZXddcOJMmdmgmQitvy8XsxcYJfzYC4jD6PxplJIUrx6VGhvfmRvGMyKqY+De3xfpV7 o0h/P7dYKsmaQ== X-Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, matttbe@kernel.org, martineau@kernel.org, geliang@kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, kuniyu@google.com, willemb@google.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org X-In-Reply-To: <tencent_AE3D481F5F51E98E657317C2F664C4FA4F08@qq.com> X-sashiko-severity: Medium 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