Article View: linux.kernel.netdev
Article #17775Re: [PATCH net v4 1/3] net: mptcp: take token lookup references with acquire ordering
From: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 09:43
Date: Tue, 17 Nov 2026 09:43
150 lines
13992 bytes
13992 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท 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).
- [High] The fix is incomplete on the passive-open (sk_clone_lock)
allocation path.
- [Low] The patch is tagged `Cc: stable@vger.kernel.org` with Fixes: tags
pointing to v5.8-era commits (2c5ebd001d4f, 96d890daad05).
--
net: mptcp: take token lookup references with acquire ordering
This switches the refcount increments in mptcp_token_get_sock() and
mptcp_token_iter_next() to refcount_inc_not_zero_acquire(). The re-check of
msk->token and sock_net(sk) is then ordered after the reference is taken on
a SLAB_TYPESAFE_BY_RCU socket that may have been recycled. It follows what
commit 5b5d8f351dd9 did for the IPv4/IPv6 established lookups.
> Fixes: 2c5ebd001d4f ("mptcp: refactor token container")
> Fixes: 96d890daad05 ("mptcp: add msk interations helper")
> Cc: stable@vger.kernel.org
[Severity: Low]
Will this build on the stable trees these Fixes: tags reach?
refcount_inc_not_zero_acquire() was added to include/linux/refcount.h by
commit 7f8ceea0c580 in 2025. Both 2c5ebd001d4f and 96d890daad05 date from
v5.8. LTS branches that don't have 7f8ceea0c580 also don't have the helper.
Could the stable tag name the prerequisite, for example:
Cc: stable@vger.kernel.org # depends on 7f8ceea0c580
> diff --git a/net/mptcp/token.c b/net/mptcp/token.c
> index e0f2823f92efb..3429b43a9f7c3 100644
> --- a/net/mptcp/token.c
> +++ b/net/mptcp/token.c
> @@ -309,7 +309,7 @@ struct mptcp_sock *mptcp_token_get_sock(struct net *net, u32 token)
> !net_eq(sock_net(sk), net))
> continue;
>
> - if (!refcount_inc_not_zero(&sk->sk_refcnt))
> + if (!refcount_inc_not_zero_acquire(&sk->sk_refcnt))
> goto not_found;
>
> if (READ_ONCE(msk->token) != token ||
[ ... ]
> @@ -370,7 +370,7 @@ struct mptcp_sock *mptcp_token_iter_next(const struct net *net, long *s_slot,
> if (num <= *s_num)
> continue;
>
> - if (!refcount_inc_not_zero(&sk->sk_refcnt))
> + if (!refcount_inc_not_zero_acquire(&sk->sk_refcnt))
> continue;
>
> if (!net_eq(sock_net(sk), net)) {
[Severity: High]
Does the acquire ordering also cover the passive-open allocation path?
The commit message covers the sock_init_data_uid() path. On the clone
path, every MPTCP-specific store happens after the refcount is already
live. That includes the token the readers re-check:
sk_clone_lock()
sk_clone()
smp_wmb();
refcount_set(&newsk->sk_refcnt, 2);
mptcp_sk_clone_init()
__mptcp_init_sock(nsk);
...
WRITE_ONCE(msk->token, subflow_req->token);
...
mptcp_set_state(nsk, TCP_ESTABLISHED);
WRITE_ONCE(msk->first, ssk);
list_add(&subflow->node, &msk->conn_list);
...
mptcp_copy_inaddrs(nsk, ssk);
...
if (!mptcp_token_accept(subflow_req, msk)) {
The SLAB_TYPESAFE_BY_RCU comment in include/linux/slab.h says "the newly
allocated object has to be fully initialized *before* its refcount gets
initialized". This path doesn't do that.
Take a reader such as mptcp_diag_dump() walking bucket S through
mptcp_token_iter_next(), holding a chain pointer to msk A. A is closed and
freed, and a clone B for a new incoming MPTCP connection reuses its memory
right away.
refcount_inc_not_zero_acquire() then succeeds on B's refcount of 2. The
following READ_ONCE() of the token can return B's new token simply because
that store has already happened. This is a timing issue, not a reordering
one, so strongly ordered CPUs are affected too.
Even with the later patch in this series ("net: mptcp: verify the token
slot in mptcp_token_iter_next()"), this is the only check after the
increment:
token = READ_ONCE(mptcp_sk(sk)->token);
if (!token || (token & token_mask) != slot ||
!net_eq(sock_net(sk), net)) {
If B's token hashes to slot S, B is returned while it is on no token chain
and is still being built in softirq. Its sk_state may still be the
TCP_LISTEN copied from the listener. msk->first, conn_list and the
addresses may not be set yet. On weakly ordered CPUs, the
__mptcp_init_sock() and pm init stores may not be visible either.
That looks like the "or one that is not initialised yet" outcome the commit
message says this change removes.
mptcp_token_get_sock() seems to have the same gap when B's token matches
the token being looked up. One example is a peer that sends an MP_JOIN for
that token right after its MPC ACK, while a reader walks a stale pointer to
a recycled object in the same bucket. The lookup then returns B before
mptcp_token_accept() has hashed it. The later "net: mptcp: reject token 0
in mptcp_token_get_sock()" patch doesn't change this.
The precedent cited in the commit message, __inet_lookup_established(),
also rejects unhashed sockets after the acquire increment:
if (unlikely(!refcount_inc_not_zero_acquire(&sk->sk_refcnt)))
goto out;
if (unlikely(hlist_nulls_unhashed_lockless(&sk->sk_nulls_node) ||
!inet_match(net, sk, acookie, ports, dif,
sdif))) {
sk_clone() calls sk_node_init() before it publishes the refcount, so that
check would reject B.
Should both mptcp sites also re-check
hlist_nulls_unhashed_lockless(&sk->sk_nulls_node) after taking the
reference? Alternatively, could the clone path publish its refcount only
after the MPTCP identity is set?
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/tencent_D0DCF4B132B20B70FB5AE2D9272AA4AEAF07%40qq.com
Technical Details
Message-ID:
<179490863184.3133.11284908359551272618@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365144-linux-kernel-netdev=dewy.ruReferences:
<tencent_D0DCF4B132B20B70FB5AE2D9272AA4AEAF07@qq.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365144-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v4 1/3] net: mptcp: take token lookup references with acquire ordering Date: Tue, 17 Nov 2026 09:43:51 +0000 Organization: Usenet Network Message-ID: <179490863184.3133.11284908359551272618@kernel.org> References: <tencent_D0DCF4B132B20B70FB5AE2D9272AA4AEAF07@qq.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2295927"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:sCgUIu4YT96YtzrAg2iFFajfzE0= sha256:6XjsiHyCIt3fBfD5aAVlnOJ9XSG/WAFIrCrjfI1QBso= sha1:1U97EoqV9ZKOwBiprrzflgwgouI= sha256:Cy1xuOSleGvHoMYMhzdXAFi2EriWcOOOIkRKiBaqz7I= 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 EE924114EEC; Tue, 17 Nov 2026 12:45:52 +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 XEhhovL9HaUI; Tue, 17 Nov 2026 12:45:46 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365144-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 55C67114EE2; Tue, 17 Nov 2026 12:45:38 +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 78F0E3D856; Tue, 17 Nov 2026 09:44: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=1794908639; b=U76MXSBQm5k2EuHezluBF0fVlaV7dJhSvJ7vmZM1IJLHbJzlCbuATTU8a3c9zdPvFW0q jnImPqPqY3OwukauM5tZ3EuWKb7O8TdWHwf9tLTpFK+iuN/g5ECtMQqZ029RNRt0+Sv/4 onbQ2Z65qkQbhw30USAAZGCtsb6/XlCGhck/eaE1sJra0Vzw1A4f1ExnMR4UUqFowiW+z Q6GHOmpyigTPM6IjTKO0eHvALQBd+EjINjgD2j5/tzHiR9NBc5D5hynhgxrChTJXQ+cY8 zgvmphGXRehxF8ofwhEcYbUJvXyroV4PNNfILuk3+ZT34EDdskPaZlR2cuaCDmpJC1g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794908639; 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=7qo4pDApg6kPCIqnGxTspkdPI4s3aZYTTCU9JPkaMZI=; b=ws7zCcnLShW36cbLVuJ1CE35ch06WKg52EhKPjreCZKjye9gT6bsLcY0+eAbooTL5+oe kXUgfMEXSklmzYrx+ivHVB0jS+j4vuatVy8r0y4K/Db/XKcvnkYv8Ndv5W1PPDNHq6trh 9qWBs/WwcFKJlBGZYOhnjhhljDx0Vmgx0vLjiwYX9QyKXYGifq9KtczOxz4rDRTWK8j5j I8gd+FWYROWy0ybDyEMzZXfVdmk8dEEyo6HIQYwoSeMIc9gzpjbVwGF5OxaEAga2KU2bc ViaSckiMJAh4eaAwPV3ybiAYC4edwsHSlCWVrZHYFM87gjIQGXpSpgurBKDDzZ+HfdA== 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=UH4+ZZ5P; 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 8547B606A8A0; Tue, 17 Nov 2026 09:43:59 +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=UH4+ZZ5P 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=1794908633; b=sLoSPBMoFI26SC7LbnPK3agEhPYmF7E6rGbinNQqswa/UibLMEcXkCbDvoaWX+pZljcJ GBbYFnpVpuWc7wKa7nMduITar/rnPhTuM0tqvklP9Xh7Bs8baMXgPwyFxvX4BCxELdDMe pDtRAlJluEQJlxOWljBfzdKnuGjwotnOAV9Xs+ZnYQRGbF+qFrgJulQb3trytqx9Sy2XC iDbZBQWvuts2ntQOx2i/u+OCNdCwaSoihU3D3JIILxitTSHfD5BpR7ErNJ2Zx2S0r/0Qa 3TY0xfQXvMGetQvvHGFyTOGvr3dJkebkNGZ7Wis0nMceu0/e/28zf7gy+G1aWtzYGbw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794908633; 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=7qo4pDApg6kPCIqnGxTspkdPI4s3aZYTTCU9JPkaMZI=; b=N/lfUL2DLBv2DqICWbopnX60KSfEpZDFWOjxkOtGKAKxZ+ZzYs/y2qlrtLqqrMyj1vFz 0nsSstrpC0pcxob52ABNGld9K38m0lfulgCjxSEecCnO3Bu3/SFQedIWvbmBhPtTyQd/5 pG9GJZ+wyj4+1EL7Tmydt3yoyg3ZTBrUcUPVSFa7PrvqRgZVVO/lpAq/RV5cXcpJ/Jn5G iThpklaQNnHd+NoM2vynP2HmiMgI6LP+EvJqTE/Tlq9WZvxgngXeScTjBNM1Kwbm0CUja euuKTA8n8pbTCRQPRwGMALN4TMZpcfGvZQhQgHSJisdNBbiEKNQyAzqpmywxtOSUWbQ== 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=UH4+ZZ5P; 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 A4D3360A5BDE; Tue, 17 Nov 2026 09:43:53 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5379E1F000D2; Tue, 17 Nov 2026 09:43:52 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794908633; bh=7qo4pDApg6kPCIqnGxTspkdPI4s3aZYTTCU9JPkaMZI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=UH4+ZZ5PArpyN3to+x7MhXhi/KR1/pe4KrrPG9HYENuJWzlqDvQJWuuhZN69+oQ7g bpUQo34ZZgVvT3Aqk1kBjMmzf82t9KbbEIMK97p3FGzvjRXoa4pafMpVZ8thxLFOzk dO2eTsu0WyRnG+I3NFzttsncqUiOUKJK8/huCLpFucCpJxJvcR4tTN3om9vByrbjhm XoZ8ScrJiDIunhTqIUf7WhjJ7DEZbgTLDolS3u2lg6JU4gWqVNX1xpQ49PfT810m5i 8VHyvc4o4DVy7nQ+gkFs/N/h/OXKboRDInXVOFJvvlUfz0ZSQIcynrVvrhAsECB2gl O9HMUSZMOHrQA== 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_D0DCF4B132B20B70FB5AE2D9272AA4AEAF07@qq.com> 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 X-Received-Bytes: 13717