🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26589

Re: [PATCH net 5/9] mptcp: return EOF after a DATA_FIN, as TCP does

#26589
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 21:51
164 lines
14011 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] This patch's fix (EOF after a DATA_FIN even when a reset
  follows) does not cover the passive side when accept() gets the msk…
- [Low] mptcp_close_ssk() (net/mptcp/protocol.c:2787-2788) reads
  msk->rcv_data_fin with READ_ONCE() before it takes the first subflow's…

--

mptcp: return EOF after a DATA_FIN, as TCP does

Once a DATA_FIN has been processed, this patch sets SOCK_DONE on the msk.
mptcp_recvmsg() now checks that flag before the socket error, so recv()
returns EOF after the data even if a reset or MP_FASTCLOSE follows. After
a fallback, the emulated DATA_FIN is now set before the subflow close is
scheduled, and mptcp_close_ssk() processes it before the first subflow is
disconnected.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/647

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index fc8aad7e2fde9..1f045348764ad 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c

[ ... ]

> @@ -2763,12 +2775,21 @@ void mptcp_close_ssk(struct sock *sk, struct sock *ssk,

[ ... ]

> +	mptcp_pm_subflow_check_next(msk, subflow);
> +
> +	/* On fallback, the FIN of the first subflow is cleared when it is
> +	 * disconnected: process the DATA_FIN emulated from it before.
> +	 */
> +	if (ssk == msk->first && __mptcp_check_fallback(msk) &&
> +	    READ_ONCE(msk->rcv_data_fin) && !sock_flag(sk, SOCK_DEAD)) {
> +		mptcp_move_skbs(sk);
> +		mptcp_check_data_fin(sk);
> +	}

[Severity: Medium]
Is the passive side covered when accept() takes the msk lock before
mptcp_worker() has handled the emulated DATA_FIN?

When the first subflow is already closed and is the only subflow,
mptcp_stream_accept() moves newsk to TCP_CLOSE before it calls
mptcp_close_ssk():

net/mptcp/protocol.c:mptcp_stream_accept() {
    ...
		if (unlikely(inet_sk_state_load(msk->first) == TCP_CLOSE)) {
			if (unlikely(list_is_singular(&msk->conn_list)))
				mptcp_set_state(newsk, TCP_CLOSE);
			mptcp_close_ssk(newsk, msk->first,
					mptcp_subflow_ctx(msk->first));
		}
    ...
}

The new block above then matches. This is the first subflow, the msk has
fallen back, subflow_sched_work_if_closed() has set rcv_data_fin, and the
msk is not SOCK_DEAD.

But mptcp_check_data_fin() does nothing here. mptcp_pending_data_fin()
only accepts TCPF_ESTABLISHED | TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2, so the
msk gets neither RCV_SHUTDOWN nor SOCK_DONE.

Next, __mptcp_close_ssk()->__mptcp_subflow_disconnect()->tcp_disconnect()
clears SOCK_DONE on the subflow. It keeps sk_err, which tcp_reset() set
to EPIPE in CLOSE_WAIT.

The accept() caller owns the msk, so the error report is deferred as
MPTCP_ERROR_REPORT. Then at release_sock():

mptcp_release_cb()
  __mptcp_error_report()
    __mptcp_subflow_error_report()

This skips the new SOCK_DONE propagation, because the subflow flag is
already cleared, and sets sk_err = EPIPE on the msk.

mptcp_worker() then bails out on TCPF_CLOSE, so nothing corrects this
later. Doesn't mptcp_recvmsg() then return the data followed by -EPIPE
instead of EOF? The commit message says this case is fixed.

The non-fallback case looks similar. Data, a DATA_FIN and an MP_FASTCLOSE
can all arrive before accept(), with the worker not yet run. In that case
mptcp_check_fastclose() and mptcp_check_data_fin() are never called, and
recv() returns -ENOTCONN after the data instead of EOF.

Could the pending DATA_FIN be processed before mptcp_set_state(newsk,
TCP_CLOSE) in mptcp_stream_accept()?

>  
>  	__mptcp_close_ssk(sk, ssk, subflow, MPTCP_CF_PUSH);
>  }

[Severity: Low]
Can the lockless READ_ONCE(msk->rcv_data_fin) check in mptcp_close_ssk()
race with the subflow side?

The check runs before lock_sock_nested() in __mptcp_close_ssk() takes the
first subflow's lock. The emulated DATA_FIN is written from the subflow's
softirq / state_change context:

