From: netdev-bot+sashiko@kernel.org
To: matttbe@kernel.org
Cc: mptcp@lists.linux.dev, kuba@kernel.org
Subject: Re: [PATCH mptcp-net v2 15/62] mptcp: return EOF after a DATA_FIN, as TCP does
Date: Mon, 23 Nov 2026 06:32:24 +0000 [thread overview]
Message-ID: <179541554480.3133.8039878521061914181@kernel.org> (raw)
In-Reply-To: <20261121-mptcp-cmason-fixes-v2-15-00327fd1de1f@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 3 · 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).
- [Medium] In mptcp_check_fastclose() (net/mptcp/protocol.c), the patch
reads msk->rcv_data_fin, drains msk->backlog_list with…
- [Medium] mptcp: early return in mptcp_check_fastclose() skips subflow
close in FIN_WAIT2
- [Medium] mptcp: mptcp_check_data_fin() misses SOCK_DONE after subflow
disconnect
--
mptcp: return EOF after a DATA_FIN, as TCP does
When an MPTCP socket processes a DATA_FIN, this commit sets SOCK_DONE, as
TCP does with a FIN. mptcp_recvmsg() then checks SOCK_DONE before the
socket error, so recv() returns EOF instead of an error after a later
reset. On MP_FASTCLOSE, the backlog is drained first so the DATA_FIN is not
missed.
Link: https://github.com/multipath-tcp/mptcp_net-next/issues/647
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 9e297fa08bfed..91639ae0c8a02 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
[ ... ]
> @@ -2938,6 +2948,11 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)
> if (likely(!READ_ONCE(msk->rcv_fastclose)))
> return;
>
> + /* a DATA_FIN received before still leads to EOF, as with TCP */
> + if (READ_ONCE(msk->rcv_data_fin))
> + mptcp_move_skbs(sk);
> + mptcp_check_data_fin(sk);
> +
> mptcp_token_destroy(msk);
>
> mptcp_for_each_subflow_safe(msk, subflow, tmp) {
[Severity: Medium]
On fallback, this check relies on SOCK_DONE still being set on
msk->first when the DATA_FIN is finally processed on the msk. Can
tcp_disconnect() clear it before that happens?
Consider data + FIN, then a RST, arriving on the fallback subflow
while mptcp_worker() owns the msk socket lock. This can happen, for
example, right after shutdown(SHUT_WR) has scheduled the worker:
softirq, msk owned by mptcp_worker():
tcp_fin(ssk) <- SOCK_DONE set on ssk
mptcp_data_ready()
__mptcp_move_skbs_from_subflow(msk, ssk, false)
payload moved to msk->backlog_list, ack_seq not advanced
subflow_sched_work_if_closed()
MPTCP_WORK_CLOSE_SUBFLOW set, rcv_data_fin = 1
RST: ssk moves to TCP_CLOSE, subflow_error_report() only
defers via MPTCP_ERROR_REPORT
mptcp_worker():
mptcp_check_data_fin(sk)
backlog not spooled, ack_seq != rcv_data_fin_seq: no-op
__mptcp_close_subflow(sk)
mptcp_close_ssk()
__mptcp_close_ssk() <- ssk == msk->first, !dispose_it
__mptcp_subflow_disconnect()
tcp_disconnect(ssk, 0) <- SOCK_DONE cleared on ssk
goto out <- no error report here
release_sock(sk)
mptcp_release_cb()
backlog spooled -> mptcp_check_data_fin(sk)
sock_flag(msk->first, SOCK_DONE) is now false
MPTCP_ERROR_REPORT -> __mptcp_subflow_error_report(sk, ssk)
sock_flag(ssk, SOCK_DONE) is false as well
The msk never gets SOCK_DONE. mptcp_recvmsg() then returns the data
followed by EPIPE or ECONNRESET. That is the fallback case this patch
is meant to fix with v1_connect_tcpfallback_fin_reset.pkt.
The mptcp_check_rcv_close() call added at the out label of
__mptcp_close_ssk() later in the series, by "mptcp: no sf left:
process pending DATA_FIN", seems to see the same cleared flag.
A bare FIN + RST landing between mptcp_check_data_fin() and
__mptcp_close_subflow() in mptcp_worker() looks like it can reach
the same path.
Should the FIN seen on the first subflow be recorded on the msk side
before the disconnect, e.g. in __mptcp_close_ssk() before calling
__mptcp_subflow_disconnect()? That would avoid reading SOCK_DONE
from msk->first later. Or should mptcp_worker() spool the backlog
before its mptcp_check_data_fin() call, as mptcp_check_fastclose()
now does?
[Severity: Medium]
What happens here if the msk is in TCP_FIN_WAIT2 and a DATA_FIN is
pending when the MP_FASTCLOSE is processed? This can happen after
shutdown(SHUT_WR) once the peer has sent its DATA_ACK.
In that state, mptcp_check_data_fin() takes its TCP_FIN_WAIT2 branch.
It calls mptcp_shutdown_subflows() and mptcp_send_ack(), then moves
the msk to TCP_CLOSE. So FIN and ACK segments get queued and sent,
and the retransmit timer gets armed, on subflows that the loop just
below is about to reset.
The bigger issue comes after that loop. The loop sends the resets and
calls tcp_set_state(tcp_sk, TCP_CLOSE) on each subflow. The switch on
sk->sk_state then hits the TCP_CLOSE case and returns early. That
skips setting MPTCP_WORK_CLOSE_SUBFLOW in msk->flags.
The bit may not already be set, for example when the MP_FASTCLOSE
arrived in a pure ACK or on another subflow. If so, and the msk is
not SOCK_DEAD, mptcp_worker() never calls __mptcp_close_subflow().
It will not do anything more for this msk now that it is TCP_CLOSE.
tcp_set_state() alone does not stop the subflow timers or purge their
write queues. The reset subflows therefore stay on msk->conn_list
until userspace closes the msk. __mptcp_close() cleans them up at
that point, so this is not a permanent leak. But a remote peer can
trigger it by sending a DATA_FIN followed by an MP_FASTCLOSE.
Should this new block only move the pending data and set RCV_SHUTDOWN
and SOCK_DONE, without going through the sk_state transitions in
mptcp_check_data_fin()? Or should the TCP_CLOSE case below still make
sure MPTCP_WORK_CLOSE_SUBFLOW is set when the subflows were just
reset here?
[Severity: Medium]
Can a subflow running RX in BH on another CPU still race with this drain?
The rcv_data_fin read, mptcp_move_skbs() and mptcp_check_data_fin() all
run before the loop below takes each subflow lock with lock_sock_fast().
When a segment carries both data and a DATA_FIN, rcv_data_fin is published
before the payload reaches msk->backlog_list:
subflow_data_ready()
mptcp_subflow_data_available()
get_mapping_status()
mptcp_update_rcv_data_fin() <- rcv_data_fin = 1
mptcp_data_ready()
mptcp_data_lock(sk)
__mptcp_move_skbs_from_subflow(msk, ssk, false) <- payload to backlog
Consider this interleaving:
CPU1 (subflow B, BH): parses MP_FASTCLOSE, sets rcv_fastclose, schedules
the worker.
CPU2 (subflow A, BH): get_mapping_status() sets rcv_data_fin = 1.
CPU0 (mptcp_worker, msk owned): mptcp_check_fastclose() sees
rcv_data_fin == 1. mptcp_move_skbs() finds the backlog still empty.
mptcp_check_data_fin() then sees ack_seq != rcv_data_fin_seq and does
nothing, so neither RCV_SHUTDOWN nor SOCK_DONE is set.
CPU2: takes the data lock and queues the payload on the backlog.
CPU0: lock_sock_fast(A) waits for CPU2 to finish. The subflows are then
reset. The msk is still ESTABLISHED, so the switch sets sk_err to
ECONNRESET and the msk moves to TCP_CLOSE.
Later, mptcp_release_cb() spools the late backlog. But the chain
__mptcp_move_skbs()->mptcp_check_data_fin()->mptcp_pending_data_fin()
now fails this check:
if (READ_ONCE(msk->rcv_data_fin) &&
((1 << inet_sk_state_load(sk)) &
(TCPF_ESTABLISHED | TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2))) {
So SOCK_DONE is never set. mptcp_recvmsg() would then return the data,
followed by -ECONNRESET instead of EOF.
That is the behaviour the commit message describes as fixed: "recv()
returned an error after the data ... instead of EOF as TCP does".
The later commit in the series, "mptcp: report errors as TCP does when
closing", keeps the same order in mptcp_check_fastclose(). It still drains
and checks first, then runs the subflow loop, then sets sk_err. So the
window looks like it is still open at the end of the series.
Would it close the window to drain the backlog and call
mptcp_check_data_fin() after the lock_sock_fast()/tcp_set_state(TCP_CLOSE)
loop, but before the sk_state switch? By then any subflow BH already in
progress has finished, and the closed subflows cannot receive anything
more.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f%40kernel.org
next prev parent reply other threads:[~2026-11-23 6:32 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
2026-11-21 9:40 ` [PATCH mptcp-net v2 01/62] tcp: drain the queues of a listen() that fails Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 02/62] mptcp: " Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 03/62] mptcp: clear inet_opt in the child of an IPv6 listener Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 04/62] mptcp: pm: work on a copy of the received RM_ADDR list Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 05/62] mptcp: pm: don't drop an RM_ADDR behind a pending one Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 06/62] mptcp: pm: don't drop an RM_ADDR because of an ADD_ADDR Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-23 10:22 ` Matthieu Baerts
2026-11-21 9:41 ` [PATCH mptcp-net v2 07/62] mptcp: pm: keep an RM_ADDR when computing the MSS Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 08/62] mptcp: arm the rtx timer if a push leaves data behind Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 09/62] mptcp: force the charge for the first skb of a subflow Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 10/62] mptcp: leave an orphan's DATA_FIN to the worker Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 11/62] mptcp: don't leak an orphan when the PM closes its last subflow Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 12/62] mptcp: keep an orphan while it can send its data Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 13/62] mptcp: limit an orphan probing a zero window Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 14/62] mptcp: count orphans as TCP does Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 15/62] mptcp: return EOF after a DATA_FIN, " Matthieu Baerts (NGI0)
2026-11-21 10:25 ` sashiko-bot
2026-11-23 6:32 ` netdev-bot+sashiko [this message]
2026-11-21 9:41 ` [PATCH mptcp-net v2 16/62] mptcp: let TCP send orphan data after fallback Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 17/62] mptcp: reset the subflow on abort " Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 18/62] mptcp: wake up blocked senders when no sf left Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 19/62] mptcp: set SEND_SHUTDOWN on close by an sf error Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 20/62] mptcp: start close timeout on initial sf shutdown Matthieu Baerts (NGI0)
2026-11-21 10:20 ` sashiko-bot
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 21/62] mptcp: process a DATA_FIN received with old data Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 22/62] mptcp: no sf left: process pending MP_FASTCLOSE Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 23/62] mptcp: no sf left: process pending DATA_FIN Matthieu Baerts (NGI0)
2026-11-21 10:17 ` sashiko-bot
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 24/62] mptcp: process pending close events at accept() Matthieu Baerts (NGI0)
2026-11-21 10:13 ` sashiko-bot
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 25/62] mptcp: clear sk_err on connect(), as TCP does Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 26/62] mptcp: clear DEFER_CONNECT on disconnect Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 27/62] mptcp: report sf aborts during deferred connect Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 28/62] mptcp: no fastclose reset from SYN_SENT subflows Matthieu Baerts (NGI0)
2026-11-21 10:11 ` sashiko-bot
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 29/62] mptcp: keep listening after MSG_FASTOPEN errors Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 30/62] mptcp: don't inherit fastopening from a listener Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 31/62] mptcp: drop non-MP_JOIN cookie ACKs on PM listeners Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 32/62] net: add __sk_net_refcnt_upgrade() with a GFP mask Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 33/62] mptcp: pm: don't let listeners pin their netns Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 34/62] mptcp: close a subflow reset for a bad mapping Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 35/62] mptcp: initialize drop_req in subflow_init_req() Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 36/62] mptcp: pm: kernel: count endpoint listeners as sockets in use Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 37/62] mptcp: count a listener once when listen() is called again Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 38/62] mptcp: send the infinite map in a single segment Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 39/62] mptcp: keep room for infinite map after fallback Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 40/62] mptcp: do not fallback while old data is in flight Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 41/62] mptcp: stop resending data to a peer that fell back Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 42/62] mptcp: don't resend data acked without MPTCP opts Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 43/62] mptcp: pm: kernel: don't count signal+subflow ID 0 endp Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 44/62] selftests: mptcp: join: check re-adding " Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 45/62] tcp: do not pass a BPF reqsk to an MPTCP listener Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 46/62] mptcp: reclaim forward memory after coalescing skbs Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 47/62] mptcp: don't charge a shared page twice at accept() Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 48/62] mptcp: don't charge the backlog " Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 49/62] mptcp: don't charge a subflow twice when it joins during accept() Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 50/62] mptcp: continue the last mapping after a fallback Matthieu Baerts (NGI0)
2026-11-23 6:32 ` netdev-bot+sashiko
2026-11-21 9:41 ` [PATCH mptcp-net v2 51/62] mptcp: keep the first byte after a simult connect Matthieu Baerts (NGI0)
2026-11-21 10:31 ` sashiko-bot
2026-11-21 9:41 ` [PATCH mptcp-net v2 52/62] mptcp: move to ESTABLISHED " Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 53/62] mptcp: fix MSG_PEEK after a partly peeked skb Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 54/62] mptcp: send the DATA_ACK after moving the backlog Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 55/62] selftests: mptcp: join: infinite map: no spurious rtx Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 56/62] selftests: mptcp: connect: trunc: wait for acks Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 57/62] mptcp: order write_seq and DATA_FIN flag for fallback Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 58/62] Squash to "bpf: Add mptcp packet scheduler struct_ops" Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-net v2 59/62] Squash to "bpf: Export mptcp packet scheduler helpers" Matthieu Baerts (NGI0)
2026-11-21 10:21 ` sashiko-bot
2026-11-21 9:41 ` [PATCH mptcp-next mptcp-net v2 60/62] mptcp: push pending data after a fallback on reception Matthieu Baerts (NGI0)
2026-11-21 9:41 ` [PATCH mptcp-next mptcp-net v2 61/62] mptcp: report errors as TCP does when closing Matthieu Baerts (NGI0)
2026-11-21 10:30 ` sashiko-bot
2026-11-21 9:42 ` [PATCH RFC mptcp-next mptcp-net v2 62/62] mptcp: reset when the DSS disappears after a DATA_ACK Matthieu Baerts (NGI0)
2026-11-21 10:20 ` sashiko-bot
2026-11-21 12:11 ` [PATCH mptcp-net v2 00/62] mptcp: misc fixes MPTCP CI
2026-11-23 11:57 ` Matthieu Baerts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179541554480.3133.8039878521061914181@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=kuba@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox