Article View: linux.kernel.netdev
Article #21844Re: [PATCH net 04/10] mptcp: fix use-after-free of the subflow context on the delegated list
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 14:26
Date: Tue, 24 Nov 2026 14:26
104 lines
11963 bytes
11963 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The comment in the sock_owned_by_user() branch of
mptcp_napi_poll() (net/mptcp/protocol.c) is now wrong for the caseโฆ
--
mptcp: fix use-after-free of the subflow context on the delegated list
This fixes a use-after-free. subflow_ulp_release() frees the subflow
context with kfree_rcu() while the context is still linked on the per-CPU
delegated napi list. A new MPTCP_DELEGATE_DEAD bit hands the free to
mptcp_napi_poll() when the subflow is scheduled, skips delegated actions
for dead contexts, and moves delegated_status out of struct_group(reset).
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 50c294d925b0c..23d35f43b566e 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
[ ... ]
> @@ -4803,10 +4803,13 @@ static int mptcp_napi_poll(struct napi_struct *napi, int budget)
> delegated = container_of(napi, struct mptcp_delegated_action, napi);
> while ((subflow = mptcp_subflow_delegated_next(delegated)) != NULL) {
> struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
> + long status;
>
> bh_lock_sock_nested(ssk);
> if (!sock_owned_by_user(ssk)) {
> - mptcp_subflow_process_delegated(ssk, xchg(&subflow->delegated_status, 0));
> + status = xchg(&subflow->delegated_status, 0);
> + if (!(status & BIT(MPTCP_DELEGATE_DEAD)))
> + mptcp_subflow_process_delegated(ssk, status);
> } else {
> /* tcp_release_cb_override already processed
> * the action or will do at next release_sock().
> @@ -4814,11 +4817,15 @@ static int mptcp_napi_poll(struct napi_struct *napi, int budget)
> * CPU that scheduled it.
> */
> smp_wmb();
> - clear_bit(MPTCP_DELEGATE_SCHEDULED, &subflow->delegated_status);
> + status = set_mask_bits(&subflow->delegated_status,
> + BIT(MPTCP_DELEGATE_SCHEDULED), 0);
[Severity: Low]
This isn't a bug, but is the comment above this branch still accurate
once MPTCP_DELEGATE_DEAD is set?
The comment says tcp_release_cb_override "already processed the action or
will do at next release_sock()". However, every path that reaches
mptcp_subflow_free_ctx() runs after mptcp_subflow_ops_undo_override() has
restored ssk->sk_prot to plain tcp_prot/tcpv6_prot:
net/mptcp/subflow.c:subflow_ulp_release() {
...
mptcp_subflow_ops_undo_override(ssk);
if (release)
mptcp_subflow_free_ctx(ctx);
}
mptcp_subflow_drop_ctx() reaches the same undo through
subflow_ulp_fallback(). __mptcp_close_ssk() only calls
mptcp_subflow_free_ctx() when icsk_ulp_ops is already NULL.
So for a dead context, the next release_sock() calls tcp_release_cb()
rather than tcp_release_cb_override(). Any pending action bits are dropped,
and the commit message says that is intended ("the pending actions must not
run").
A dead context can reach this branch. __mptcp_close_ssk() holds
lock_sock_nested(ssk) across this chain:
__tcp_close()->inet_csk_destroy_sock()->tcp_cleanup_ulp()->
subflow_ulp_release()->mptcp_subflow_free_ctx()
That means a concurrent mptcp_napi_poll() can see sock_owned_by_user(ssk)
after DEAD has been set.
Could the comment be updated to say that dead contexts have their pending
actions discarded here? It could also mention that status is captured so
the context can be freed with kfree_rcu() after bh_unlock_sock() and
sock_put().
> }
> bh_unlock_sock(ssk);
> sock_put(ssk);
>
> + if (status & BIT(MPTCP_DELEGATE_DEAD))
> + kfree_rcu(subflow, rcu);
> +
> if (++work_done == budget)
> return budget;
> }
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123-net-mptcp-misc-fixes-7-4-rc5-v1-0-278042217e8d%40kernel.org
Technical Details
Message-ID:
<179553041150.3135.10012593386905502123@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370437-linux-kernel-netdev=dewy.ruReferences:
<20261123-net-mptcp-misc-fixes-7-4-rc5-v1-4-278042217e8d@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370437-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 04/10] mptcp: fix use-after-free of the subflow context on the delegated list Date: Tue, 24 Nov 2026 14:26:51 +0000 Organization: Usenet Network Message-ID: <179553041150.3135.10012593386905502123@kernel.org> References: <20261123-net-mptcp-misc-fixes-7-4-rc5-v1-4-278042217e8d@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4156649"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:csH7mzMs06pKoAy9RpKq/Sebzxg= sha256:x0QwEGg8Yk2+0Wv3BF8N7bQDEAX/GH3bGV2dybvQruU= sha1:GYwI/kQ7vV0EN54HMsDwGRq7MRE= sha256:SpJPXPQowW45nwQqL48YZNFbp2luJKoHmZN5ZFtz1kM= 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 1DD2F125E1B; Tue, 24 Nov 2026 17:27:11 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 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] 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 K_hIV8rU-TOK; Tue, 24 Nov 2026 17:27:07 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-370437-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 A81F5125E1A; Tue, 24 Nov 2026 17:26:58 +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 F1CF438E9D; Tue, 24 Nov 2026 14:26:54 +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=1795530414; b=0CD3sEj3qM0gJhw4S2eJVKK3fnbfyHZBeS8rz2zTTgkdWcrJ241LEdVvmF9h/4dUEOc+ /4ALpbAXpYX3Spl7r66eDDik3qr2Ipmz7x6REX51ytdIqMQ1BQiiCHhltqoeCW/j7JxS3 k/6k6umEApopSN0ZqoXwexqECfq1mtBloUf/w/ASkdWmDTjABR8wk0ScU+LB/5t6O199N +aR5w+vKohbXbztzgySaq6TJSZLMz1BhOA1mBuWo/a9f2ElBA4Rt3DMXndTTABfWVLYp2 4tZnpd/QmHL7yqS+n3FZjz/2haiAzUtfJwI1SX/Y2n8VzvEvVbOPyUdMAr60w+jqMDg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795530414; 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=mTwBFRyFSROWCnCFCSSel89ouxGBgoxE6b1oZnyUXq4=; b=tMnweyJDRLpfsiFgbt5n/c2Bt+aSv26Rkw6TDg0rhavRb4Z9e+Nn8awl6ozOCmDpqt+D jXULuGISTnDsYxEh3vO4UWS+S9B3r53Cf8muOkRooJPNpLYa9JFxyv8HCOBcNO0BmwvE5 8eZJOd3TVocB9Q5Cnd4E8BHtbRwUPt7SdRW3/7I0G0xMttSZ9+/6roFhbhZS/x4pinylH dPh5SNeizgzRS1Hyxm6FzJy/yQoLZtIxm2/zNn2mGFLr6tr+VjoOmr9hNe8DKA4z5Kbo7 Qvqzn46SNBNa5O6XZmudViCC7uyybckQrSZu8cPiOIntnxRiFkvuW3g5ebQe9B+q4Kg== 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=n5UEACMU; 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 7BBFE606A335; Tue, 24 Nov 2026 14:26:54 +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=n5UEACMU 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=1795530413; b=m7aP1Yyc8iJDoPUbRVy+mAI5BGZt5ZWswMa7+mZuuvTnXLrfODsT3Xglp4PoOSiI7/Dt u2nBW1NDu/LIxMkX1RTHqZ8OpMrr7lr/VjDjwgo1VqpA3o3/qa+gVUBbCgGT/Z73ZD4r4 fEGPML7RDFHO6/h8B4XCZP3GSZG6/JljWmXVuC4LC5OTEK45ehwDGmDlDx3h5InLOuP29 flPP6f+cx4xevpnhFjfD7tRDHRHUrA/dji/f6fjo6mt7Y8vglpqgXjOY4jRGYZL82STK0 JGqrZPFZDuEPXFHkUD51ddow3U+ONjrEvWw0OUncSONlKXU4SfQDP2ky9n9OIPWxXnA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795530413; 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=mTwBFRyFSROWCnCFCSSel89ouxGBgoxE6b1oZnyUXq4=; b=wE9dX2kk6M7avozW0o+Je6gCmHzmv3nUHYQDmOd1jNQ/aOq5blqh/ga/HVa2m8G81rnP 3mzvVTZod9Chl1W3imuj9pVCdcdZ2xmM5VnF31jYqLjpg+VO7BkPYYGmpGfoszkZWt7JF 1+6qyrcMdeULMG7rguLLTnMYgpPG10sgJnWZCYuON8R5h+LTyfC4yEahES8V747GU3Etq h2DD6VNHJwCbZwDyUMK7k2Ea5mzQ7M46KKnES5XCP55TVwF3S+jdxaeyQvncjiCmyljvJ yWSvt07nvnzlm9y1Sfm5wKdmfo10++Ryn4vOQodfxDmvUsB7YYQ0/6iazu/WvJ9v1IQ== 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=n5UEACMU; 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 99B17606A321; Tue, 24 Nov 2026 14:26:53 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0CC91F000C6; Tue, 24 Nov 2026 14:26:51 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795530413; bh=mTwBFRyFSROWCnCFCSSel89ouxGBgoxE6b1oZnyUXq4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=n5UEACMURgjfpgLFKrsVZFmC2awe4D2PQaskzHFD4iJKlNUhanPH9qPBzrspXZY91 baGS4Fj1wT/jhTrGgr7T1gMIx0J3gfqmR77tS6normc8sU1b6DqOcRfcJJ1YgxX9hb OT5lNHfWt0gW3ayaKFpt/Pi55o0akAfLOAe+1s/I8SRbMktmNzMAKx+UwcCA264ZtM snimwJfXoSB3HZeOoF5i+K2nfaLIteU4laOZv3YWc3kyo8xdD0g6i3XmkehtZMxa+U Es/BMhvxtxpu3zTaohOPN1BTmL0Kh67iz83EfFLMYmRWG0r5WehR6lLFK3cG4Cbvgf kTEwORPTf0lYg== X-Cc: edumazet@kernel.org, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, martineau@kernel.org, geliang@kernel.org, cpaasch@openai.com, fw@strlen.de, netdev@vger.kernel.org, mptcp@lists.linux.dev, dcaratti@redhat.com, mason@kernel.org, stable@vger.kernel.org, ncardwell@google.com, kuniyu@google.com, kafai@fb.com, daniel@iogearbox.net, ast@kernel.org, martin.lau@kernel.org, bpf@vger.kernel.org X-In-Reply-To: <20261123-net-mptcp-misc-fixes-7-4-rc5-v1-4-278042217e8d@kernel.org> X-sashiko-severity: Low 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