subflow_sched_work_if_closed()
  mptcp_update_rcv_data_fin()

and the msk lock does not exclude that path.

mptcp_pm_nl_subflow_destroy_doit() in net/mptcp/pm_userspace.c holds only
the msk lock and has no fallback check. It can select msk->first and
does:

	mptcp_subflow_shutdown(sk, ssk, RCV_SHUTDOWN | SEND_SHUTDOWN);
	mptcp_close_ssk(sk, ssk, mptcp_subflow_ctx(ssk));

Consider this interleaving:

1. mptcp_close_ssk() reads rcv_data_fin == 0 and is then preempted.

2. The subflow receives a FIN (tcp_fin() sets SOCK_DONE), then a RST.
   sk_err is set and the error report is deferred as MPTCP_ERROR_REPORT.
   tcp_done() moves the subflow to TCP_CLOSE, and
   subflow_sched_work_if_closed() sets the dummy rcv_data_fin.

3. __mptcp_close_ssk() locks the subflow, sees TCP_CLOSE and calls
   tcp_disconnect(), which clears SOCK_DONE.

4. At release_sock(msk), __mptcp_subflow_error_report() finds no
   SOCK_DONE on the subflow. It moves the msk to TCP_CLOSE and sets
   sk_err.

mptcp_check_data_fin() never runs on this path, so recv() would return
the error instead of EOF.

Moving the MPTCP_WORK_CLOSE_SUBFLOW bit after the dummy DATA_FIN in
subflow_sched_work_if_closed() only orders the worker runs that the bit
triggers, so it does not help this caller.

This is a rare corner case. It needs a userspace PM (CAP_NET_ADMIN)
tearing down the only subflow of a fallback connection, plus precisely
timed peer packets.

