[PATCH mptcp-net] mptcp: push pending data after a sendmsg copy fault

Quanye Yang via B4 Relay posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20261017-fix-mptcp-issue-640-v1-1-50a7bace7d43@proton.me
net/mptcp/protocol.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH mptcp-net] mptcp: push pending data after a sendmsg copy fault
Posted by Quanye Yang via B4 Relay 1 month, 1 week ago
From: Quanye Yang <quanyeyang@proton.me>

mptcp_sendmsg() copies into the msk write queue first, then
__mptcp_push_pending() on the success path. tcp_sendmsg_locked()
does the opposite: its do_error path jumps to out, and out
calls tcp_push() when copied > 0.

A later iovec fault (copy_from_iter / -EFAULT) after a successful
iteration therefore returns the partial byte count but leaves the
already-queued dfrag on rtx_queue. No subflow packet is sent, no
retransmission timer is armed, and DATA_FIN stays blocked on
first_pending.

Push in do_error when copied is already non-zero. Do not move
the push to out: copied is a size_t, and sk_stream_error()
stores a negative errno there.

Fixes: 69800e516e96 ("mptcp: propagate fastclose error")
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/640
Signed-off-by: Quanye Yang <quanyeyang@proton.me>
---
 net/mptcp/protocol.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 05c38564e8fd..f72e0e3d2619 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2129,8 +2129,10 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 	return copied;
 
 do_error:
-	if (copied)
+	if (copied) {
+		__mptcp_push_pending(sk, msg->msg_flags);
 		goto out;
+	}
 
 	copied = sk_stream_error(sk, msg->msg_flags, ret);
 	goto out;

---
base-commit: a22035be824449c4921ec406f6383089016a628c
change-id: 20261017-fix-mptcp-issue-640-c47bc084bd36

Best regards,
--  
Quanye Yang <quanyeyang@proton.me>
Re: [PATCH mptcp-net] mptcp: push pending data after a sendmsg copy fault
Posted by Matthieu Baerts 1 month ago
Hi Quanye,

On 17/10/2026 14:46, Quanye Yang via B4 Relay wrote:
> From: Quanye Yang <quanyeyang@proton.me>
> 
> mptcp_sendmsg() copies into the msk write queue first, then
> __mptcp_push_pending() on the success path. tcp_sendmsg_locked()
> does the opposite: its do_error path jumps to out, and out
> calls tcp_push() when copied > 0.
> 
> A later iovec fault (copy_from_iter / -EFAULT) after a successful
> iteration therefore returns the partial byte count but leaves the
> already-queued dfrag on rtx_queue. No subflow packet is sent, no
> retransmission timer is armed, and DATA_FIN stays blocked on
> first_pending.
> 
> Push in do_error when copied is already non-zero. Do not move
> the push to out: copied is a size_t, and sk_stream_error()
> stores a negative errno there.

Thank you for the fix and for the test, it looks good to me:

Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

I just added that it was spot by AI, but easy to reproduce with
Packetdrill (to justify why we want it to -net):

New patches for t/upstream-net and t/upstream:
- f94544594473: mptcp: push pending data after a sendmsg copy fault
- Results: 8d14bfc65f4a..b13e2e43af96 (export-net)
- Results: c2dd59af75f8..9257a00903b8 (export)

Tests are now in progress:

- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/501231f7acb612561523f4e194cf01c77938bdad/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/f2f79e9af965c1c49decfe56312fa547095fbbee/checks

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH mptcp-net] mptcp: push pending data after a sendmsg copy fault
Posted by MPTCP CI 1 month ago
Hi Quanye,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Perf: Critical: No conclusion ❓
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/39579049675

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/21febefb636c
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1187936


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)