Would it make sense to re-check rcv_data_fin under the subflow lock
before disconnecting, or to stop relying on SOCK_DONE surviving on the
subflow?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-net-mptcp-misc-fixes-7-4-rc7-v1-0-9f03efcb1a17%40kernel.org
Technical Details
Message-ID: <179633471320.3146.5929327584163174012@kernel.org>
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376886-linux-kernel-netdev=dewy.ru
References: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-5-9f03efcb1a17@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376886-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 5/9] mptcp: return EOF after a DATA_FIN, as TCP does
Date: Thu, 03 Dec 2026 21:51:53 +0000
Organization: Usenet Network
Message-ID: <179633471320.3146.5929327584163174012@kernel.org>
References: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-5-9f03efcb1a17@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2606155"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:r9vTeRg/53hQatgNm00hTXge3JE= sha256:nbHFMngZ3D6Lh4Fa+VZVXv8l7QXVzwBL3dY4IzLq+rI=
	sha1:r4rkW2LWv+DdKcRltAlbnxJX9fc= sha256:OGwKcznRRgosmtMfHxce8+Q/RFfM/GytZzQA1VKeo0E=
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 584C8117A44; Fri,  4 Dec 2026 00:52:18 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.74
X-Spam-Status: No, score=-3.74 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.24, 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 EBfiuHzDiTJo;
	Fri,  4 Dec 2026 00:52:15 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376886-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 21AAA1179E7; Fri,  4 Dec 2026 00:52:05 +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 33D0B24AB0; Thu,  3 Dec 2026 21:52:01 +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=1796334715;
	b=oqNJ8gRdXWgpSv17nU5bA+ek5gTlXgkI5leoYBpXWCTJze7bJvFQpqKWGvS4n6GSLFve
	 abtixw8QS5fnTl1aKgWSd1C07nwqI3Z6Fzk8E2IxpQK3yQHu6F+hBrB8VGFdmCij2RjGr
	 LjfD/R5SaW5WQuNaIoNKSNWG7VR68cZUvFYKBzkl1+VGxRPGy5eiIFnIkkSdxXYnH+ENr
	 5bALoaOWVxQU+/QinBm41e5t5geYhY6HJzdNfToczEov8jfn8mFctpunZZbJ1lCQYEJVD
	 wVA0ZEEkS85ME6KzHqnz11eeOWttj4PI6uqEahqCiEH70gYQHfN6hxDz3z8tmhmoDjQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796334715;
	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=3cs9IyuyTh0WU6CriC3CXNce117vgtDwWeMIzbzEWyc=;
	b=NmYxBqEvuYkyJK9AfHtbzT3zGIwq7mt4M7gQ3a+TP+A/w1JUJ3xDuiB9ZvFZwBfXsmx4
	 td2JPxGwr1egOxvYSnkOuQhFeNvgz33zMssqNP852NAV2bAysiXID4jLHSg+px8PhLUTA
	 KgYE6cGlhFccev5qHhQmGDPCk28twuzQX4G2gby1cIKP3uqUUHYyxJhnaa/ZMyFddJySw
	 Dwg3JX43TV28WYfpW3nKR+3tFLqQcW772ZM/Fa7lAOmQwjWaF8nyRLNlQBKlykDdnYDCi
	 YrVe3IyNyhjOA+1rMe1LDZhp4bomgIFVpEmLp2bLjSLadeDnJzyDcltUV53O3V3wPiA==
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=J01dUiYZ;
	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 66CCC606A6A4;
	Thu,  3 Dec 2026 21:51:55 +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=J01dUiYZ
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=1796334714;
	b=S19q+F5ed7iSgZZZBlvcmJwvYEgWz1wcndIJErhFcdsN+WxGCIoKsS3rC4s0KlPWztJb
	 jXvswX1GHh3LYvufimDuOlvm3YMIsxWxJ1VlaMl1lXTkC4rPe+3dMp5nLoUjifIts+Z7/
	 vGbWlvLhU94iarXyS1TWfwhu78f/9kVoJpg3BLqlf04P0AtULpUbGeK2WwBzjreQLsITB
	 rhlV4Mcqh4ZHm0UcWnZ1gWbSnNRidH8VhjYD50d4rMzrQz7DXCcFWVvQzX2XQ8s21kqPC
	 FMVtit+jp41NF5eclPtIq0kn1QZZDhhSkstbtdrsFm6hYclADS9mxQ2QLK4Bu15vrtg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796334714;
	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=3cs9IyuyTh0WU6CriC3CXNce117vgtDwWeMIzbzEWyc=;
	b=sa+Lc50yRuBJUE2iVEarvk2WxZo9ltLwzw1muA4A3+tHT0Rx11HJMVWsOyvtc8nnZUpA
	 0OSRA4ChF3M/XJgZ+kpqyyUIfGyvd8ZNzPWRQqaOgApx8smbx+4cruMV5C9qvuc87hnzZ
	 erjkLRPHKjkUyvQw0Aw7f4jM6N+o3GIeFJ7qncDXY0HwaeI/IrmebwcbPjCN9rF5Q+cEw
	 lJy8JnAcUgBkZbIuxXRwVkxD7wfqZQ0sLV0yohpuA/Ryv+o9KImYd6tPirwnU5HvnIFFU
	 LwecqNhNbztSipbvCK7gS6x6t0vatDDRId6efSC0+ZnRGmV+02GEPjbk/MCQweK2PDQ==
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=J01dUiYZ;
	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 89951606A697;
	Thu,  3 Dec 2026 21:51:54 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A20F81F00933;
	Thu,  3 Dec 2026 21:51:53 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796334714;
	bh=3cs9IyuyTh0WU6CriC3CXNce117vgtDwWeMIzbzEWyc=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=J01dUiYZCOkJ8waYXb/+xx7u/rR8vj8037wYegG8VUeipi58AkBIDBrXISNy2eqC1
	 quhcws6HdYp+VEpxbQFKWHFAohiGI8zHsuySnqcB+oVCFTq+74Ctcv68NhjzKwmuU1
	 y4uoJwlvUmEAlNukWzKqAekWU+WiNrwNIOPPdkg2fdfGOBrd12pI/zVVtoK0NSDYzZ
	 q0vHRZ63tVQi9zGDGTOAac07oeQxRdSmYCUnfffcG3bp9mEn4kFakTO2W1wJ2ejDdw
	 GgEQjTCxLPMpeWaIpHLCCtghYxQuL3SHMpnAUgpM1fhfhA+0L0Qu2hvn6AFsjBJrgY
	 PF0023FueZAeg==
X-Cc: martineau@kernel.org, geliang@kernel.org, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com,
 horms@kernel.org, dcaratti@redhat.com, netdev@vger.kernel.org,
 mptcp@lists.linux.dev, mason@kernel.org, stable@vger.kernel.org
X-In-Reply-To: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-5-9f03efcb1a17@kernel.org>
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