All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-net v2 00/62] mptcp: misc fixes
@ 2026-11-21  9:40 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)
                   ` (61 more replies)
  0 siblings, 62 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:40 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason, Josef Bacik, Kyuwon Cho

Here are various fixes, many from Chris Mason and Josef Bacik:

- Patches 1-2: drain the queues of a TCP or MPTCP socket when listen()
  fails, not to leak sockets and their netns. Fixes for v4.4 and v5.11.

- Patch 3: clear inet_opt in the child of an IPv6 listener, to avoid a
  double free with SELinux and NetLabel. A fix for v5.6.

- Patches 4-7: do not lose an RM_ADDR, when received in a row, sent with
  a pending ADD_ADDR echo, or when computing the MSS. Fixes for v5.13,
  v5.10, v5.15 and v5.10.

- Patches 8-9: do not leave data unsent after a memory shortage. Fixes
  for another fix introduced in v6.19 and targeting v5.15, and for
  v5.11.

- Patches 10-11: do not leak an orphan moved to the CLOSE state outside
  the worker. Fixes for v6.15, and for another fix introduced in v6.6
  and targeting v5.11.

- Patches 12-17: do not reset an orphan while it can still send its
  data, also after a fallback, but limit it with a closed window, and
  count it as TCP does, so that tcp_max_orphans limits it too. Also
  return EOF after a DATA_FIN followed by a reset, and send a reset
  when aborting after a fallback, as TCP does. Fixes for v5.11, v5.12,
  v6.1, and for another fix introduced in v6.18 and targeting v6.1.

- Patches 18-20: wake up the senders blocked when the connection is
  closed without subflows, after a subflow error, or when the initial
  subflow is only shut down. Fixes for another fix introduced in v6.6
  and targeting v5.11, and for v5.12.

- Patches 21-24: process a DATA_FIN received with old data, and a
  pending MP_FASTCLOSE or DATA_FIN before closing without subflows, also
  at accept() time, instead of ignoring them: the reader could miss the
  end of file or the reset. Fixes for v5.9, v6.6, v6.19 and v6.3.

- Patch 25: clear the socket error on connect(), as TCP does. A fix for
  v5.17.

- Patches 26-27: with TCP_FASTOPEN_CONNECT, clear DEFER_CONNECT on
  disconnect, and report the error of a first subflow aborted before the
  first write(), instead of EINVAL or EISCONN. Fixes for v6.1, and for
  another fix introduced in v7.4-rc3 and targeting v4.11.

- Patch 28: do not send a fastclose reset from a subflow in SYN_SENT, as
  TCP does. A fix for another fix introduced in v6.18 and targeting
  v6.1.

- Patches 29-30: keep listening after a failed sendmsg() with
  MSG_FASTOPEN, as TCP does, and do not let the new sockets created
  meanwhile inherit a flag preventing their disconnection. Fixes for
  another fix introduced in v6.2 and targeting v6.1.

- Patch 31: drop the ACKs with a SYN cookie and no MP_JOIN on PM
  listeners, which could stop accepting new subflows. A fix for v5.12.

- Patches 32-33: do not let PM listeners pin their netns, leaked
  otherwise. A fix for v5.12.

- Patch 34: close a subflow reset because of a bad mapping, not to keep
  the MPTCP socket established without subflows. A fix for v5.12.

- Patch 35: initialize drop_req, not to leak sockets with SO_REUSEPORT
  migration. A fix for v5.14.

- Patches 36-37: count MPTCP listeners correctly in /proc/net/protocols,
  and send their creation event once. Fixes for another fix introduced
  in v6.4 and targeting v5.17, and for v6.2.

- Patches 38-39: send the infinite mapping in a single segment, with
  room for its DSS option, also after a fallback on reception: its
  segments could be bigger than the MTU, and then dropped. Fixes for
  v5.19.

- Patches 40-42: avoid data delivered twice around a fallback to TCP,
  with old data in flight, or resent to a peer that fell back. Fixes for
  v5.19, and for another fix introduced in v6.12 and targeting v5.13.

- Patches 43-44: do not count a signal+subflow ID 0 endpoint as used at
  each re-creation, and validate it. A fix for another fix introduced in
  v6.11 and targeting v6.0.

- Patch 45: do not pass a BPF request sock to an MPTCP listener, to
  avoid a slab-out-of-bounds write. A fix for v6.9.

- Patches 46-49: reclaim the forward memory after coalescing skbs, and
  do not overcharge the memcg at accept(). Fixes for v6.19.

- Patch 50: after a fallback, continue the last mapping. A fix for
  v6.19.

- Patches 51-52: after a simultaneous connect, do not drop the first
  received byte, and move to ESTABLISHED without waiting for the next
  packet. Fixes for v6.19, and for another fix introduced in v6.19 and
  targeting v6.2.

- Patch 53: with MSG_PEEK, do not skip data after a partly peeked skb:
  the peeked data was corrupted. A fix for v6.18.

- Patch 54: send the DATA_ACK of the data moved from the backlog, to
  avoid spurious MPTCP retransmissions, preventing a fallback after an
  MP_FAIL. A fix for v6.15.

- Patches 55-56: in the selftests, avoid spurious MPTCP retransmissions
  preventing the infinite fallback in the 'Infinite map' subtest, and
  wait for the data to be acked before a fastclose. Fixes for v5.19,
  only effective from v7.3, and for v6.1.

- Patch 57: order the write_seq and DATA_FIN flag updates, not to send a
  FIN before the last byte of data after a fallback, on weakly ordered
  CPUs. A fix for another fix, now in net, and targeting v5.19.

- Patches 58-59: Squash-to patches for the BPF packet schedulers, in the
  MPTCP tree only: stop pushing when they pick no subflow, instead of
  spinning in softirq, and set the rtx timer interval before calling
  them, not to fire the timer every jiffy.

- Patch 60: for mptcp-next: push the pending data, and the FIN, right
  after a fallback on reception, not at the next retransmission timeout.
  A non-urgent fix for v6.12.

- Patch 61: for mptcp-next: report the errors as TCP does when closing:
  ETIMEDOUT after the close timeout or the last subflow's RTO, and the
  reset errors when the last subflow is reset.

- Patch 62: RFC for mptcp-next: reset the subflow when the DSS
  disappears after a DATA_ACK, instead of a fallback to TCP, as
  suggested by RFC 8684.

The Packetdrill tests mptcp/regressions/close_mpj_timeout* will fail
because of patch 61: the Packetdrill patches adapting them will be
shared later.

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Changes in v2:
- Patches 1-2: on top of commit 342e62fd34c2 ("tcp: purge Fast Open RST
  queue when listen() fails"), which purges the RST queue: only the
  accept queue is left. Patch 2 is now reproduced, with MPTCP sockets.
- Patch 5: no netlink event for the dropped ids (Clashiko), but still
  for the next pending ones (Sashiko).
- Patch 6: send the RM_ADDR at once (Clashiko).
- Patch 7: new, for an issue spotted by Clashiko.
- Patch 12: new, for issue #647 reported on GitHub.
- Patch 13: new, to limit the orphans kept by patch 12, as TCP does,
  for an issue found by a review agent.
- Patch 14: new, spotted by a review agent.
- Patch 15: new, for issue #647 reported on GitHub.
- Patch 16: new, for a similar issue found by a review agent.
- Patch 17: new, for an issue found by a review agent.
- Patch 18: new, for issue #648 reported on GitHub.
- Patch 19: new, for a similar issue found by a review agent.
- Patch 20: new, for an issue found by a review agent and Sashiko.
- Patches 21-23: new, for issues causing flaky selftests.
- Patches 24-25: new, for issues found by a review agent.
- Patch 26: new, for an issue found by a review agent.
- Patch 27: new, for an issue spotted by Sashiko.
- Patch 28: new, for an issue found by a review agent.
- Patches 29-30: new, for issues found by a review agent.
- Patch 34: commit msg: the reset after a bad checksum too (Sashiko).
- Patch 36: count the listener once listen() succeeded, and restore
  TCP_CLOSE otherwise (Sashiko, Kyuwon Cho).
- Patch 37: commit msg: explain the two Fixes tags.
- Patch 38: new, for an issue causing a flaky selftest.
- Patch 39: new, for an issue spotted by Sashiko.
- Patch 40: commit msg: the peer can still fall back alone (Clashiko),
  and only clamp to one MSS when sending the infinite mapping (Sashiko).
- Patch 41: drop the segment if the push resets the subflow (Sashiko,
  Clashiko).
- Patch 42: new, for an issue spotted by Clashiko.
- Patch 44: skip a part if the nft rule cannot be added (Clashiko).
- Patch 49: update a comment (Clashiko).
- Patch 50: commit msg: the sender now resets in the remaining case
  (Clashiko).
- Patch 51: new, for an issue spotted by Sashiko.
- Patch 52: new, for an issue found by a review agent, after a Sashiko
  review.
- Patch 53: new, for an issue causing a flaky selftest.
- Patch 54: new, for an issue causing a flaky selftest.
- Patches 55-56: new, for flaky selftests.
- Patch 57: new, for an issue spotted by Clashiko in a fix pending in
  net.
- Patch 58: new, for an issue found by a review agent.
- Patch 59: new, for an issue spotted by Clashiko.
- Patch 60: new, for mptcp-next, for an issue spotted by Clashiko in a
  fix pending in net.
- Patch 61: new, for mptcp-next, as suggested in the GitHub issue #648.
- Patch 62: also reset on an invalid mapping (Clashiko).
- Patches 11, 23-26 and 32 from v1: dropped, applied in the MPTCP tree.
- Link to v1: https://patch.msgid.link/20261113-mptcp-cmason-fixes-v1-0-9205b77e9a2f@kernel.org

---
Chris Mason (16):
      tcp: drain the queues of a listen() that fails
      mptcp: drain the queues of a listen() that fails
      mptcp: clear inet_opt in the child of an IPv6 listener
      mptcp: arm the rtx timer if a push leaves data behind
      mptcp: force the charge for the first skb of a subflow
      mptcp: leave an orphan's DATA_FIN to the worker
      mptcp: drop non-MP_JOIN cookie ACKs on PM listeners
      mptcp: close a subflow reset for a bad mapping
      mptcp: initialize drop_req in subflow_init_req()
      mptcp: do not fallback while old data is in flight
      mptcp: stop resending data to a peer that fell back
      tcp: do not pass a BPF reqsk to an MPTCP listener
      mptcp: reclaim forward memory after coalescing skbs
      mptcp: don't charge a shared page twice at accept()
      mptcp: don't charge the backlog twice at accept()
      mptcp: continue the last mapping after a fallback

Josef Bacik (5):
      mptcp: pm: work on a copy of the received RM_ADDR list
      mptcp: pm: don't drop an RM_ADDR behind a pending one
      mptcp: pm: don't drop an RM_ADDR because of an ADD_ADDR
      mptcp: pm: don't let listeners pin their netns
      mptcp: pm: kernel: don't count signal+subflow ID 0 endp

Matthieu Baerts (NGI0) (41):
      mptcp: pm: keep an RM_ADDR when computing the MSS
      mptcp: don't leak an orphan when the PM closes its last subflow
      mptcp: keep an orphan while it can send its data
      mptcp: limit an orphan probing a zero window
      mptcp: count orphans as TCP does
      mptcp: return EOF after a DATA_FIN, as TCP does
      mptcp: let TCP send orphan data after fallback
      mptcp: reset the subflow on abort after fallback
      mptcp: wake up blocked senders when no sf left
      mptcp: set SEND_SHUTDOWN on close by an sf error
      mptcp: start close timeout on initial sf shutdown
      mptcp: process a DATA_FIN received with old data
      mptcp: no sf left: process pending MP_FASTCLOSE
      mptcp: no sf left: process pending DATA_FIN
      mptcp: process pending close events at accept()
      mptcp: clear sk_err on connect(), as TCP does
      mptcp: clear DEFER_CONNECT on disconnect
      mptcp: report sf aborts during deferred connect
      mptcp: no fastclose reset from SYN_SENT subflows
      mptcp: keep listening after MSG_FASTOPEN errors
      mptcp: don't inherit fastopening from a listener
      net: add __sk_net_refcnt_upgrade() with a GFP mask
      mptcp: pm: kernel: count endpoint listeners as sockets in use
      mptcp: count a listener once when listen() is called again
      mptcp: send the infinite map in a single segment
      mptcp: keep room for infinite map after fallback
      mptcp: don't resend data acked without MPTCP opts
      selftests: mptcp: join: check re-adding signal+subflow ID 0 endp
      mptcp: don't charge a subflow twice when it joins during accept()
      mptcp: keep the first byte after a simult connect
      mptcp: move to ESTABLISHED after a simult connect
      mptcp: fix MSG_PEEK after a partly peeked skb
      mptcp: send the DATA_ACK after moving the backlog
      selftests: mptcp: join: infinite map: no spurious rtx
      selftests: mptcp: connect: trunc: wait for acks
      mptcp: order write_seq and DATA_FIN flag for fallback
      Squash to "bpf: Add mptcp packet scheduler struct_ops"
      Squash to "bpf: Export mptcp packet scheduler helpers"
      [mptcp-next] mptcp: push pending data after a fallback on reception
      [mptcp-next] mptcp: report errors as TCP does when closing
      [RFC mptcp-next] mptcp: reset when the DSS disappears after a DATA_ACK

 include/net/sock.h                                |   1 +
 net/core/sock.c                                   |   9 +-
 net/ipv4/inet_connection_sock.c                   |  12 +-
 net/ipv4/syncookies.c                             |   3 +-
 net/mptcp/mib.h                                   |   2 +-
 net/mptcp/options.c                               |  53 ++-
 net/mptcp/pm.c                                    |  50 ++-
 net/mptcp/pm_kernel.c                             |  15 +-
 net/mptcp/protocol.c                              | 476 ++++++++++++++++++----
 net/mptcp/protocol.h                              |  30 +-
 net/mptcp/sched.c                                 |   3 +
 net/mptcp/subflow.c                               | 115 +++++-
 tools/testing/selftests/net/mptcp/mptcp_connect.c |  24 +-
 tools/testing/selftests/net/mptcp/mptcp_join.sh   |  19 +-
 14 files changed, 671 insertions(+), 141 deletions(-)
---
base-commit: b9620afcd7c2a78410eb68fa5fe70b9da8ce088e
base-tree: https://github.com/multipath-tcp/mptcp_net-next.git t/upstream
change-id: 20261110-mptcp-cmason-fixes-eec0054c880a

Best regards,
--  
Matthieu Baerts (NGI0) <matttbe@kernel.org>


^ permalink raw reply	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 01/62] tcp: drain the queues of a listen() that fails
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
@ 2026-11-21  9:40 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 02/62] mptcp: " Matthieu Baerts (NGI0)
                   ` (60 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:40 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

If listen() fails on a TCP socket that has listened before, the sockets
of connections from the earlier listen() can leak, together with their
network namespace.

inet_csk_listen_start() sets TCP_LISTEN before it calls get_port() and
hash(), and its error path sets TCP_CLOSE again, then purges the Fast
Open RST queue since commit 342e62fd34c2 ("tcp: purge Fast Open RST
queue when listen() fails"), but not the accept queue. Pending request
socks outlive an earlier listen() and still point to the socket, so in
TCP_LISTEN, inet_csk_reqsk_queue_add() adds them to the accept queue,
with their new child. These entries, and the sockets that they hold,
are never freed, since close() drains this queue only in TCP_LISTEN and
the next listen() stores NULL in rskq_accept_head.

The fix used here is to call inet_csk_listen_stop() after the error path
sets TCP_CLOSE, which also purges the RST queue, except for an MPTCP
subflow, which needs mptcp_subflow_queue_clean() first: only its RST
queue is purged here, and mptcp_listen() has to drain its accept queue,
which is done in the next patch, "mptcp: drain the queues of a listen()
that fails".

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch,
run as an unprivileged user: listen() failing with EADDRINUSE in a loop,
while the connections of an earlier listen() complete. Without this
patch, sockets were leaked, and network namespaces too when each round
was in its own one, without any message from the kernel:

  result: request socks: 10000 made, 2535 left. Sockets: 33373 made, 5070 left
  [...]
  result: namespaces: 1000 made, 694 taken down, 306 left

Fixes: 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comments. Commit message: how the issue was found, and its
  symptoms. On top of commit 342e62fd34c2, with a Fixes tag for the
  accept queue. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: on top of commit 342e62fd34c2, which purges the RST queue, still
done for MPTCP subflows: Fixes tag for the accept queue.
---
 net/ipv4/inet_connection_sock.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index dec0ce6ff0f3..8b0e0746dfda 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -1371,8 +1371,8 @@ int inet_csk_listen_start(struct sock *sk)
 
 	/* There is race window here: we announce ourselves listening,
 	 * but this transition is still not validated by get_port().
-	 * It is OK, because this socket enters to hash table only
-	 * after validation is complete.
+	 * This socket enters to hash table only after validation is
+	 * complete, but reqs of an earlier listen() may queue children.
 	 */
 	inet_sk_state_store(sk, TCP_LISTEN);
 	err = sk->sk_prot->get_port(sk, inet->inet_num);
@@ -1390,9 +1390,13 @@ int inet_csk_listen_start(struct sock *sk)
 
 	/* A Fast Open child accepted before a previous shutdown() of this
 	 * listener might have queued its request in rskq_rst_head while
-	 * we were transiently in TCP_LISTEN state.
+	 * we were transiently in TCP_LISTEN state. The accept queue of an
+	 * MPTCP subflow is drained by mptcp_listen().
 	 */
-	reqsk_fastopen_purge_rst(&icsk->icsk_accept_queue);
+	if (sk_is_mptcp(sk))
+		reqsk_fastopen_purge_rst(&icsk->icsk_accept_queue);
+	else
+		inet_csk_listen_stop(sk);
 	return err;
 }
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 02/62] mptcp: drain the queues of a listen() that fails
  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 ` 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)
                   ` (59 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

Sockets and their network namespace can leak, if a handshake completes
while listen() fails on an MPTCP socket that has listened before.

mptcp_listen() passes the first subflow through __inet_listen_sk() to
inet_csk_listen_start(), which sets TCP_LISTEN, then calls get_port()
and hash(), and sets TCP_CLOSE again if either fails. Until then the
subflow is in TCP_LISTEN, so a request sock of a previous listen() that
still points to it can get a new child and be added to the subflow's
accept queue. But neither close() nor the next listen() frees what is
queued, and the earlier commit "tcp: drain the queues of a listen() that
fails" only purges the RST queue of an MPTCP subflow, which needs
mptcp_subflow_queue_clean() before a drain.

The fix used here is to call mptcp_subflow_queue_clean() and then
inet_csk_listen_stop() on the subflow in mptcp_listen(), if
__inet_listen_sk() returns an error with the subflow in TCP_CLOSE.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer of the previous commit, modified to use MPTCP
sockets, on both sides. Without this patch, sockets were leaked, and
network namespaces too when each round was in its own one, without any
message from the kernel:

  result: request socks: 10000 made, 1151 left. Sockets: 64982 made, 5755 left
  [...]
  result: namespaces: 1000 made, 923 taken down, 77 left

Fixes: 76e2a55d1625 ("mptcp: better msk-level shutdown.")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comment. Add a Fixes tag. Commit message: how the issue was
  found, and its symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: commit msg: reproduced, with MPTCP sockets. Only the accept queue is
left, after commit 342e62fd34c2 ("tcp: purge Fast Open RST queue when
listen() fails").
---
 net/mptcp/protocol.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index be23768b6d05..08c3b005949d 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -4383,6 +4383,11 @@ static int mptcp_listen(struct socket *sock, int backlog)
 
 	lock_sock(ssk);
 	err = __inet_listen_sk(ssk, backlog);
+	if (err && ssk->sk_state == TCP_CLOSE) {
+		/* inet_csk_listen_start() leaves this drain to MPTCP */
+		mptcp_subflow_queue_clean(sk, ssk);
+		inet_csk_listen_stop(ssk);
+	}
 	release_sock(ssk);
 	mptcp_set_state(sk, inet_sk_state_load(ssk));
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 03/62] mptcp: clear inet_opt in the child of an IPv6 listener
  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 ` 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)
                   ` (58 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

With SELinux, an IPv6 MPTCP listener and its children can cause a double
free of one CIPSO option, and then a use-after-free read of it, if
NetLabel uses CIPSO for IPv4 and selects the IPv6 labels by address.

mptcp_sk_clone_init() creates the child of a listener with
sk_clone_lock(), as a byte copy of the listener, so each pointer in the
copy that the socket destructor frees has to be replaced or cleared.
mptcp_copy_ip_options() duplicates inet_opt, the IPv4 options, for
AF_INET, and mptcp_copy_ip6_options() duplicates the IPv6 options for
AF_INET6. But an AF_INET6 socket has an inet_opt pointer too, and its
child keeps the listener's pointer.

MPTCP does not support setsockopt(IP_OPTIONS), so that pointer is
usually NULL. But if connect() gets a struct sockaddr_in,
netlbl_conn_setattr() does not look at the family of the socket, so the
connect() hook of SELinux can store a CIPSO option in inet_opt of an
AF_INET6 MPTCP listener. inet_sock_destruct() then passes that option to
kfree_rcu() for each child and again for the listener, and after a child
has freed it, another such connect() on the listener reads it in
cipso_v4_sock_setattr().

The fix used here is to clear inet_opt of the child in
mptcp_copy_ip6_options().

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch,
with SELinux, NetLabel -- CIPSO for some IPv4 addresses, and the
address-based selection used for IPv6 too -- and KASAN: an unprivileged
user calls connect() with an IPv4 address on an IPv6 MPTCP listener.
Without this patch, an object is freed twice:

  BUG: KASAN: double-free in rcu_free_sheaf+0x23/0x100
  Free of addr ffff888012c27a80 by task kworker/1:1/50
  CPU: 1 UID: 0 PID: 50 Comm: kworker/1:1 Not tainted 7.4.0-rc1+ #1 PREEMPT(full)
  Workqueue: events mptcp_worker
  Call Trace:
   <IRQ>
   kasan_report_invalid_free+0xd4/0x1b0
   check_slab_allocation+0xc2/0xf0
   __rcu_free_sheaf_prepare+0x102/0x2a0
   rcu_free_sheaf+0x23/0x100
   rcu_do_batch+0x29a/0xf80
   rcu_core+0x33c/0x830
   handle_softirqs+0x212/0x980
   do_softirq+0xb4/0xf0
   </IRQ>
   <TASK>
   __local_bh_enable_ip+0x11c/0x150
   mptcp_token_destroy+0x1c9/0x360
   mptcp_destroy_common+0x2d9/0x430
   mptcp_destroy+0x86/0x110
   __mptcp_destroy_sock+0x176/0x350
   mptcp_worker+0xbb5/0xf80
  [...]
  Allocated by task 176:
  [...]
   cipso_v4_sock_setattr+0x9b/0x3d0
   netlbl_conn_setattr+0x3ac/0x500
   selinux_netlbl_socket_connect_locked+0x102/0x210
   selinux_netlbl_socket_connect+0x23/0x40
   security_socket_connect+0x2e/0x60
   __sys_connect_file+0xcb/0x200
  [...]

In another case, the CIPSO option is used after having been freed:

  BUG: KASAN: slab-use-after-free in cipso_v4_sock_setattr+0x3c7/0x3d0
  Read of size 1 at addr ffff8880161c2f18 by task python3/177
  CPU: 1 UID: 65534 PID: 177 Comm: python3 Not tainted 7.4.0-rc1+ #1 PREEMPT(full)
  Call Trace:
   <TASK>
   kasan_report+0x101/0x140
   cipso_v4_sock_setattr+0x3c7/0x3d0
   netlbl_conn_setattr+0x3ac/0x500
   selinux_netlbl_socket_connect_locked+0x102/0x210
   selinux_netlbl_socket_connect+0x23/0x40
   security_socket_connect+0x2e/0x60
   __sys_connect_file+0xcb/0x200
   __sys_connect+0xfd/0x130
   __x64_sys_connect+0x72/0xd0
  [...]

Fixes: cf7da0d66cc1 ("mptcp: Create SUBFLOW socket for incoming connections")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Commit message: how the issue was found, and its symptoms ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/protocol.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 08c3b005949d..54782bdce5fb 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3720,6 +3720,9 @@ static void mptcp_copy_ip6_options(struct sock *newsk, const struct sock *sk)
 
 	newnp = inet6_sk(newsk);
 
+	/* The IPv4 options belong to the listener, which frees them */
+	RCU_INIT_POINTER(inet_sk(newsk)->inet_opt, NULL);
+
 	rcu_read_lock();
 	opt = rcu_dereference(np->opt);
 	if (opt) {

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 04/62] mptcp: pm: work on a copy of the received RM_ADDR list
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (2 preceding siblings ...)
  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 ` 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)
                   ` (57 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Josef Bacik

From: Josef Bacik <josef@toxicpanda.com>

The worker clears MPTCP_PM_RM_ADDR_RECEIVED and walks pm.rm_list_rx in
place.  For every subflow it closes, mptcp_pm_rm_addr_or_subflow() drops
pm.lock.  If the peer's next RM_ADDR arrives then, the flag is clear and
mptcp_pm_rm_addr_received() overwrites the list.  The walk goes on at
its index in the new list: the ids of the first list that were still to
come are never handled, and their subflows stay.

Hand a copy of the list to the walk.

This issue has been found with the help of an LLM. It has not been
reproduced: the next RM_ADDR has to be processed while the worker has
dropped pm.lock to close a subflow, a window that a Packetdrill script
cannot target. This fix is based on code inspection only, which is
acceptable here: it is simple, and the issue is clear from the code.

Fixes: d0b698ca9a27 ("mptcp: remove multi addresses in PM")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
[ Commit message: how the issue was found, and why it is fine without
  a reproducer. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index d7c5b50b34cc..cdc8bab0eaf8 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -827,7 +827,10 @@ static void mptcp_pm_rm_addr_or_subflow(struct mptcp_sock *msk,
 
 static void mptcp_pm_rm_addr_recv(struct mptcp_sock *msk)
 {
-	mptcp_pm_rm_addr_or_subflow(msk, &msk->pm.rm_list_rx, MPTCP_MIB_RMADDR);
+	/* pm.lock is dropped on the way: the next RM_ADDR may come in */
+	struct mptcp_rm_list rm_list = msk->pm.rm_list_rx;
+
+	mptcp_pm_rm_addr_or_subflow(msk, &rm_list, MPTCP_MIB_RMADDR);
 }
 
 void mptcp_pm_rm_subflow(struct mptcp_sock *msk,

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 05/62] mptcp: pm: don't drop an RM_ADDR behind a pending one
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (3 preceding siblings ...)
  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 ` 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)
                   ` (56 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Josef Bacik

From: Josef Bacik <josef@toxicpanda.com>

There is room for one received list of address ids.  An RM_ADDR that
arrives before the worker has taken the previous one is counted as
RmAddrDrop and forgotten, although the netlink events for its ids have
been sent already.  Two options follow each other at once if, for
instance, the path manager in user space of the peer removes two of its
addresses.  The subflows to the second address stay.

Add the new ids to the pending list.  Only the ids that do not fit in
the list of MPTCP_RM_IDS_MAX ids are dropped, and the RM_ADDR is then
counted as RmAddrDrop.  The netlink events are not sent for the
dropped ids, and they are sent before the worker can act on the others.

This issue has been found with the help of an LLM. It has not been
reproduced: the second RM_ADDR has to be processed before the PM worker
gets to the first one, a window that a Packetdrill script cannot
target. This fix is based on code inspection only, which is acceptable
here: the issue is clear from the code, and the fix is simple.

Fixes: d0876b2284cf ("mptcp: add the incoming RM_ADDR support")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
[ Commit message: only the ids that do not fit are dropped + how the
  issue was found, and why it is fine without a reproducer. No netlink
  event for the dropped ids. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: no netlink event for the dropped ids (Clashiko), but still for the
    next pending ones (Sashiko)

Note (Clashiko on v1): as before, an event is sent for each id of each
received RM_ADDR, even if this id is already pending.
---
 net/mptcp/pm.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index cdc8bab0eaf8..f1f4b13c5459 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -843,17 +843,30 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk,
 			       const struct mptcp_rm_list *rm_list)
 {
 	struct mptcp_pm_data *pm = &msk->pm;
+	bool drop = false;
 	u8 i;
 
 	pr_debug("msk=%p remote_ids_nr=%d\n", msk, rm_list->nr);
 
-	for (i = 0; i < rm_list->nr; i++)
-		mptcp_event_addr_removed(msk, rm_list->ids[i]);
-
 	spin_lock_bh(&pm->lock);
 	if (mptcp_pm_schedule_work(msk, MPTCP_PM_RM_ADDR_RECEIVED))
-		pm->rm_list_rx = *rm_list;
-	else
+		pm->rm_list_rx.nr = 0;
+
+	/* the worker may not have got to the previous RM_ADDR yet */
+	for (i = 0; i < rm_list->nr; i++) {
+		u8 id = rm_list->ids[i];
+
+		if (!memchr(pm->rm_list_rx.ids, id, pm->rm_list_rx.nr)) {
+			if (pm->rm_list_rx.nr == MPTCP_RM_IDS_MAX) {
+				drop = true;
+				continue;
+			}
+			pm->rm_list_rx.ids[pm->rm_list_rx.nr++] = id;
+		}
+		/* not for the dropped ids, and before the worker acts */
+		mptcp_event_addr_removed(msk, id);
+	}
+	if (drop)
 		__MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_RMADDRDROP);
 	spin_unlock_bh(&pm->lock);
 }

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 06/62] mptcp: pm: don't drop an RM_ADDR because of an ADD_ADDR
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (4 preceding siblings ...)
  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 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 07/62] mptcp: pm: keep an RM_ADDR when computing the MSS Matthieu Baerts (NGI0)
                   ` (55 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Josef Bacik

From: Josef Bacik <josef@toxicpanda.com>

mptcp_pm_remove_addr() gives up, and counts RmAddrTxDrop, if any bit of
pm.addr_signal is set. That dates from the time when the byte was
cleared as a whole after a signal had been sent. Since
commit 119c022096f5 ("mptcp: fix ADD_ADDR and RM_ADDR maybe flush
addr_signal each other") an ADD_ADDR, an echo and an RM_ADDR each clear
their own bit, and they have storage of their own: pm.local, pm.remote
and pm.rm_list_tx. mptcp_pm_announce_addr() looks at its own bit only.

The callers have updated their state by then and ignore the result: the
endpoint is gone, the announcement is forgotten, and the peer never
learns that the address is not valid any more.

When the bit of an echo is set at the arrival of the peer's ADD_ADDR,
it stays set until the PM worker has sent the ACK. An endpoint that is
removed in between loses its RM_ADDR.

Only a pending RM_ADDR stands in the way, as rm_list_tx would be
overwritten. A pure ACK carries the pending ADD_ADDR or echo first: up
to three ACKs are then sent at once, preferably on a subflow that is not
being removed, until one carries the RM_ADDR, and as long as they carry
one of these signals. Otherwise, the RM_ADDR would go with the next
packet, which could be sent on a subflow being removed, or after an
ADD_ADDR re-announcing the same ID.

This issue has been found with the help of an LLM. It has not been
reproduced: the endpoint has to be removed before the PM worker sends
the pending ADD_ADDR or echo, a window that a Packetdrill script cannot
target. This fix is based on code inspection only, which is acceptable
here: the issue is clear from the code, and the fix is small.

Fixes: 119c022096f5 ("mptcp: fix ADD_ADDR and RM_ADDR maybe flush addr_signal each other")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
[ Use mptcp_pm_should_rm_signal() instead of a comment. Fixes tag:
  119c022096f5 instead of 42842a425ad6. Commit message: remove the
  number of attempts, say which packet carries the RM_ADDR then, and
  when the echo bit is set + how the issue was found, and why it is fine
  without a reproducer. Send the RM_ADDR at once, with up to three ACKs,
  instead of with the next packet. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: send the RM_ADDR at once, not with the next packet (Clashiko)
---
 net/mptcp/pm.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index f1f4b13c5459..cdd62433e0a6 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -526,10 +526,11 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
 int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list)
 {
 	u8 rm_addr = READ_ONCE(msk->pm.addr_signal);
+	int i;
 
 	pr_debug("msk=%p, rm_list_nr=%d\n", msk, rm_list->nr);
 
-	if (rm_addr) {
+	if (mptcp_pm_should_rm_signal(msk)) {
 		MPTCP_ADD_STATS(sock_net((struct sock *)msk),
 				MPTCP_MIB_RMADDRTXDROP, rm_list->nr);
 		return -EINVAL;
@@ -538,7 +539,16 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_
 	msk->pm.rm_list_tx = *rm_list;
 	rm_addr |= BIT(MPTCP_RM_ADDR_SIGNAL);
 	WRITE_ONCE(msk->pm.addr_signal, rm_addr);
-	mptcp_pm_addr_send_ack_avoid_list(msk, rm_list);
+
+	/* pending ADD_ADDR and echo take the first ACKs: one more each */
+	for (i = 0; i < 3 && mptcp_pm_should_rm_signal(msk); i++) {
+		u8 signal = READ_ONCE(msk->pm.addr_signal);
+
+		mptcp_pm_addr_send_ack_avoid_list(msk, rm_list);
+		/* no signal sent, e.g. after a fallback: no more ACKs */
+		if (READ_ONCE(msk->pm.addr_signal) == signal)
+			break;
+	}
 	return 0;
 }
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 07/62] mptcp: pm: keep an RM_ADDR when computing the MSS
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (5 preceding siblings ...)
  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-21  9:41 ` 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)
                   ` (54 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

tcp_current_mss() calls mptcp_established_options() without skb, to
know the size of the options. A pending RM_ADDR was then taken: its
signal bit was cleared, and RmAddrTx was incremented, but it was not
sent. The peer then never learnt that the address was not valid any
more. An ADD_ADDR is not affected: it is only sent with a pure ACK.

Without skb, only reserve the size of the RM_ADDR, and keep it pending
for the packet that will be sent.

This issue has been reported by Clashiko, while reviewing commit
"mptcp: pm: don't drop an RM_ADDR because of an ADD_ADDR", and
confirmed with a script on an earlier version of that commit, where the
RM_ADDR stayed pending longer: data was sent while it was pending.
RmAddrTx was then 1 on the sender, but RmAddr 0 on the receiver. With
that commit, the window is narrower: tcp_current_mss() has to be called
between the moment the RM_ADDR is pending, and the moment the ACK is
sent.

Fixes: 5cb104ae55e9 ("mptcp: add the outgoing RM_ADDR support")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue spotted by Clashiko
---
 net/mptcp/options.c  | 12 +++++++++---
 net/mptcp/pm.c       |  8 ++++++--
 net/mptcp/protocol.h |  3 ++-
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 6365e180d9a0..736e55532296 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -762,7 +762,8 @@ static bool mptcp_established_options_add_addr(struct sock *sk,
 	return true;
 }
 
-static bool mptcp_established_options_rm_addr(struct sock *sk, int *size,
+static bool mptcp_established_options_rm_addr(struct sock *sk,
+					      struct sk_buff *skb, int *size,
 					      unsigned int remaining,
 					      struct mptcp_out_options *opts)
 {
@@ -772,9 +773,13 @@ static bool mptcp_established_options_rm_addr(struct sock *sk, int *size,
 	int i;
 
 	if (!mptcp_pm_should_rm_signal(msk) ||
-	    !(mptcp_pm_rm_addr_signal(msk, remaining, &rm_list, size)))
+	    !(mptcp_pm_rm_addr_signal(msk, remaining, &rm_list, size, !skb)))
 		return false;
 
+	/* without skb, only the size is needed: keep it for the next packet */
+	if (!skb)
+		return true;
+
 	opts->suboptions |= OPTION_MPTCP_RM_ADDR;
 	opts->rm_list = rm_list;
 
@@ -933,7 +938,8 @@ int mptcp_established_options(struct sock *sk, struct sk_buff *skb,
 		total_size += opt_size;
 		remaining -= opt_size;
 		ret = true;
-	} else if (mptcp_established_options_rm_addr(sk, &opt_size, remaining, opts)) {
+	} else if (mptcp_established_options_rm_addr(sk, skb, &opt_size,
+						     remaining, opts)) {
 		total_size += opt_size;
 		remaining -= opt_size;
 		ret = true;
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index cdd62433e0a6..0fb38c257eea 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -1026,7 +1026,8 @@ static int mptcp_rm_addr_len(const struct mptcp_rm_list *rm_list)
 }
 
 bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
-			     struct mptcp_rm_list *rm_list, int *size)
+			     struct mptcp_rm_list *rm_list, int *size,
+			     bool size_only)
 {
 	int ret = false, len;
 	u8 rm_addr;
@@ -1047,9 +1048,12 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 		goto out_unlock;
 
 	*size = len;
+	ret = true;
+	if (size_only)
+		goto out_unlock;
+
 	*rm_list = msk->pm.rm_list_tx;
 	WRITE_ONCE(msk->pm.addr_signal, rm_addr);
-	ret = true;
 
 out_unlock:
 	spin_unlock_bh(&msk->pm.lock);
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 9febcaf84762..2c9a442dacd6 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -1248,7 +1248,8 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, int *size, int remaining,
 			      struct mptcp_addr_info *addr, bool *echo,
 			      bool *drop_ts);
 bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
-			     struct mptcp_rm_list *rm_list, int *len);
+			     struct mptcp_rm_list *rm_list, int *len,
+			     bool size_only);
 int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
 bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc);
 int mptcp_pm_nl_dump_addr(struct sk_buff *msg,

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 08/62] mptcp: arm the rtx timer if a push leaves data behind
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (6 preceding siblings ...)
  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 ` 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)
                   ` (53 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

In a memory shortage, send() on an idle MPTCP socket can succeed but
leave its data unsent, and the connection stays stalled after the
shortage has ended.

send() puts its data in the write queue of the MPTCP socket, and the
push to a subflow leaves the data there if the memory charge to the
subflow is refused or no skb can be allocated. A push that leaves data
in the write queue has to be tried again, on the acknowledgment of data
in flight or from the handler of the MPTCP retransmission (rtx) timer.
But __mptcp_push_pending() and __mptcp_subflow_push_pending() arm that
timer only if they have pushed data, so with no data in flight and no
timer pending, the data waits for another event, such as the next
send().

The fix used here is to also arm the timer, in both functions, if unsent
data is left in the write queue.

This does not help a socket that has fallen back to TCP, as its rtx
timer is disabled since commit e2ab913f68c7 ("mptcp: do not reschedule
the RTX timer for fallback sockets"). "mptcp: force the charge for the
first skb of a subflow" avoids a refused charge in this case, but not a
failed skb allocation.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch,
with fault injection: one skb allocation made to fail during a send().
Without this patch, the data accepted by this send() was only sent with
the next one, 60 seconds later here:

  3.007 s: CLIENT send() of 1,000 bytes returned 1000. Allocations that were made to fail in it: 1
  [...]
  63.008 s: CLIENT the second send(), of 100 bytes, returned 100
  63.008 s: SERVER has 1200 bytes
  RESULT-FAILSLAB [...] the_1000_bytes_at_the_server_at=never [...]
  [...] arrived_before_the_second_send=no [...]

Fixes: 2ea6190f42d0 ("mptcp: schedule rtx timer only after pushing data")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comment. Commit message: sockets that fell back to TCP are not
  covered + how the issue was found, and its symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Note (Clashiko on v1): timer_ival cannot be 0 here in net: the in-kernel
scheduler sets it before it can fail, and the timer is disabled after a
fallback. Only the BPF schedulers, not in net, are affected.
---
 net/mptcp/protocol.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 54782bdce5fb..fa3d0522a696 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1850,14 +1850,11 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags)
 	if (ssk)
 		mptcp_push_release(ssk, &info);
 
-	/* Avoid scheduling the rtx timer if no data has been pushed; the timer
-	 * will be updated on positive acks by __mptcp_cleanup_una().
-	 */
-	if (copied) {
-		if (!mptcp_rtx_timer_pending(sk))
-			mptcp_reset_rtx_timer(sk);
+	/* also retry later if unsent data is left: no ack may trigger it */
+	if ((copied || mptcp_send_head(sk)) && !mptcp_rtx_timer_pending(sk))
+		mptcp_reset_rtx_timer(sk);
+	if (copied)
 		mptcp_check_send_data_fin(sk);
-	}
 }
 
 static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk, bool first)
@@ -1919,13 +1916,15 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk, bool
 	if (copied) {
 		tcp_push(ssk, 0, info.mss_now, tcp_sk(ssk)->nonagle,
 			 info.size_goal);
-		if (!mptcp_rtx_timer_pending(sk))
-			mptcp_reset_rtx_timer(sk);
 
 		if (msk->snd_data_fin_enable &&
 		    msk->snd_nxt + 1 == msk->write_seq)
 			mptcp_schedule_work(sk);
 	}
+
+	/* see __mptcp_push_pending() */
+	if ((copied || mptcp_send_head(sk)) && !mptcp_rtx_timer_pending(sk))
+		mptcp_reset_rtx_timer(sk);
 }
 
 static int mptcp_disconnect(struct sock *sk, int flags);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 09/62] mptcp: force the charge for the first skb of a subflow
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (7 preceding siblings ...)
  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 ` 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)
                   ` (52 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

After a fallback to TCP, an MPTCP connection can stay stalled once TCP
memory use is back below the hard limit of net.ipv4.tcp_mem, and above
that limit send() on an idle MPTCP socket can leave its data unsent.

A push moves data from the write queue of the MPTCP socket to a subflow,
and charges the subflow twice: for a new skb in __mptcp_alloc_tx_skb()
and for the payload in mptcp_sendmsg_frag(). On an idle socket, with
nothing queued, TCP forces both charges past the limit, in
tcp_stream_alloc_skb() and tcp_wmem_schedule(), since no ACK would ever
restart such a socket. But a push forces neither, so above the hard
limit both can be refused, and the push then moves no data.

The earlier commit "mptcp: arm the rtx timer if a push leaves data
behind" repeats such a push from the MPTCP retransmission (rtx) timer.
But each attempt fails while memory use stays above the limit. After a
fallback that timer is disabled, so the data stays unsent until another
event, such as the next send(), repeats the push.

The fix used here is to:
- force the charge for the skb if the subflow has nothing queued
- charge the payload with tcp_wmem_schedule()
- send only the bytes that tcp_wmem_schedule() grants

The first skb of an MPTCP-level reinjection is then forced too, as it is
sent on a subflow with nothing queued. This is bounded the same way.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch:
a TCP memory shortage, for 30 seconds, during which each of ten idle
MPTCP clients calls send() once. Without this patch, only 5 of them had
their answer during the shortage, versus 8 with it: the 2 others are
blocked in send() during the shortage, which is not fixed here. Some
answers only came after the next send(), 300 seconds later, because of
the issue fixed by the previous commit:

  IDLE label=behind-the-second-send t=338.9 conn=0 [...] answer_at=336.4
  IDLE label=behind-the-second-send t=338.9 conn=1 [...] answer_at=4.2

Fixes: 724cfd2ee8aa ("mptcp: allocate TX skbs in msk context")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comments. Commit message: the first skb of a reinjection is
  forced too + how the issue was found, and its symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Note (Sashiko on v1): info.mss_now and size_goal cannot be stale in net:
the in-kernel scheduler only picks a subflow that can send, which can
then only move to TCP_CLOSE, where tcp_push() does nothing.
---
 net/mptcp/protocol.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index fa3d0522a696..90fbfb258b79 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1387,13 +1387,17 @@ static struct sk_buff *__mptcp_alloc_tx_skb(struct sock *sk, struct sock *ssk, g
 	if (!skb)
 		return NULL;
 
-	if (likely(sk_wmem_schedule(ssk, skb->truesize))) {
-		tcp_skb_entail(ssk, skb);
-		return skb;
+	/* like TCP, force the charge if nothing is queued */
+	if (tcp_rtx_and_write_queues_empty(ssk)) {
+		sk_forced_mem_schedule(ssk, skb->truesize);
+	} else if (unlikely(!sk_wmem_schedule(ssk, skb->truesize))) {
+		tcp_skb_tsorted_anchor_cleanup(skb);
+		kfree_skb(skb);
+		return NULL;
 	}
-	tcp_skb_tsorted_anchor_cleanup(skb);
-	kfree_skb(skb);
-	return NULL;
+
+	tcp_skb_entail(ssk, skb);
+	return skb;
 }
 
 static struct sk_buff *mptcp_alloc_tx_skb(struct sock *sk, struct sock *ssk, bool data_lock_held)
@@ -1449,6 +1453,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 	bool reuse_skb = true;
 	struct sk_buff *skb;
 	size_t copy;
+	int avail;
 	int i;
 
 	pr_debug("msk=%p ssk=%p sending dfrag at seq=%llu len=%u already sent=%u\n",
@@ -1522,10 +1527,14 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 	}
 
 	copy = min_t(size_t, copy, info->limit - info->sent);
-	if (!sk_wmem_schedule(ssk, copy)) {
+
+	/* like TCP, allow some progress up to tcp_wmem[0] */
+	avail = tcp_wmem_schedule(ssk, copy);
+	if (avail <= 0) {
 		tcp_remove_empty_skb(ssk);
 		return -ENOMEM;
 	}
+	copy = avail;
 
 	if (can_coalesce) {
 		skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 10/62] mptcp: leave an orphan's DATA_FIN to the worker
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (8 preceding siblings ...)
  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 ` 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)
                   ` (51 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

Closed MPTCP sockets can leak until reboot, with the data in their
receive queues, which can exhaust tcp_mem and stall other TCP
connections.

Once close() has returned, only mptcp_worker() destroys an orphaned msk,
and only in the run that moves it to TCP_CLOSE: a later run returns at
once, and mptcp_schedule_work() queues no work for an msk in that state.
The receive path, in softirq, puts data on the backlog while the msk is
owned, and release_sock() calls mptcp_release_cb(), which passes the
backlog to __mptcp_move_skbs(). But __mptcp_move_skbs() calls
mptcp_check_data_fin(), which can move the msk to TCP_CLOSE, and by then
the lock owner, here the worker, no longer looks at the state:

    receive path, softirq             mptcp_worker()
    =====================             ==============
                                      not in TCP_CLOSE: no destroy
    last data, with the DATA_FIN
      the msk is owned: backlog
                                      release_sock()
                                        mptcp_release_cb()
                                          __mptcp_move_skbs()
                                            mptcp_check_data_fin()
                                              TCP_CLOSE, never destroyed

The fix used here is to queue the worker in __mptcp_move_skbs() if an
orphaned msk has a DATA_FIN to handle, instead of calling
mptcp_check_data_fin().

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch:
200,000 connections in which the server accept()s and close()s, while
the client reads the end of file, sends one byte, and closes. Without
this patch, some MPTCP sockets of the server stayed in the CLOSE state
for good, with their network namespace:

  === connections so far : MPTCP sockets of the server in the state CLOSE: 200000:722,
  [...]
  RESULT [...] | left 300 s behind the end: slab_MPTCP=722 sockets_MPTCP=722 [...]
  [...] | veth_end_left=1 slab_net_namespace_left=2 | [...]

Fixes: bc68b0efa1bf ("mptcp: move the whole rx path under msk socket lock protection")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comment. Commit message: how the issue was found, and its
  symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/protocol.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 90fbfb258b79..803ed1f9c413 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2364,9 +2364,15 @@ static bool __mptcp_move_skbs(struct sock *sk, struct list_head *skbs, u32 *delt
 	}
 
 	__mptcp_ofo_queue(msk);
-	if (moved)
-		mptcp_check_data_fin((struct sock *)msk);
-	return moved;
+	if (!moved)
+		return false;
+
+	/* Only the worker can close an orphan, as it must then destroy it */
+	if (!sock_flag(sk, SOCK_DEAD))
+		mptcp_check_data_fin(sk);
+	else if (mptcp_pending_data_fin(sk, NULL))
+		mptcp_schedule_work(sk);
+	return true;
 }
 
 static bool mptcp_can_spool_backlog(struct sock *sk, struct list_head *skbs)

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 11/62] mptcp: don't leak an orphan when the PM closes its last subflow
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (9 preceding siblings ...)
  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 ` 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)
                   ` (50 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

Once close() has returned, an orphaned MPTCP socket is only destroyed by
mptcp_worker(), in the run that sees it in TCP_CLOSE: later on, the
worker returns at once for an msk in this state, and
mptcp_schedule_work() no longer queues it.

__mptcp_close_ssk() moves an orphan to TCP_CLOSE when, after the closure
of a subflow, only the initial one remains, and it is closed. This
function is not only called by the worker: path manager commands also
close subflows of any msk of the netns, orphans included, under the msk
lock: e.g. 'ip mptcp endpoint delete' or 'flush' with the in-kernel PM,
or MPTCP_PM_CMD_SUBFLOW_DESTROY with the userspace one. In this case,
nothing destroys the orphan: it stays in TCP_CLOSE until the reboot,
with its token, its initial subflow, and its reference to the netns,
which is then never freed.

This can happen when the initial subflow has been reset or has timed
out, and the connection is closed -- the orphan then waits for the end
of the DATA_FIN exchange, up to TCP_TIMEWAIT_LEN -- before the endpoint
used by another subflow is removed, e.g. when an interface goes down.

Only the worker can close an orphan, as it must then destroy it. So
here, mark its close timeout as expired, and queue the worker, like it
is done for an msk in the accept queue. The worker then closes the
orphan with mptcp_do_fastclose() -- nothing is sent: the only subflow
left is closed -- and destroys it. If __mptcp_close_ssk() was called by
the worker, this happens later in the same run.

This issue has been found by an AI code review agent, while reviewing
the code of the commit "mptcp: leave an orphan's DATA_FIN to the
worker", and confirmed with a new Packetdrill test: the initial subflow
of an orphan waiting for the end of the DATA_FIN exchange is reset, then
the endpoint of the other subflow is removed. Without this patch, the
orphan stayed:

  UNCONN 0      0      192.168.0.1:8080 192.0.2.1:39933
  kernel_orphan_last_subflow.pkt:39: error executing `! ss -HMan | grep -v LISTEN` command: non-zero status 1

Fixes: 27e5ccc2d5a5 ("mptcp: fix dangling connection hang-up")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/protocol.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 803ed1f9c413..d64e04245963 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2795,8 +2795,13 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 	 */
 	if (list_is_singular(&msk->conn_list) && msk->first &&
 	    inet_sk_state_load(msk->first) == TCP_CLOSE) {
-		if (sk->sk_state != TCP_ESTABLISHED ||
-		    msk->in_accept_queue || sock_flag(sk, SOCK_DEAD)) {
+		if (sock_flag(sk, SOCK_DEAD)) {
+			/* let the worker close and destroy the orphan */
+			mptcp_set_close_tout(sk, tcp_jiffies32 -
+					     (mptcp_close_timeout(sk) + 1));
+			mptcp_schedule_work(sk);
+		} else if (sk->sk_state != TCP_ESTABLISHED ||
+			   msk->in_accept_queue) {
 			mptcp_set_state(sk, TCP_CLOSE);
 			mptcp_close_wake_up(sk);
 		} else {

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 12/62] mptcp: keep an orphan while it can send its data
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (10 preceding siblings ...)
  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 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 13/62] mptcp: limit an orphan probing a zero window Matthieu Baerts (NGI0)
                   ` (49 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

The close timeout of an orphaned MPTCP socket started at close(), and
its expiry reset the connection, while some data could still be waiting
for the peer to open its window: a peer reading slowly or pausing got a
reset 60 seconds after close(), and lost the end of the data, while TCP
delivers it.

This timeout is there for the DATA_FIN exchange, see commit d866ae9aaa43
("mptcp: add a new sysctl for make after break timeout"), and for an
orphan that can no longer send anything. So restart it when the DATA_FIN
is sent, and when it expires before, as long as a subflow can still send
the data, which is then pushed again: an established subflow, on which
the peer acked something recently, at least the window probes. Until
then, as for a TCP socket that is not orphaned, nothing limits how long
the peer can keep its window closed, while it acks the window probes.
The timeout still starts at close(): the subflows are not TCP orphans,
so its expiry is the only check that the orphan can still send.

This was reported on GitHub, with a reproducer: a server writes 2 MB,
then calls close(), while the client pauses before reading the rest.
After a pause of 90 seconds, the client got ECONNRESET, while TCP
delivered everything, as MPTCP now does. If the client vanishes instead,
the orphan is now reset as TCP does.

Fixes: e16163b6e2b7 ("mptcp: refactor shutdown and close")
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/647
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for issue #647 reported on GitHub
---
 net/mptcp/protocol.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index d64e04245963..944c9d11d211 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2871,6 +2871,28 @@ static bool mptcp_close_tout_expired(const struct sock *sk)
 		  inet_csk(sk)->icsk_mtup.probe_timestamp + mptcp_close_timeout(sk));
 }
 
+/* Before its DATA_FIN, keep an orphan while a subflow can send its data */
+static bool mptcp_orphan_keep(struct sock *sk)
+{
+	struct mptcp_sock *msk = mptcp_sk(sk);
+	struct mptcp_subflow_context *subflow;
+
+	if (!sock_flag(sk, SOCK_DEAD) || msk->snd_nxt == msk->write_seq)
+		return false;
+
+	mptcp_for_each_subflow(msk, subflow) {
+		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+
+		/* a live peer acks at least the probes, every TCP_RTO_MAX */
+		if (__mptcp_subflow_active(subflow) &&
+		    tcp_jiffies32 - READ_ONCE(tcp_sk(ssk)->rcv_tstamp) <
+		    2 * TCP_RTO_MAX)
+			return true;
+	}
+
+	return false;
+}
+
 static void mptcp_check_fastclose(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow, *tmp;
@@ -3208,6 +3230,11 @@ static void mptcp_worker(struct work_struct *work)
 	if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags))
 		__mptcp_close_subflow(sk);
 
+	if (mptcp_close_tout_expired(sk) && mptcp_orphan_keep(sk)) {
+		mptcp_start_tout_timer(sk);
+		__mptcp_push_pending(sk, 0);
+	}
+
 	if (mptcp_close_tout_expired(sk)) {
 		struct mptcp_subflow_context *subflow, *tmp;
 
@@ -3449,6 +3476,10 @@ static void mptcp_check_send_data_fin(struct sock *sk)
 
 	WRITE_ONCE(msk->snd_nxt, msk->write_seq);
 
+	/* an orphan's close timeout is for the DATA_FIN exchange */
+	if (sock_flag(sk, SOCK_DEAD))
+		mptcp_start_tout_timer(sk);
+
 	mptcp_for_each_subflow(msk, subflow) {
 		struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow);
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 13/62] mptcp: limit an orphan probing a zero window
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (11 preceding siblings ...)
  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-21  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 14/62] mptcp: count orphans as TCP does Matthieu Baerts (NGI0)
                   ` (48 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

Since the previous commit, an orphan with data to send is kept while
the peer acks something, at least the window probes: a peer keeping its
window closed, e.g. not reading, could then keep the orphan forever.

TCP limits this for its orphans: tcp_probe_timer() aborts them instead
of probing again after the max interval. The subflows of an MPTCP orphan
are not orphaned: they probe again then, and back off once more, up to
tcp_retries2. So check if TCP would have aborted them, when the close
timeout expires. Same with data in flight, when the peer has shrunk its
window to zero: tcp_retransmit_timer() only aborts orphans then.

Two corner cases needing non-default settings are not covered, which is
fine: an idle subflow refreshed by keepalives still keeps the orphan
when the stale detection is disabled, and tcp_orphan_retries is ignored.

This was found by an AI code review agent, while reviewing the previous
commit. With its reproducer and a long pause, the orphan was kept until
the end of the pause. It is now reset as TCP does, respecting
tcp_retries2.

Note for the backports: this patch is needed with the previous one, and
before v6.15, tcp_rto_max() can be replaced by TCP_RTO_MAX.

Fixes: e16163b6e2b7 ("mptcp: refactor shutdown and close")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, to limit the orphans kept by the previous patch, with the same
    Fixes tag to backport them together.
---
 net/mptcp/protocol.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 944c9d11d211..ff71f1954077 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2871,6 +2871,32 @@ static bool mptcp_close_tout_expired(const struct sock *sk)
 		  inet_csk(sk)->icsk_mtup.probe_timestamp + mptcp_close_timeout(sk));
 }
 
+/* Would TCP abort this subflow if it were an orphan probing a zero window? */
+static bool mptcp_subflow_probe_timed_out(struct sock *ssk)
+{
+	u8 retries2 = READ_ONCE(sock_net(ssk)->ipv4.sysctl_tcp_retries2);
+	struct inet_connection_sock *icsk = inet_csk(ssk);
+	const struct tcp_sock *tp = tcp_sk(ssk);
+	unsigned long limit;
+	bool slow, ret;
+	u64 when;
+
+	slow = lock_sock_fast_nested(ssk);
+	limit = tcp_rto_max(ssk);
+	if (tp->packets_out) {
+		ret = !tp->snd_wnd && icsk->icsk_rto >= limit;
+	} else {
+		if (icsk->icsk_backoff < retries2)
+			limit *= 2;
+		/* a shift of 32 already exceeds the limit */
+		when = (u64)icsk->icsk_rto << min_t(u8, icsk->icsk_backoff, 32);
+		ret = tcp_send_head(ssk) && when >= limit;
+	}
+	unlock_sock_fast(ssk, slow);
+
+	return ret;
+}
+
 /* Before its DATA_FIN, keep an orphan while a subflow can send its data */
 static bool mptcp_orphan_keep(struct sock *sk)
 {
@@ -2886,7 +2912,8 @@ static bool mptcp_orphan_keep(struct sock *sk)
 		/* a live peer acks at least the probes, every TCP_RTO_MAX */
 		if (__mptcp_subflow_active(subflow) &&
 		    tcp_jiffies32 - READ_ONCE(tcp_sk(ssk)->rcv_tstamp) <
-		    2 * TCP_RTO_MAX)
+		    2 * TCP_RTO_MAX &&
+		    !mptcp_subflow_probe_timed_out(ssk))
 			return true;
 	}
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 14/62] mptcp: count orphans as TCP does
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (12 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 13/62] mptcp: limit an orphan probing a zero window Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 15/62] mptcp: return EOF after a DATA_FIN, " Matthieu Baerts (NGI0)
                   ` (47 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

The MPTCP sockets orphaned by close() were not counted in
tcp_orphan_count, contrary to TCP: tcp_max_orphans did not limit them,
and they were not visible in /proc/net/sockstat.

This is all the more needed since commit "mptcp: keep an orphan while it
can send its data": an orphan can then be kept longer than its close
timeout, e.g., as Sashiko noticed, by a peer acking the data at the TCP
level only, without moving the DATA_ACK.

Count them, and as TCP does, reset an orphan when there are too many
orphans, or when TCP uses too much memory: at close(), and when its
close timeout expires while it is kept to send its data. This is similar
to what tcp_out_of_resources() does from the TCP timers, without the
stricter limit for the stalled orphans. These resets are counted in
TCPAbortOnMemory, not in a new MPTCP counter: the MPTCP orphans now
share the TCP orphan count and limits.

This has been found by a review agent, and validated with a script
closing 8 connections whose peer doesn't read, with tcp_max_orphans set
to 4: the MPTCP orphans were all kept, without being counted, while
other orphans were reset. Now, only 5 or 6 are kept, vs 4 or 5 with TCP,
which also checks the limit from the timers of its orphans.

Fixes: e16163b6e2b7 ("mptcp: refactor shutdown and close")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, spotted by a review agent
---
 net/mptcp/protocol.c | 24 ++++++++++++++++++++++--
 net/mptcp/protocol.h |  1 +
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index ff71f1954077..9e297fa08bfe 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2897,6 +2897,16 @@ static bool mptcp_subflow_probe_timed_out(struct sock *ssk)
 	return ret;
 }
 
+/* As TCP orphans: limited in number and memory */
+static bool mptcp_orphan_oom(struct sock *sk)
+{
+	if (!tcp_check_oom(sk, 0))
+		return false;
+
+	NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY);
+	return true;
+}
+
 /* Before its DATA_FIN, keep an orphan while a subflow can send its data */
 static bool mptcp_orphan_keep(struct sock *sk)
 {
@@ -2914,7 +2924,7 @@ static bool mptcp_orphan_keep(struct sock *sk)
 		    tcp_jiffies32 - READ_ONCE(tcp_sk(ssk)->rcv_tstamp) <
 		    2 * TCP_RTO_MAX &&
 		    !mptcp_subflow_probe_timed_out(ssk))
-			return true;
+			return !mptcp_orphan_oom(sk);
 	}
 
 	return false;
@@ -3547,6 +3557,9 @@ static void __mptcp_destroy_sock(struct sock *sk)
 	sk_stream_kill_queues(sk);
 	xfrm_sk_free_policy(sk);
 
+	if (test_and_clear_bit(MPTCP_ORPHAN_COUNTED, &msk->flags))
+		tcp_orphan_count_dec();
+
 	sock_put(sk);
 }
 
@@ -3636,8 +3649,15 @@ bool __mptcp_close(struct sock *sk, long timeout)
 	/* all the subflows are closed, only timeout can change the msk
 	 * state, let's not keep resources busy for no reasons
 	 */
-	if (subflows_alive == 0)
+	if (subflows_alive == 0) {
 		mptcp_set_state(sk, TCP_CLOSE);
+	} else if (sk->sk_state != TCP_CLOSE) {
+		/* as TCP orphans: counted, and limited */
+		tcp_orphan_count_inc();
+		set_bit(MPTCP_ORPHAN_COUNTED, &msk->flags);
+		if (mptcp_orphan_oom(sk))
+			mptcp_do_fastclose(sk);
+	}
 
 	sock_hold(sk);
 	pr_debug("msk=%p state=%d\n", sk, sk->sk_state);
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 2c9a442dacd6..888ee9d66967 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -117,6 +117,7 @@
 #define MPTCP_FALLBACK_DONE	2
 #define MPTCP_WORK_CLOSE_SUBFLOW 3
 #define MPTCP_RTX_ENABLED	4
+#define MPTCP_ORPHAN_COUNTED	5
 
 /* MPTCP socket release cb flags */
 #define MPTCP_PUSH_PENDING	1

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 15/62] mptcp: return EOF after a DATA_FIN, as TCP does
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (13 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 14/62] mptcp: count orphans as TCP does Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21 10:25   ` sashiko-bot
  2026-11-21  9:41 ` [PATCH mptcp-net v2 16/62] mptcp: let TCP send orphan data after fallback Matthieu Baerts (NGI0)
                   ` (46 subsequent siblings)
  61 siblings, 1 reply; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

Once an MPTCP socket has received a DATA_FIN, recv() returns the
remaining data, then EOF. But if the connection was then reset, e.g. by
an MP_FASTCLOSE, recv() returned an error after the data, e.g. EPIPE,
instead of EOF as TCP does. A proxy resetting the other connection on
read errors then dropped the data it still had to forward.

As TCP does with a FIN, set SOCK_DONE when processing the DATA_FIN, and
check it before the socket error in recvmsg(). With an MP_FASTCLOSE, the
data still in the backlog is moved first, not to miss the DATA_FIN.
After a fallback, a DATA_FIN is also emulated after a reset: only set
SOCK_DONE after a FIN, not to hide a reset behind an EOF.

This was reported on GitHub, and is validated with new Packetdrill
tests: data and a DATA_FIN are received, then an MP_FASTCLOSE; and
after a fallback, data, a FIN and a reset. Without this patch, the
second read() returned EPIPE in both cases:

  receive_fastclose_after_data_fin.pkt:27: runtime error in read call: Expected result 0 but got -1 with errno 32 (Broken pipe)
  v1_connect_tcpfallback_fin_reset.pkt:19: runtime error in read call: Expected result 0 but got -1 with errno 32 (Broken pipe)

Note for the backports: the issue with an MP_FASTCLOSE comes from commit
69800e516e96 ("mptcp: propagate fastclose error"), in v6.1. Before that,
the modifications in mptcp_check_fastclose() and mptcp_disconnect() are
not needed.

Fixes: 15cc10453398 ("mptcp: deliver ssk errors to msk")
Link: https://github.com/multipath-tcp/mptcp_net-next/issues/647
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for issue #647 reported on GitHub
---
 net/mptcp/protocol.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 9e297fa08bfe..91639ae0c8a0 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -714,6 +714,10 @@ static void mptcp_check_data_fin(struct sock *sk)
 		WRITE_ONCE(msk->rcv_data_fin, 0);
 
 		WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | RCV_SHUTDOWN);
+		/* on fallback, also emulated after a reset: check for a FIN */
+		if (!__mptcp_check_fallback(msk) ||
+		    (msk->first && sock_flag(msk->first, SOCK_DONE)))
+			sock_set_flag(sk, SOCK_DONE);
 		smp_mb__before_atomic(); /* SHUTDOWN must be visible first */
 
 		switch (sk->sk_state) {
@@ -972,6 +976,9 @@ static bool __mptcp_subflow_error_report(struct sock *sk, struct sock *ssk)
 	 * destroy the msk as needed.
 	 */
 	ssk_state = inet_sk_state_load(ssk);
+	/* a FIN received before still leads to EOF, as with TCP */
+	if (sock_flag(ssk, SOCK_DONE) && mptcp_pending_data_fin(sk, NULL))
+		sock_set_flag(sk, SOCK_DONE);
 	if (ssk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DEAD))
 		mptcp_set_state(sk, ssk_state);
 	WRITE_ONCE(sk->sk_err, -err);
@@ -2494,6 +2501,9 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 			    !timeo)
 				break;
 		} else {
+			if (sock_flag(sk, SOCK_DONE))
+				break;
+
 			copied = sock_error(sk);
 			if (copied)
 				break;
@@ -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) {
@@ -3797,6 +3812,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)
 	atomic64_set(&msk->rcv_wnd_sent, 0);
 
 	WRITE_ONCE(sk->sk_shutdown, 0);
+	sock_reset_flag(sk, SOCK_DONE);
 	sk_error_report(sk);
 	return 0;
 }

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 16/62] mptcp: let TCP send orphan data after fallback
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (14 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 15/62] mptcp: return EOF after a DATA_FIN, " Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 17/62] mptcp: reset the subflow on abort " Matthieu Baerts (NGI0)
                   ` (45 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

After a fallback to TCP, once an orphaned MPTCP socket has given all its
data and the FIN to the subflow, the rest of the transfer is in the
hands of TCP. But when the close timeout expired, the subflow was reset,
and the data it still had was lost, e.g. with a peer reading slowly,
while TCP sends it, within the limits set for its orphans.

Close the MPTCP socket without reset in this case: the subflow is then
closed as after a graceful close, and TCP sends the remaining data.
Unless data received after close() has not been read: as in
__mptcp_close(), a reset is then needed.

This issue has been found by an AI code review agent, while validating a
fix for a similar issue, and confirmed with the reproducer from the
linked GitHub issue, adapted to a fallback: the writer is an MPTCP
client connected to a TCP server. The server got ECONNRESET after its
pause, while it gets everything with a TCP client, and now with an MPTCP
one too.

Fixes: d21f83485518 ("mptcp: use fastclose on more edge scenarios")
Link: https://github.com/multipath-tcp/mptcp_net-next/issues/647
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for a similar issue found by a review agent
---
 net/mptcp/protocol.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 91639ae0c8a0..541bf23d1bda 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2940,6 +2940,18 @@ static bool mptcp_orphan_keep(struct sock *sk)
 	return false;
 }
 
+/* On fallback, TCP can send what an orphan gave to the subflow. As in
+ * __mptcp_close(), unread data requires a reset, also in the backlog.
+ */
+static bool mptcp_orphan_handover(const struct sock *sk)
+{
+	const struct mptcp_sock *msk = mptcp_sk(sk);
+
+	return sock_flag(sk, SOCK_DEAD) && __mptcp_check_fallback(msk) &&
+	       msk->snd_nxt == msk->write_seq && !mptcp_data_avail(msk) &&
+	       !READ_ONCE(msk->backlog_len);
+}
+
 static void mptcp_check_fastclose(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow, *tmp;
@@ -3287,6 +3299,10 @@ static void mptcp_worker(struct work_struct *work)
 		__mptcp_push_pending(sk, 0);
 	}
 
+	/* TCP will close the subflow, as with its own orphans */
+	if (mptcp_close_tout_expired(sk) && mptcp_orphan_handover(sk))
+		mptcp_set_state(sk, TCP_CLOSE);
+
 	if (mptcp_close_tout_expired(sk)) {
 		struct mptcp_subflow_context *subflow, *tmp;
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 17/62] mptcp: reset the subflow on abort after fallback
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (15 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 16/62] mptcp: let TCP send orphan data after fallback Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 18/62] mptcp: wake up blocked senders when no sf left Matthieu Baerts (NGI0)
                   ` (44 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

After a fallback to TCP, closing an MPTCP socket with unread data, or
with SO_LINGER and a zero timeout, did not reset the connection as TCP
does: the data still in the MPTCP send queue was dropped, and the
subflow was closed with a FIN. The peer then got a truncated stream,
followed by EOF, without error.

mptcp_do_fastclose() sends a reset on each subflow, except after a
fallback: send it in this case too. No MPTCP option is added after a
fallback: this is a plain TCP reset. Its other callers, on disconnect()
and when the close timeout of an orphan expires, were already resetting
the subflow after a fallback, via tcp_disconnect(), in most states: the
reset is now sent as without a fallback.

This issue has been found by an AI code review agent, while reviewing
another fix, and confirmed with a new Packetdrill test: an MPTCP client
falls back to TCP, receives data, and closes the socket without reading
it. Without this patch, a FIN was sent instead of a reset:

  v1_connect_tcpfallback_close_unread_data.pkt:19: error handling packet: live packet field tcp_fin: expected: 0 (0x0) vs actual: 1 (0x1)

Fixes: ae155060247b ("mptcp: fix duplicate reset on fastclose")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue found by a review agent
---
 net/mptcp/protocol.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 541bf23d1bda..201e77772bdd 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3245,10 +3245,7 @@ static void mptcp_do_fastclose(struct sock *sk)
 	mptcp_backlog_purge(sk);
 	msk->fastclosing = 1;
 
-	/* Explicitly send the fastclose reset as need */
-	if (__mptcp_check_fallback(msk))
-		return;
-
+	/* Explicitly send the fastclose reset, a plain one after a fallback */
 	mptcp_for_each_subflow_safe(msk, subflow, tmp) {
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 18/62] mptcp: wake up blocked senders when no sf left
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (16 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 17/62] mptcp: reset the subflow on abort " Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` 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)
                   ` (43 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

When an MPTCP socket moves to TCP_CLOSE because its last subflow is
closed, after the close timeout or not, sk_shutdown was not updated, and
no error was set in most cases. A thread blocked in send() was then
never woken up for good.

Set SEND_SHUTDOWN in these cases: no more data can be sent. The blocked
send() then returns EPIPE, as a send() called after the close timeout
already does. Reporting another error first, e.g. ETIMEDOUT as TCP does
after a timeout, would change the behaviour seen by the applications:
this is left for net-next.

This was reported on GitHub, with a reproducer: the only subflow dies by
RTO, and send() was never woken up, while it returned ETIMEDOUT after a
few seconds with TCP. With this patch, send() returns EPIPE after the
subflow timeout (like TCP) and the close timeout (by default at 60
seconds). This is also validated with new Packetdrill tests, with the
close timeout, and with a reset received in CLOSE_WAIT. Without this
patch, send() stayed blocked in both cases:

  close_timeout_blocked_send.pkt:24: runtime error: exiting while a blocking system call is in progress
  close_wait_reset_blocked_send.pkt:25: runtime error: exiting while a blocking system call is in progress

Fixes: 27e5ccc2d5a5 ("mptcp: fix dangling connection hang-up")
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/648
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for issue #648 reported on GitHub
---
 net/mptcp/protocol.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 201e77772bdd..b0f8a3d2e8b7 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2813,6 +2813,8 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 		} else if (sk->sk_state != TCP_ESTABLISHED ||
 			   msk->in_accept_queue) {
 			mptcp_set_state(sk, TCP_CLOSE);
+			WRITE_ONCE(sk->sk_shutdown,
+				   sk->sk_shutdown | SEND_SHUTDOWN);
 			mptcp_close_wake_up(sk);
 		} else {
 			mptcp_start_tout_timer(sk);
@@ -3306,6 +3308,7 @@ static void mptcp_worker(struct work_struct *work)
 		mptcp_do_fastclose(sk);
 		mptcp_for_each_subflow_safe(msk, subflow, tmp)
 			__mptcp_close_ssk(sk, subflow->tcp_sock, subflow, 0);
+		WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN);
 		mptcp_close_wake_up(sk);
 	}
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 19/62] mptcp: set SEND_SHUTDOWN on close by an sf error
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (17 preceding siblings ...)
  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 ` 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)
                   ` (42 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

After a fallback to TCP, or during the MPC connection, an error on a
subflow is propagated to the MPTCP socket, which moves to TCP_CLOSE.
But sk_shutdown was not updated, while tcp_done() does it. A thread
blocked in send() was then only woken up by the socket error: if
another thread consumed it first, the sender went back to sleep, for
good.

Set SEND_SHUTDOWN here too, after the error, as tcp_done_with_error()
does, not to have poll() reporting a close without error in between.
Setting RCV_SHUTDOWN, as tcp_done() does, would change what recv()
returns once the error has been consumed: this is left for net-next.

This issue has been found by an AI code review agent, while fixing a
similar issue, and confirmed with a reproducer: after a fallback to TCP,
a thread reads and another one writes on the same socket, until the peer
resets the connection. A part of the writers were then still blocked in
send(), and none with TCP or with this patch.

Fixes: 15cc10453398 ("mptcp: deliver ssk errors to msk")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for a similar issue found by a review agent
---
 net/mptcp/protocol.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index b0f8a3d2e8b7..835796fd4f77 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -979,9 +979,13 @@ static bool __mptcp_subflow_error_report(struct sock *sk, struct sock *ssk)
 	/* a FIN received before still leads to EOF, as with TCP */
 	if (sock_flag(ssk, SOCK_DONE) && mptcp_pending_data_fin(sk, NULL))
 		sock_set_flag(sk, SOCK_DONE);
-	if (ssk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DEAD))
-		mptcp_set_state(sk, ssk_state);
 	WRITE_ONCE(sk->sk_err, -err);
+	if (ssk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DEAD)) {
+		/* This barrier is coupled with smp_rmb() in mptcp_poll() */
+		smp_wmb();
+		WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN);
+		mptcp_set_state(sk, ssk_state);
+	}
 	report = true;
 	propagated = true;
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 20/62] mptcp: start close timeout on initial sf shutdown
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (18 preceding siblings ...)
  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 ` Matthieu Baerts (NGI0)
  2026-11-21 10:20   ` sashiko-bot
  2026-11-21  9:41 ` [PATCH mptcp-net v2 21/62] mptcp: process a DATA_FIN received with old data Matthieu Baerts (NGI0)
                   ` (41 subsequent siblings)
  61 siblings, 1 reply; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

When the initial subflow is closed while it is not in TCP_CLOSE, e.g.
after a FIN without DATA_FIN from the peer, it is only shut down, and
stays in the connection list. The check for an MPTCP socket without
subflows then missed it: it only looks for an initial subflow in
TCP_CLOSE, and when this subflow reaches this state later on,
mptcp_close_ssk() ignores it, as it has already been processed. A
socket still owned by the application then stayed without any usable
subflow, without close timeout nor error, and with blocked send() or
recv() calls, for good.

When only this shut down initial subflow remains, start the close
timeout, if it is not running yet.

This issue has been found by an AI code review agent, while reviewing a
similar fix, and also reported by Sashiko. It has been confirmed with a
new Packetdrill test: the peer closes the only subflow with a FIN,
without DATA_FIN. Without this patch, send() stayed blocked:

  subflow_fin_blocked_send.pkt:26: runtime error: exiting while a blocking system call is in progress

The check only looks at TCP_CLOSE since the commit below, and
mptcp_close_ssk() ignores this subflow in this state since commit
d82809b6c5f2 ("mptcp: avoid duplicated SUB_CLOSED events"), which is in
all the stable versions having the commit below.

Fixes: 27e5ccc2d5a5 ("mptcp: fix dangling connection hang-up")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue found by a review agent, and Sashiko
---
 net/mptcp/protocol.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 835796fd4f77..d3a793e96c9c 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2823,6 +2823,14 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 		} else {
 			mptcp_start_tout_timer(sk);
 		}
+	} else if (list_is_singular(&msk->conn_list) && msk->first &&
+		   mptcp_subflow_ctx(msk->first)->closing &&
+		   !inet_csk(sk)->icsk_mtup.probe_timestamp &&
+		   sk->sk_state != TCP_CLOSE) {
+		/* The initial subflow has only been shut down, and its later
+		 * close will be ignored: start the close timeout now.
+		 */
+		mptcp_start_tout_timer(sk);
 	}
 }
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 21/62] mptcp: process a DATA_FIN received with old data
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (19 preceding siblings ...)
  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  9:41 ` 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)
                   ` (40 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

A DATA_FIN received in a DSS option with a data mapping, or without data
in the middle of a mapping, is recorded by get_mapping_status(), but its
processing was left to the code moving the mapped data to the MPTCP
socket. If this data is old, e.g. the last data retransmitted at the
MPTCP level with the DATA_FIN, it is discarded at the subflow level, and
never moved to the MPTCP socket: the DATA_FIN is then not processed,
while ack_seq has already reached it. Later retransmissions of this
DATA_FIN are ignored too, as it has already been recorded: the peer
might then never get a DATA_ACK for it, and the reader the end of file.

This issue was causing a subtest from mptcp_connect_mmap.sh to fail,
after a spurious MPTCP-level retransmission from the client
(MPTCPRetrans on the client, DuplicateData on the server). The server
had received all the data, its ack_seq being at the DSN of the
DATA_FIN, which was retransmitted 9 times by the client, still in
FIN-WAIT-1:

  26 ns2 MPTCP -> ns4 (dead:beef:3::1:10023) MPTCP     timeout
  (...)
  mptcp ESTAB (...) rcv_nxt:17234557033099169620 (...)
  (...)
  mptcp FIN-WAIT-1 (...) write_seq:17234557033099169621 snd_una:17234557033099169620 (...) retransmits:9 (...)
  (...)
  (duration 61384ms) [FAIL] client exit code 143, server 143

The root cause has been confirmed with new Packetdrill tests: data is
received, then the same data again at the MPTCP level, with the DATA_FIN
in the same DSS option, or in a DSS option without data, in the middle
of this mapping. Without this patch, the DATA_FIN was never acked:

  dss_fin_after_old_data_server.pkt:23: error handling packet: Timed out waiting for packet
  dss_fin_mid_old_mapping_server.pkt:22: error handling packet: Timed out waiting for packet

To fix this, schedule the worker when this DATA_FIN is recorded, as it
is already done for a DATA_FIN without data outside a mapping:
mptcp_check_data_fin() then processes it if ack_seq has already reached
it. If not, it is still processed once the data before it is moved to
the MPTCP socket.

Fixes: 43b54c6ee382 ("mptcp: Use full MPTCP-level disconnect state machine")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue causing a flaky selftest
---
 net/mptcp/subflow.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 20d506235074..0c97a5ce2d0c 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1218,6 +1218,10 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
 			bool updated = mptcp_update_rcv_data_fin(msk, mpext->data_seq,
 								 mpext->dsn64);
 			pr_debug("DATA_FIN with no payload seq=%llu\n", mpext->data_seq);
+			/* The current mapping can be old, and then not moved */
+			if (updated)
+				mptcp_schedule_work((struct sock *)msk);
+
 			if (subflow->map_valid) {
 				/* A DATA_FIN might arrive in a DSS
 				 * option before the previous mapping
@@ -1228,9 +1232,6 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
 				return MAPPING_OK;
 			}
 
-			if (updated)
-				mptcp_schedule_work((struct sock *)msk);
-
 			return MAPPING_DATA_FIN;
 		}
 
@@ -1242,7 +1243,9 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
 		if (!mpext->dsn64)
 			data_fin_seq &= GENMASK_ULL(31, 0);
 
-		mptcp_update_rcv_data_fin(msk, data_fin_seq, mpext->dsn64);
+		/* The mapped data can be old, and then not moved to the msk */
+		if (mptcp_update_rcv_data_fin(msk, data_fin_seq, mpext->dsn64))
+			mptcp_schedule_work((struct sock *)msk);
 		pr_debug("DATA_FIN with mapping seq=%llu dsn64=%d\n",
 			 data_fin_seq, mpext->dsn64);
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 22/62] mptcp: no sf left: process pending MP_FASTCLOSE
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (20 preceding siblings ...)
  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 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 23/62] mptcp: no sf left: process pending DATA_FIN Matthieu Baerts (NGI0)
                   ` (39 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

When the last subflow is closed while the MPTCP socket is no longer in
the ESTABLISHED state, e.g. in CLOSE_WAIT after a DATA_FIN, the MPTCP
socket moves to TCP_CLOSE. But this subflow could have been closed by
a reset carrying an MP_FASTCLOSE, not processed yet: if this reset is
received while the worker is running, after mptcp_check_fastclose(),
and before __mptcp_close_subflow(). At the next run of the worker, the
MPTCP socket being closed, the MP_FASTCLOSE is ignored: no error is
reported, and SEND_SHUTDOWN is not set. With data still to be sent,
poll() then reports EPOLLHUP, but neither EPOLLOUT, nor EPOLLERR.

This issue was causing the "fastclose test" subtest from mptcp_join.sh
to be flaky: after the DATA_FIN from the client, then its MP_FASTCLOSE,
the server, still having data to send, was killed after the timeout,
with its MPTCP socket closed with RCV_SHUTDOWN only (-->):

  timeout
  (...)
  mptcp UNCONN 0      0      [::ffff:10.0.1.1]:10121 [::ffff:10.0.1.2]:45220 (...) -->
     (...) bytes_sent:92032 bytes_received:1024 bytes_acked:57344 (...)
  (...)
  [FAIL] client exit code 0, server 143

The root cause has been confirmed with a debug patch keeping the worker
busy while the socket is in CLOSE_WAIT, until the subflow is closed: the
same failure has been seen, with the socket closed in CLOSE_WAIT (8)
with a pending MP_FASTCLOSE, and without error:

  (...) closed with pending events, state=8 rcv_data_fin=0 rcv_fastclose=1 err=0

To fix this, process a pending MP_FASTCLOSE before the close, if the
socket is still in use. With the same debug patch, this subtest then no
longer failed.

Fixes: 27e5ccc2d5a5 ("mptcp: fix dangling connection hang-up")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue causing a flaky selftest
---
 net/mptcp/protocol.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index d3a793e96c9c..518321aedd1e 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2705,6 +2705,8 @@ static void mptcp_cleanup_ssk_backlog(struct sock *sk, struct sock *ssk)
 	mptcp_data_unlock(sk);
 }
 
+static void mptcp_check_fastclose(struct mptcp_sock *msk);
+
 /* subflow sockets can be either outgoing (connect) or incoming
  * (accept).
  *
@@ -2816,6 +2818,9 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 			mptcp_schedule_work(sk);
 		} else if (sk->sk_state != TCP_ESTABLISHED ||
 			   msk->in_accept_queue) {
+			/* After the close, an MP_FASTCLOSE would be ignored */
+			mptcp_check_fastclose(msk);
+
 			mptcp_set_state(sk, TCP_CLOSE);
 			WRITE_ONCE(sk->sk_shutdown,
 				   sk->sk_shutdown | SEND_SHUTDOWN);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 23/62] mptcp: no sf left: process pending DATA_FIN
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (21 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 22/62] mptcp: no sf left: process pending MP_FASTCLOSE Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21 10:17   ` sashiko-bot
  2026-11-21  9:41 ` [PATCH mptcp-net v2 24/62] mptcp: process pending close events at accept() Matthieu Baerts (NGI0)
                   ` (38 subsequent siblings)
  61 siblings, 1 reply; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

When the last subflow is closed while the MPTCP socket is no longer in
the ESTABLISHED state, e.g. after a shutdown(SHUT_WR), the MPTCP socket
moves to TCP_CLOSE. But the peer's DATA_FIN -- or FIN, after a fallback
to TCP -- might not have been processed yet: e.g. if the last data was
received while the worker owned the MPTCP socket, this data is still in
the backlog, and the DATA_FIN can only be processed once the data before
it is in. When the backlog is spooled later on, mptcp_check_data_fin()
ignores the DATA_FIN, the socket being closed. RCV_SHUTDOWN is then
never set: after the remaining data, poll() reports EPOLLHUP, but
neither EPOLLIN nor EPOLLRDHUP, and recv() returns ENOTCONN instead of
EOF.

Before the commit using the MPTCP-level backlog for the RX path, the
data received while the MPTCP socket was owned was left in the subflow,
and a subflow with data in its receive queue was not closed.

This issue was causing the "Infinite map" subtest from mptcp_join.sh to
be flaky: the server only got EPOLLHUP after having received all the
data, and spun until the timeout:

  timeout
  (...)
  tcp   TIME-WAIT 0      0      [::ffff:10.0.1.1]:10123 [::ffff:10.0.1.2]:51790 (...)
  mptcp UNCONN    0      0      [::ffff:10.0.1.1]:10123 [::ffff:10.0.1.2]:51790 (...)
     (...) fallback (...) bytes_sent:131100 bytes_received:131100 (...)
  (...)
  [FAIL] client exit code 0, server 143

The same issue was causing the 'peek mode' and 'full disconnect'
subtests from mptcp_connect.sh to be flaky, in the MPTCP to TCP cases,
so after a fallback at the connection: the client never got the end of
file:

  64 ns1 MPTCP -> ns1 (10.0.1.1:20002      ) TCP       main_loop_s: timed out
  (...)
  mptcp UNCONN    0      0           10.0.1.1:35046     10.0.1.1:20002 (...) <--
     (...) fallback (...) bytes_sent:714380 bytes_received:714380 (...)
  (...) [FAIL] client exit code 143, server 2

The root cause has been confirmed with a debug patch keeping the worker
in FIN_WAIT2 after a fallback, until the subflow is closed: the same
failures have been seen in the "Infinite map" subtest, and in the 'peek
mode' and 'full disconnect' parts of mptcp_connect.sh, with the socket
closed before the DATA_FIN:

  (...) closed with a pending DATA_FIN, state=5 ack_seq=11784643520213419601 data_fin_seq=11784643520213452397 backlog=35484

To fix this, spool the backlog and process the pending DATA_FIN before
the close, if the socket is still in use. This is done in a new helper,
mptcp_check_rcv_close(), also processing a pending MP_FASTCLOSE: the
next commit uses it at accept() time too. With the same debug patch,
these subtests no longer failed.

Fixes: 6228efe0cc01 ("mptcp: leverage the backlog for RX packet processing")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue causing flaky selftests
---
 net/mptcp/protocol.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 518321aedd1e..a4dbe6d3a466 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2707,6 +2707,18 @@ static void mptcp_cleanup_ssk_backlog(struct sock *sk, struct sock *ssk)
 
 static void mptcp_check_fastclose(struct mptcp_sock *msk);
 
+/* After the close, a pending DATA_FIN or MP_FASTCLOSE would be ignored */
+static void mptcp_check_rcv_close(struct sock *sk)
+{
+	/* process the DATA_FIN after the data still in the backlog */
+	if (READ_ONCE(mptcp_sk(sk)->rcv_data_fin)) {
+		mptcp_move_skbs(sk);
+		mptcp_check_data_fin(sk);
+	}
+
+	mptcp_check_fastclose(mptcp_sk(sk));
+}
+
 /* subflow sockets can be either outgoing (connect) or incoming
  * (accept).
  *
@@ -2818,9 +2830,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 			mptcp_schedule_work(sk);
 		} else if (sk->sk_state != TCP_ESTABLISHED ||
 			   msk->in_accept_queue) {
-			/* After the close, an MP_FASTCLOSE would be ignored */
-			mptcp_check_fastclose(msk);
-
+			mptcp_check_rcv_close(sk);
 			mptcp_set_state(sk, TCP_CLOSE);
 			WRITE_ONCE(sk->sk_shutdown,
 				   sk->sk_shutdown | SEND_SHUTDOWN);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 24/62] mptcp: process pending close events at accept()
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (22 preceding siblings ...)
  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  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21 10:13   ` sashiko-bot
  2026-11-21  9:41 ` [PATCH mptcp-net v2 25/62] mptcp: clear sk_err on connect(), as TCP does Matthieu Baerts (NGI0)
                   ` (37 subsequent siblings)
  61 siblings, 1 reply; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

When the only subflow of a new MPTCP socket has been closed before
accept(), e.g. reset by the peer, mptcp_stream_accept() moves this
socket to the CLOSE state, then closes the subflow. A DATA_FIN or an
MP_FASTCLOSE received before, but not processed yet by the worker, was
then ignored: the code processing them before closing an MPTCP socket
without subflows, and the worker, skip a socket already closed.

recv() then returned ENOTCONN after the data, instead of EOF after a
DATA_FIN, or ECONNRESET after an MP_FASTCLOSE alone, as TCP does.

This race has been found by a review agent, and confirmed with
Packetdrill scripts and a debug patch delaying the worker of the MPTCP
sockets in the accept queue: data, a DATA_FIN or not, then a reset with
an MP_FASTCLOSE are received before accept(). Without this patch, the
second read() returned ENOTCONN in both cases:

  With DATA_FIN: runtime error in read call: Expected result 0 but got -1 with errno 107 (Transport endpoint is not connected)
  Without DATA_FIN: runtime error in read call: Expected errno 104 (Connection reset by peer) but got 107 (Transport endpoint is not connected)

To fix this, process them before moving to the CLOSE state, with
mptcp_check_rcv_close(), as done when closing the MPTCP socket without
subflows.

Note for the backports: before v6.19, this helper, added by the previous
commit, is not available, and mptcp_stream_accept() closes the subflow
before moving to the CLOSE state.

Fixes: 63740448a32e ("mptcp: fix accept vs worker race")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue found by a review agent
---
 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 a4dbe6d3a466..7700265a13ce 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -4679,8 +4679,10 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,
 		 * deal with bad peers not doing a complete shutdown.
 		 */
 		if (unlikely(inet_sk_state_load(msk->first) == TCP_CLOSE)) {
-			if (unlikely(list_is_singular(&msk->conn_list)))
+			if (unlikely(list_is_singular(&msk->conn_list))) {
+				mptcp_check_rcv_close(newsk);
 				mptcp_set_state(newsk, TCP_CLOSE);
+			}
 			mptcp_close_ssk(newsk, msk->first,
 					mptcp_subflow_ctx(msk->first));
 		}

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 25/62] mptcp: clear sk_err on connect(), as TCP does
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (23 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 24/62] mptcp: process pending close events at accept() Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 26/62] mptcp: clear DEFER_CONNECT on disconnect Matthieu Baerts (NGI0)
                   ` (36 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

After a disconnect with connect(AF_UNSPEC), an error from the previous
connection, e.g. a reset not reported yet to the application, was still
reported for the next connection, by poll(), SO_ERROR, and the first
send() or recv(). TCP clears it in tcp_connect_init(): do the same,
once the subflow connect() succeeded, so an early failure keeps it.

This issue has been found by an AI code review agent, while reviewing
other fixes, and confirmed with a reproducer: the peer resets the
connection, the error is not read, then the socket is disconnected and
connected again. SO_ERROR then reported ECONNRESET each time, while TCP
reported no error, as MPTCP now does.

Fixes: 3d1d6d66e156 ("mptcp: implement support for user-space disconnect")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue found by a review agent
---
 net/mptcp/protocol.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 7700265a13ce..9a61317853a0 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -4428,6 +4428,8 @@ static int mptcp_connect(struct sock *sk, struct sockaddr_unsized *uaddr,
 	if (err < 0)
 		goto out;
 
+	/* as tcp_connect_init(): drop an error from a previous connection */
+	WRITE_ONCE(sk->sk_err, 0);
 	inet_assign_bit(DEFER_CONNECT, sk, inet_test_bit(DEFER_CONNECT, ssk));
 
 out:

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 26/62] mptcp: clear DEFER_CONNECT on disconnect
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (24 preceding siblings ...)
  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 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 27/62] mptcp: report sf aborts during deferred connect Matthieu Baerts (NGI0)
                   ` (35 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

With TCP_FASTOPEN_CONNECT, mptcp_connect() copies the DEFER_CONNECT bit
of the first subflow to the msk. This bit is cleared on the first
write(), but not when the msk is disconnected, e.g. with
connect(AF_UNSPEC) before any write().

tcp_disconnect() clears this bit on the subflow, but mptcp_disconnect()
leaves it set on the msk. The next write() then goes through
mptcp_sendmsg_fastopen(), and tries to connect the msk again with a NULL
address: mptcp_connect() moves the msk back to SYN_SENT, possibly
allocates a token and increments the MPCapableActive counter, before the
subflow connect() fails. -EINVAL is then returned, instead of -EPIPE.
The stale bit is also reported by the diag interface.

Clear DEFER_CONNECT in mptcp_disconnect(), like tcp_disconnect() does.

This issue has been found by an AI code review agent, while fixing a
similar issue, and confirmed with a new Packetdrill test: a deferred
connect, then connect(AF_UNSPEC), then send(). Without this patch,
send() failed with EINVAL:

  client-TCP_FASTOPEN_CONNECT-disconnect.pkt:35: runtime error in send call: Expected errno 32 (Broken pipe) but got 22 (Invalid argument)

Fixes: a42cf9d18278 ("mptcp: poll allow write call before actual connect")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue found by a review agent
---
 net/mptcp/protocol.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 9a61317853a0..a9ce2b6317d3 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3804,6 +3804,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)
 
 	mptcp_check_listen_stop(sk);
 	mptcp_set_state(sk, TCP_CLOSE);
+	inet_clear_bit(DEFER_CONNECT, sk);
 
 	/* The later subflow close can not kick again the tout timer,
 	 * as the msk is already in closed status.

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 27/62] mptcp: report sf aborts during deferred connect
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (25 preceding siblings ...)
  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 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 28/62] mptcp: no fastclose reset from SYN_SENT subflows Matthieu Baerts (NGI0)
                   ` (34 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

With TCP_FASTOPEN_CONNECT, connect() on an MPTCP socket only sets
DEFER_CONNECT on the first subflow and on the msk, and the first write()
sends the SYN with data via mptcp_sendmsg_fastopen().

If the first subflow is aborted by tcp_abort(), e.g. via a sock_diag
destroy request or the bpf_sock_destroy() kfunc, while mptcp_sendmsg()
already owns the msk socket and is waiting for the subflow lock:

- tcp_abort() clears DEFER_CONNECT on the subflow, and moves it to
  TCP_CLOSE;
- subflow_error_report() can only set MPTCP_ERROR_REPORT, because the
  msk is owned by the user: the msk stays in SYN_SENT, with
  DEFER_CONNECT still set.

tcp_sendmsg_fastopen() then skips tcp_connect(), and calls
__inet_stream_connect() with the msk socket, the first subflow being
grafted to it. Because DEFER_CONNECT is set on the msk, -EISCONN is
returned to userspace, on a connection that has just been aborted.

Detect this case once the subflow lock is held: if DEFER_CONNECT is set
on the msk, but no longer on the subflow, the subflow has been aborted.
Propagate the subflow error to the msk directly, instead of waiting for
the msk release callback. mptcp_sendmsg() will then report this error
via sk_stream_wait_connect(), like plain TCP after tcp_abort(), e.g.
-ECONNABORTED. The deferred error report is then a no-op, so the error
is not reported twice.

Without the race, the msk is already in TCP_CLOSE with the error set:
the same check also avoids going through tcp_sendmsg_fastopen() and
__inet_stream_connect() in this case, except with MSG_FASTOPEN. Then,
the socket has to be disconnected, as with TCP, for the next sendto() to
connect again, and the race cannot happen: __mptcp_nmpc_sk() requires an
msk in TCP_CLOSE.

Clearing DEFER_CONNECT on the msk from tcp_abort_override() instead
would not be enough: tcp_abort() is called on the subflow without the
msk lock, and mptcp_sendmsg() checks the msk bit before taking the
subflow lock. The abort can then happen in between, and write() would
return -EALREADY, followed by a disconnect of the msk dropping the
deferred error. In this path, only mptcp_sendmsg_fastopen() holds both
the msk and the subflow locks, and sees a consistent state.

This issue has been reported by Sashiko, while reviewing the commit
below. It has not been reproduced: the abort has to happen while write()
owns the msk socket, and waits for the subflow lock.

Fixes: 93723db43e51 ("tcp: Clear DEFER_CONNECT before tcp_connect() and in tcp_abort().")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue spotted by Sashiko
---
 net/mptcp/protocol.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index a9ce2b6317d3..f80fac0c22c0 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1960,8 +1960,6 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
 	/* on flags based fastopen the mptcp is supposed to create the
 	 * first subflow right now. Otherwise we are in the defer_connect
 	 * path, and the first subflow must be already present.
-	 * Since the defer_connect flag is cleared after the first succsful
-	 * fastopen attempt, no need to check for additional subflow status.
 	 */
 	if (msg->msg_flags & MSG_FASTOPEN) {
 		ssk = __mptcp_nmpc_sk(msk);
@@ -1974,6 +1972,19 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
 	ssk = msk->first;
 
 	lock_sock(ssk);
+
+	/* subflow aborted by tcp_abort(): its error report may be deferred.
+	 * With MSG_FASTOPEN, the socket is disconnected below, as with TCP.
+	 */
+	if (unlikely(!(msg->msg_flags & MSG_FASTOPEN) &&
+		     inet_test_bit(DEFER_CONNECT, sk) &&
+		     !inet_test_bit(DEFER_CONNECT, ssk))) {
+		inet_clear_bit(DEFER_CONNECT, sk);
+		__mptcp_subflow_error_report(sk, ssk);
+		release_sock(ssk);
+		return 0;
+	}
+
 	msg->msg_flags |= MSG_DONTWAIT;
 	msk->fastopening = 1;
 	ret = tcp_sendmsg_fastopen(ssk, msg, copied_syn, len, NULL);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 28/62] mptcp: no fastclose reset from SYN_SENT subflows
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (26 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 27/62] mptcp: report sf aborts during deferred connect Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21 10:11   ` sashiko-bot
  2026-11-21  9:41 ` [PATCH mptcp-net v2 29/62] mptcp: keep listening after MSG_FASTOPEN errors Matthieu Baerts (NGI0)
                   ` (33 subsequent siblings)
  61 siblings, 1 reply; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

mptcp_do_fastclose() sends a reset with an MP_FASTCLOSE on each subflow
not in LISTEN or CLOSE, also on the ones in SYN_SENT, while TCP sends no
reset in this state, see tcp_need_reset() used by tcp_disconnect(). On a
disconnect in SYN_SENT, e.g. with connect(AF_UNSPEC), an MPTCP client
then sends a reset with an MP_FASTCLOSE carrying an unknown key, 0. With
TCP_FASTOPEN_CONNECT, this reset is even sent before any SYN.

Before the commit below, these resets were sent by tcp_disconnect(), so
not in SYN_SENT. Skip them again in this state, as TCP does: the subflow
is still moved to TCP_CLOSE, and a later SYN-ACK gets a reset from the
stack.

This issue has been found by an AI code review agent, while reviewing
"mptcp: clear DEFER_CONNECT on disconnect", and confirmed with a new
Packetdrill test: a disconnect in SYN_SENT, then the SYN-ACK. Without
this patch, a reset with MPTCP options was sent at the disconnect,
before the one replying to the SYN-ACK:

  disconnect_in_syn_sent.pkt:16: error handling packet: live packet field ipv4_total_length: expected: 40 (0x28) vs actual: 56 (0x38)

Fixes: ae155060247b ("mptcp: fix duplicate reset on fastclose")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue found by a review agent
---
 net/mptcp/protocol.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index f80fac0c22c0..55ff0298e5dd 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3297,6 +3297,10 @@ static void mptcp_do_fastclose(struct sock *sk)
 
 		subflow->send_fastclose = 1;
 
+		/* no reset in SYN_SENT, as TCP does */
+		if (ssk->sk_state == TCP_SYN_SENT)
+			goto unlock;
+
 		/* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0
 		 * issue in __tcp_select_window(), see tcp_disconnect().
 		 */

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 29/62] mptcp: keep listening after MSG_FASTOPEN errors
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (27 preceding siblings ...)
  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  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 30/62] mptcp: don't inherit fastopening from a listener Matthieu Baerts (NGI0)
                   ` (32 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

A sendmsg() with MSG_FASTOPEN on an MPTCP listener fails, e.g. with
EISCONN, as with TCP, but it also closes the listener: after any error,
mptcp_sendmsg_fastopen() retries the disconnect that could have failed
in __inet_stream_connect(), while there is nothing to retry for a
listener.

Skip this disconnect for a listener: it keeps listening, as with TCP.

This issue has been found by an AI code review agent, while reviewing
"mptcp: report sf aborts during deferred connect", and confirmed with a
new Packetdrill test: sendto() with MSG_FASTOPEN on a listener, then a
SYN. Without this patch, the SYN got a reset instead of a SYN-ACK:

  listen_sendto_fastopen.pkt:14: error handling packet: live packet field ipv4_total_length: expected: 60 (0x3c) vs actual: 40 (0x28)

Fixes: 7d803344fdc3 ("mptcp: fix deadlock in fastopen error path")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue found by a review agent
---
 net/mptcp/protocol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 55ff0298e5dd..6f4e418d712c 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2004,11 +2004,12 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
 		 */
 		if (ret && ret != -EINPROGRESS && ret != -ERESTARTSYS && ret != -EINTR)
 			*copied_syn = 0;
-	} else if (ret && ret != -EINPROGRESS) {
+	} else if (ret && ret != -EINPROGRESS && sk->sk_state != TCP_LISTEN) {
 		/* The disconnect() op called by tcp_sendmsg_fastopen()/
 		 * __inet_stream_connect() can fail, due to looking check,
 		 * see mptcp_disconnect().
 		 * Attempt it again outside the problematic scope.
+		 * A listener is not disconnected there, as with TCP.
 		 */
 		if (!mptcp_disconnect(sk, 0)) {
 			sk->sk_disconnects++;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 30/62] mptcp: don't inherit fastopening from a listener
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (28 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 29/62] mptcp: keep listening after MSG_FASTOPEN errors Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` 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)
                   ` (31 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

A new msk is a copy of its listener, made without the listener's lock:
if the application calls sendmsg() with MSG_FASTOPEN on the listener at
the same time, the new msk can inherit msk->fastopening, only set during
tcp_sendmsg_fastopen(). mptcp_disconnect() then fails on this socket:
connect(AF_UNSPEC) returns EBUSY.

Clear this flag when creating a new msk.

This issue has been found by an AI code review agent, while reviewing
"mptcp: keep listening after MSG_FASTOPEN errors": before this other
fix, these new sockets were mostly reset with the listener. It has been
confirmed with a Packetdrill test, and a debug delay added in
mptcp_sendmsg_fastopen(), during which the handshake completes. Without
this patch, connect(AF_UNSPEC) on the accepted socket failed:

  runtime error in connect call: Expected result 0 but got -1 with errno 16 (Device or resource busy)

Fixes: 7d803344fdc3 ("mptcp: fix deadlock in fastopen error path")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue found by a review agent
---
 net/mptcp/protocol.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 6f4e418d712c..9202b14c030e 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3977,6 +3977,7 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk,
 	WRITE_ONCE(msk->local_key, subflow_req->local_key);
 	WRITE_ONCE(msk->token, subflow_req->token);
 	msk->in_accept_queue = 1;
+	msk->fastopening = 0;
 	WRITE_ONCE(msk->fully_established, false);
 	if (mp_opt->suboptions & OPTION_MPTCP_CSUMREQD)
 		WRITE_ONCE(msk->csum_enabled, true);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 31/62] mptcp: drop non-MP_JOIN cookie ACKs on PM listeners
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (29 preceding siblings ...)
  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 ` 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)
                   ` (30 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

With SYN cookies enabled, a port-based MPTCP signal endpoint can stop
accepting new subflows until it is deleted.

Nobody calls accept() on the listener that the in-kernel path manager
opens for such an endpoint, so it must create only MP_JOIN subflows,
which never enter the accept queue. The listener is marked pm_listener,
and since commit 3d041393ea8c ("mptcp: prevent MPC handshake on
port-based signal endpoints") subflow_check_req() refuses a SYN with no
MP_JOIN option on it. But a SYN cookie does not record the MPTCP option
of the SYN, so mptcp_subflow_init_cookie_req() picks the kind of child
from the options of the ACK, without looking at pm_listener:

    ACK with a valid cookie and no MP_JOIN option
      creates a plain TCP child, or an MPTCP one if it has MP_CAPABLE
        which stays on the accept queue until the endpoint is deleted
          once the queue is full, the listener drops MP_JOIN SYNs too

The fix used here is to refuse an ACK with no MP_JOIN option on such a
listener in mptcp_subflow_init_cookie_req(), so that the request sock is
freed and the ACK is dropped.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch:
a client sent 1025 ACKs with valid SYN cookies and no MP_JOIN to the
listener of such an endpoint. Without this patch, its accept queue
stayed full, and another client could not create its additional subflow,
even 130 seconds later:

  TCP: request_sock_subflow_v4: Possible SYN flooding on port 10.9.0.2:6666. Sending cookies.
  [...]
  C2         4.007  [130 s after C1 has gone] RESULT: subflows established 1, in SYN_SENT 1, the service works
  --- V, after that try of C2
      listener 10.9.0.2:6666 Recv-Q 1025 Send-Q 1024

Fixes: 1729cf186d8a ("mptcp: create the listening socket for new port")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comment, the details are in the commit message. Commit
  message: how the issue was found, and its symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/subflow.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 0c97a5ce2d0c..f9ed4cfa4b33 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -312,6 +312,11 @@ int mptcp_subflow_init_cookie_req(struct request_sock *req,
 
 	opt_mp_capable = !!(mp_opt.suboptions & OPTION_MPTCP_MPC_ACK);
 	opt_mp_join = !!(mp_opt.suboptions & OPTION_MPTCP_MPJ_ACK);
+
+	/* PM listeners only take MP_JOIN, like in subflow_check_req() */
+	if (unlikely(listener->pm_listener) && !opt_mp_join)
+		return subflow_reset_req_endp(req, skb);
+
 	if (opt_mp_capable && listener->request_mptcp) {
 		if (mp_opt.sndr_key == 0)
 			return -EINVAL;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 32/62] net: add __sk_net_refcnt_upgrade() with a GFP mask
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (30 preceding siblings ...)
  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 ` 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)
                   ` (29 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

sk_net_refcnt_upgrade() gives a kernel socket a reference on its network
namespace, with a netns tracker allocated with GFP_KERNEL. The next
commit needs to do that for a socket created in atomic context: the
child of a kernel MPTCP listener, created when an MP_JOIN request is
accepted.

Add __sk_net_refcnt_upgrade(), taking the GFP mask to use, and make
sk_net_refcnt_upgrade() call it with GFP_KERNEL: no functional change
for the existing callers.

The 'Fixes' tag here below is the same as the one from the next commit:
this patch is needed to fix the issue introduced by this commit ID.

Fixes: 1729cf186d8a ("mptcp: create the listening socket for new port")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 include/net/sock.h | 1 +
 net/core/sock.c    | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 5a203809218a..953bd0060fae 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1869,6 +1869,7 @@ static inline bool sock_allow_reclassification(const struct sock *csk)
 struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
 		      struct proto *prot, int kern);
 void sk_free(struct sock *sk);
+void __sk_net_refcnt_upgrade(struct sock *sk, gfp_t gfp);
 void sk_net_refcnt_upgrade(struct sock *sk);
 void sk_destruct(struct sock *sk);
 struct sock *sk_clone(const struct sock *sk, const gfp_t priority, bool lock);
diff --git a/net/core/sock.c b/net/core/sock.c
index 6d143faeccc3..832e335d7448 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2407,7 +2407,7 @@ static void __sk_destruct(struct rcu_head *head)
 	sk_prot_free(sk->sk_prot_creator, sk);
 }
 
-void sk_net_refcnt_upgrade(struct sock *sk)
+void __sk_net_refcnt_upgrade(struct sock *sk, gfp_t gfp)
 {
 	struct net *net = sock_net(sk);
 
@@ -2415,9 +2415,14 @@ void sk_net_refcnt_upgrade(struct sock *sk)
 	__netns_tracker_free(net, &sk->ns_tracker, false);
 	net_passive_dec(net);
 	sk->sk_net_refcnt = 1;
-	get_net_track(net, &sk->ns_tracker, GFP_KERNEL);
+	get_net_track(net, &sk->ns_tracker, gfp);
 	sock_inuse_add(net, 1);
 }
+
+void sk_net_refcnt_upgrade(struct sock *sk)
+{
+	__sk_net_refcnt_upgrade(sk, GFP_KERNEL);
+}
 EXPORT_SYMBOL_GPL(sk_net_refcnt_upgrade);
 
 void sk_destruct(struct sock *sk)

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 33/62] mptcp: pm: don't let listeners pin their netns
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (31 preceding siblings ...)
  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 ` 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)
                   ` (28 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Josef Bacik

From: Josef Bacik <josef@toxicpanda.com>

For a "signal" endpoint with a port, the in-kernel path manager creates a
listening MPTCP socket with sock_create_kern(). This socket is released
when the endpoint is deleted or, failing that, by pm_nl_exit_net() when the
network namespace is dismantled.

The MPTCP socket itself holds no reference on the namespace. But its first
subflow is created by mptcp_subflow_create_socket(), which always calls
sk_net_refcnt_upgrade(). So the namespace cannot be dismantled before
the listener is released, and the listener is not released before the
namespace is dismantled: unless somebody deletes the endpoint, both stay
around for ever once the last process of the namespace is gone.

  unshare -Urn sh -c 'ip link set lo up;
                      ip mptcp endpoint add 127.0.0.1 port 4321 signal'

leaks a namespace, with everything it contains, each time it is run. It
remains charged to the user's max_net_namespaces limit.

Only take the reference if the MPTCP socket has one. A listening TCP
socket has no timer of its own, and request sockets of a dead namespace are
taken care of by inet_twsk_purge().

The sockets cloned from that listener for incoming MP_JOIN requests do
need the reference, for their timers, but inherit sk_net_refcnt == 0. Take
it when they are created, with __sk_net_refcnt_upgrade(), from the
previous commit, as this is done in atomic context, and drop the
connection request if the namespace is already going away.

The TCP listener of such an endpoint is now a plain kernel socket, like
the MPTCP socket it belongs to: it is not counted in "sockets: used" in
/proc/net/sockstat any more, and its destruction is not broadcast to the
listeners of the SKNLGRP_INET*_TCP_DESTROY sock_diag groups.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch:
the command above, run 1000 times by an unprivileged user. Without this
patch, all the network namespaces were leaked:

  result: 1000 network namespaces made, 0 taken down, 1000 are left

Fixes: 1729cf186d8a ("mptcp: create the listening socket for new port")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
[ Use __sk_net_refcnt_upgrade(), from the previous commit, instead of an
  open-coded copy of sk_net_refcnt_upgrade(), with maybe_get_net() like
  rds_tcp_tune(). Shorter comments, and describe the condition: any
  kernel msk. Commit message: how the issue was found, and its
  symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/subflow.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index f9ed4cfa4b33..8163731a9366 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -849,6 +849,22 @@ void __mptcp_subflow_fully_established(struct mptcp_sock *msk,
 	WRITE_ONCE(msk->fully_established, true);
 }
 
+/* Children of a kernel listener need a netns ref for their timers */
+static bool subflow_child_get_net(struct sock *child)
+{
+	struct net *net = sock_net(child);
+
+	if (likely(child->sk_net_refcnt))
+		return true;
+
+	if (!maybe_get_net(net))
+		return false;
+
+	__sk_net_refcnt_upgrade(child, GFP_ATOMIC);
+	put_net(net);
+	return true;
+}
+
 static struct sock *subflow_syn_recv_sock(const struct sock *sk,
 					  struct sk_buff *skb,
 					  struct request_sock *req,
@@ -917,6 +933,11 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
 
 		tcp_rsk(req)->drop_req = false;
 
+		if (!subflow_child_get_net(child)) {
+			subflow_add_reset_reason(skb, MPTCP_RST_EUNSPEC);
+			goto dispose_child;
+		}
+
 		/* we need to fallback on ctx allocation failure and on pre-reqs
 		 * checking above. In the latter scenario we additionally need
 		 * to reset the context to non MPTCP status.
@@ -1868,8 +1889,10 @@ int mptcp_subflow_create_socket(struct sock *sk, unsigned short family,
 	/* kernel sockets do not by default acquire net ref, but TCP timer
 	 * needs it.
 	 * Update ns_tracker to current stack trace and refcounted tracker.
+	 * Not for a kernel msk, e.g. a PM listener: it would pin the netns.
 	 */
-	sk_net_refcnt_upgrade(sf->sk);
+	if (sk->sk_net_refcnt)
+		sk_net_refcnt_upgrade(sf->sk);
 	err = tcp_set_ulp(sf->sk, "mptcp");
 	if (err)
 		goto err_free;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 34/62] mptcp: close a subflow reset for a bad mapping
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (32 preceding siblings ...)
  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 ` 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)
                   ` (27 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

An MPTCP socket can stay in the ESTABLISHED state after MPTCP has reset
its only subflow because of data with no valid mapping, and recv() and
send() then block with no error.

If data arrives with no valid mapping and a fallback to TCP is not
possible, subflow_check_data_avail() resets the subflow: it moves the
TCP socket to TCP_CLOSE with tcp_set_state() and sends a RST. The MPTCP
worker then has to close the subflow in __mptcp_close_subflow(), and
closing the last subflow starts a timer that moves the MPTCP socket to
TCP_CLOSE. But the worker only calls that function if the bit
MPTCP_WORK_CLOSE_SUBFLOW is set, and this reset neither sets the bit nor
schedules the worker.

The fix used here is to call subflow_sched_work_if_closed() after the
reset, which sets the bit and schedules the worker. This also covers
the reset done after a bad checksum, when MP_FAIL cannot be used.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch,
and with a new Packetdrill test: data without DSS while the fallback is
not possible, here because of out-of-order data at the MPTCP level.
Without this patch, the subflow was reset, but the MPTCP socket stayed
established, with no subflow: read() returned EAGAIN and send() timed
out, for good:

  dss_drop_ooo_reset_server.pkt:30: runtime error in read call: Expected errno 107 (Transport endpoint is not connected) but got 11 (Resource temporarily unavailable)

Fixes: 40947e13997a ("mptcp: schedule worker when subflow is closed")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Add a Fixes tag. Moved before "mptcp: continue the last mapping after
  a fallback", which makes this reset path reachable in more cases.
  Commit message: how the issue was found, and its symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: commit msg: the reset after a bad checksum too (Sashiko)
---
 net/mptcp/subflow.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 8163731a9366..62a6dc18005b 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1502,8 +1502,8 @@ static bool subflow_check_data_avail(struct sock *ssk)
 		}
 
 		if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) {
-			/* fatal protocol error, close the socket.
-			 * subflow_error_report() will introduce the appropriate barriers
+			/* fatal protocol error, reset the subflow and let the
+			 * worker close it
 			 */
 			subflow->reset_transient = 0;
 			MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DSSRESET);
@@ -1518,6 +1518,7 @@ static bool subflow_check_data_avail(struct sock *ssk)
 				sk_eat_skb(ssk, skb);
 			mptcp_send_active_reset_reason(ssk);
 			WRITE_ONCE(subflow->data_avail, false);
+			subflow_sched_work_if_closed(msk, ssk);
 			return false;
 		}
 	}

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 35/62] mptcp: initialize drop_req in subflow_init_req()
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (33 preceding siblings ...)
  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 ` 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)
                   ` (26 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

With CONFIG_MPTCP and SO_REUSEPORT migration, which
net.ipv4.tcp_migrate_req=1 or a BPF program enables, TCP sockets can
leak until reboot, and each keeps its network namespace alive.

tcp_check_req() keeps a child off the accept queue if drop_req is true
in a request socket that an MPTCP listener created. drop_req has one
writer, subflow_syn_recv_sock(), which tcp_check_req() calls before that
test only for an MPTCP listener. But if SO_REUSEPORT migration moves the
request socket to a plain TCP listener, the test reads what the
allocation left in drop_req, and nothing drops the last reference of a
child that stays off the accept queue.

The fix used here is to set drop_req to false in subflow_init_req(),
which runs when the request socket of an MPTCP listener is set up.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch,
run as an unprivileged user in a user namespace, with
net.ipv4.tcp_migrate_req=1: an MPTCP listener and a TCP one sharing a
port with SO_REUSEPORT, the MPTCP one being closed while handshakes
complete. Without this patch, the children were leaked, with their
network namespace, without any message from the kernel:

  repro: step 3 to 6: 32 SYNs, 16 went to A. A closed, 16 third ACKs. accept() on B returned 0
  [...]
  repro: RESULT: 16 children never reached an accept queue
  repro: one RST for each connection. TCP: inuse 0 orphan 0 tw 0 alloc 16 mem 0
  === exit code 0. The process and its namespaces are gone
  === after:  TCP sockets allocated, all namespaces: 16 [...]

With UBSAN, the original version of this patch also reported:

  UBSAN: invalid-load in [...]/include/net/mptcp.h:144:47
  load of value 14 is not a valid value for type '_Bool'
   tcp_check_req.cold+0xb6/0x189
   tcp_v4_rcv+0x11f4/0x4230

Fixes: c905dee62232 ("tcp: Migrate TCP_NEW_SYN_RECV requests at retransmitting SYN+ACKs.")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comment. Commit message: how the issue was found, and its
  symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/subflow.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 62a6dc18005b..a216d88d35ee 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -151,6 +151,9 @@ static void subflow_init_req(struct request_sock *req, const struct sock *sk_lis
 	subflow_req->allow_join_id0 = mptcp_allow_join_id0(sock_net(sk_listener));
 	subflow_req->msk = NULL;
 	mptcp_token_init_request(req);
+
+	/* read by tcp_check_req() even after migration to a TCP listener */
+	tcp_rsk(req)->drop_req = false;
 }
 
 static bool subflow_use_different_sport(struct mptcp_sock *msk, const struct sock *sk)

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 36/62] mptcp: pm: kernel: count endpoint listeners as sockets in use
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (34 preceding siblings ...)
  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 ` 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)
                   ` (25 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Kyuwon Cho

The listener that the in-kernel path manager creates for a "signal"
endpoint with a port is not counted in the "sockets" column of the MPTCP
or MPTCPv6 row of /proc/net/protocols, but it is uncounted when it is
closed. Each removal of such an endpoint then hides one MPTCP socket of
the same family from this column, for the lifetime of the netns.

mptcp_check_listen_stop() decrements this counter for any MPTCP socket
closed in TCP_LISTEN state, and mptcp_listen() increments it when
listen() succeeds. But mptcp_pm_nl_create_listen_socket() sets its MPTCP
socket in TCP_LISTEN state without incrementing it. This socket is
closed when the endpoint is deleted or flushed, when adding the endpoint
fails after the creation of the listener, e.g. because its ID is already
used, and when the netns is dismantled.

Nothing depends on this counter, it is only displayed. But it is wrong
once such an endpoint has been added: its listener is not counted while
"ss -Ml" lists it, and after its removal, the total is one below the
number of MPTCP sockets of the same family in use, a negative total
being displayed as 0 by sock_prot_inuse_get().

The counter was introduced by commit c558246ee73e ("mptcp: add
statistics for mptcp socket in use"), when only the subflow of this
socket was in TCP_LISTEN state. Commit 57fc0f1ceaa4 ("mptcp: ensure
listener is unhashed before updating the sk status") then set this
socket in TCP_LISTEN state too, without counting it.

The fix used here is to increment the counter when __inet_listen_sk()
succeeds, as mptcp_listen() does. If it fails, the subflow is back in
TCP_CLOSE: move this socket back to this state too, also as
mptcp_listen() does. It was left in TCP_LISTEN, which triggered a
warning when it was released, e.g. after a socket in TCP repair mode
had been bound to the same address and port in between, as reported by
Sashiko:

  WARNING: net/mptcp/protocol.c:3542 at mptcp_check_listen_stop.part.0+0x4f/0xb0, CPU#0: ip/2816
  Call Trace:
   __mptcp_close+0x2bf/0x310
   mptcp_close+0x23/0x80
   inet_release+0x43/0x80
   sock_release+0x24/0x70
   mptcp_pm_nl_add_addr_doit+0x266/0x3b0

This issue has been found by an AI code review agent, while reviewing
the code of the commit "mptcp: pm: don't let listeners pin their netns",
and confirmed with a new Packetdrill test, and with a shell script
adding and flushing such an endpoint 3 times in a new netns, then
creating 3 MPTCP listeners. Without this patch:

  kernel_listener_inuse.pkt:15: error executing `test $(awk '/^MPTCP/ { n += $3 } END { print n }' /proc/net/protocols) -eq 2` command: non-zero status 1

  inuse: endpoint 1 present: 0 (expected 1)
  [...]
  inuse: 3 user listeners: 0 (expected 3)

Fixes: 57fc0f1ceaa4 ("mptcp: ensure listener is unhashed before updating the sk status")
Reported-by: Kyuwon Cho <kyuwoncho18@gmail.com>
Closes: https://lore.kernel.org/mptcp/179502042942.2742790.17887994424282536144@gmail.com
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: count the listener once listen() succeeded, and restore TCP_CLOSE
    otherwise, to avoid a warning (Sashiko, then reported by Kyuwon Cho)
---
 net/mptcp/pm_kernel.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
index 2680d4672d58..73261685ae4c 100644
--- a/net/mptcp/pm_kernel.c
+++ b/net/mptcp/pm_kernel.c
@@ -915,7 +915,14 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk,
 	if (!err)
 		mptcp_event_pm_listener(ssk, MPTCP_EVENT_LISTENER_CREATED);
 	release_sock(ssk);
-	return err;
+	if (err) {
+		/* the subflow is back in TCP_CLOSE: like in mptcp_listen() */
+		inet_sk_state_store(newsk, TCP_CLOSE);
+		return err;
+	}
+
+	sock_prot_inuse_add(sock_net(newsk), newsk->sk_prot, 1);
+	return 0;
 }
 
 static int mptcp_pm_kernel_get_local_id(struct mptcp_sock *msk,

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 37/62] mptcp: count a listener once when listen() is called again
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (35 preceding siblings ...)
  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 ` 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)
                   ` (24 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

listen() on a listening MPTCP socket only updates its backlog, as with
TCP. But mptcp_listen() then counts this socket once more in the
"sockets" column of the MPTCP or MPTCPv6 row of /proc/net/protocols, and
sends a new MPTCP_EVENT_LISTENER_CREATED event, while only one decrement
and one MPTCP_EVENT_LISTENER_CLOSED event are done when it is closed.
Each extra listen() call then leaves the counter one above the number of
MPTCP sockets in use, for the lifetime of the netns, and a userspace
path manager can see two listeners created for one closed.

With TCP, the socket is only counted when it is hashed, which is not
done again for a listening socket.

The fix used here is to only count the socket, and send the event, if it
was not already listening.

This issue has been found by an AI code review agent, while reviewing
the code of the commit "mptcp: pm: kernel: count endpoint listeners as
sockets in use", and confirmed with a new Packetdrill test, and with a
script calling listen() twice. Without this patch:

  listen_listen.pkt:12: error executing `test $(awk '/^MPTCP/ { n += $3 } END { print n }' /proc/net/protocols) -eq 1` command: non-zero status 1

  inuse: relisten: listening: 2 (expected 1)
  inuse: relisten: closed: 1 (expected 0)

The extra event comes from the commit below, and the extra count from
commit c558246ee73e ("mptcp: add statistics for mptcp socket in use"),
which is in all the stable versions having the commit below.

Fixes: f8c9dfbd875b ("mptcp: add pm listener events")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: commit message: explain the two Fixes tags
---
 net/mptcp/protocol.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 9202b14c030e..d16269d27b1d 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -4540,6 +4540,7 @@ static int mptcp_listen(struct socket *sock, int backlog)
 	struct mptcp_sock *msk = mptcp_sk(sock->sk);
 	struct sock *sk = sock->sk;
 	struct sock *ssk;
+	bool listening;
 	int err;
 
 	pr_debug("msk=%p\n", msk);
@@ -4556,6 +4557,7 @@ static int mptcp_listen(struct socket *sock, int backlog)
 		goto unlock;
 	}
 
+	listening = sk->sk_state == TCP_LISTEN;
 	set_bit(MPTCP_RTX_ENABLED, &msk->flags);
 	mptcp_set_state(sk, TCP_LISTEN);
 	sock_set_flag(sk, SOCK_RCU_FREE);
@@ -4570,7 +4572,8 @@ static int mptcp_listen(struct socket *sock, int backlog)
 	release_sock(ssk);
 	mptcp_set_state(sk, inet_sk_state_load(ssk));
 
-	if (!err) {
+	/* only the backlog changes when listening already */
+	if (!err && !listening) {
 		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
 		mptcp_copy_inaddrs(sk, ssk);
 		mptcp_event_pm_listener(ssk, MPTCP_EVENT_LISTENER_CREATED);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 38/62] mptcp: send the infinite map in a single segment
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (36 preceding siblings ...)
  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 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 39/62] mptcp: keep room for infinite map after fallback Matthieu Baerts (NGI0)
                   ` (23 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

After an MP_FAIL with a single subflow, mptcp_sendmsg_frag() puts the
infinite mapping on the next skb with new data, then falls back to TCP.
This skb can be bigger than one MSS: it is sized with the size goal
computed before the fallback, from an MSS reserving the space for the
DSS option.
After the fallback, this space is no longer reserved when the MSS is
computed, but this skb still carries a DSS option, which is copied to
each of its segments: with the new MSS, they are bigger than the MTU.

The new MSS is used for the next transmissions, e.g. when only a part of
the skb can be sent at first, or for a retransmission, and it can also
be used for the first one, when more data is pushed in the same batch.
The IP layer drops such segments, as DF is set, and sends an ICMP
"Fragmentation Needed" to the local host, which doesn't change the PMTU:
the transfer stalls.

This issue was causing the "Infinite map" subtest from mptcp_join.sh to
be flaky, with the client counting these ICMPs as OutOfWindowIcmps, and
its subflow stuck with unsent data:

  copyfd_io_poll: poll timed out (events: POLLIN 1, POLLOUT 0)
  (...)
    TcpExtOutOfWindowIcmps          134
  (...)
  tcp FIN-WAIT-1 (...) timer:(persist,21sec,7) (...) notsent:98333 (...)
  (...)
        infi rx server       [FAIL] got 0 infinite map[s] RX expected 1

The root cause has been confirmed with a Packetdrill script, a variant
of the new dss_infinite_map_mss_server.pkt test from the MPTCP
Packetdrill tests, with an MP_FAIL received before any data, and a cwnd
of 1: without this fix, the rest of the infinite mapping, after the
first MSS, was never sent:

  IpFragFails                     2                  0.0
  (...) timer:(persist,305ms,1) (...) cwnd:2 (...) notsent:1564 (...)
  infinite_map_stall-v4.pkt:27: error handling packet: Timed out waiting for packet

To fix this issue, limit the skb carrying the infinite mapping to one
MSS, as computed before the fallback.

A side effect: when the last unsent skb is bigger than one MSS, the
infinite mapping is now put on a new skb. This unsent skb is then sent
without DSS after the fallback, as it was already the case for the ones
before it, and the peer falls back before receiving the infinite
mapping.

Fixes: 1e39e5a32ad7 ("mptcp: infinite mapping sending")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue causing a flaky selftest
---
 net/mptcp/protocol.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index d16269d27b1d..e2fb81f52df2 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1483,6 +1483,12 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 	info->mss_now = tcp_send_mss(ssk, &info->size_goal, info->flags);
 	copy = info->size_goal;
 
+	/* After the fallback, the MSS no longer includes the DSS option of the
+	 * infinite mapping: send it in a single segment.
+	 */
+	if (unlikely(mptcp_subflow_ctx(ssk)->send_infinite_map))
+		copy = info->mss_now;
+
 	skb = tcp_write_queue_tail(ssk);
 	if (skb && copy > skb->len) {
 		/* Limit the write to the size available in the

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 39/62] mptcp: keep room for infinite map after fallback
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (37 preceding siblings ...)
  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-21  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 40/62] mptcp: do not fallback while old data is in flight Matthieu Baerts (NGI0)
                   ` (22 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

After an MP_FAIL, the infinite mapping is sent with the next data. If
the MPTCP socket falls back to TCP in the meantime, e.g. after having
received data without DSS, the size of the next skb is computed without
room for the DSS option, as no MPTCP options are sent after a fallback.
But this skb still carries the infinite mapping, with its DSS option:
its segments are then bigger than the MTU, and dropped, while the next
ones wait for them. The connection then stalls.

Keep room for the DSS option while the infinite mapping is still to be
sent, when computing the MSS.

This issue has been found by Sashiko, while reviewing "mptcp: send the
infinite map in a single segment", and confirmed with a new Packetdrill
test: an MP_FAIL is received before any data, then data without DSS.
Without this patch, the infinite mapping was never sent:

  dss_infinite_map_after_fallback_server.pkt:27: error handling packet: Timed out waiting for packet

Fixes: 1e39e5a32ad7 ("mptcp: infinite mapping sending")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue spotted by Sashiko
---
 net/mptcp/options.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 736e55532296..6b1a3994fb49 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -891,9 +891,11 @@ int mptcp_established_options(struct sock *sk, struct sk_buff *skb,
 	opts->suboptions = 0;
 
 	/* Force later mptcp_write_options(), but do not use any actual
-	 * option space.
+	 * option space, except for an infinite mapping still to be sent.
 	 */
-	if (unlikely(__mptcp_check_fallback(msk) && !mptcp_check_infinite_map(skb)))
+	if (unlikely(__mptcp_check_fallback(msk) &&
+		     !mptcp_check_infinite_map(skb) &&
+		     (skb || !subflow->send_infinite_map)))
 		return 0;
 
 	if (unlikely(skb && TCP_SKB_CB(skb)->tcp_flags & TCPHDR_RST)) {

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 40/62] mptcp: do not fallback while old data is in flight
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (38 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 39/62] mptcp: keep room for infinite map after fallback Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` 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)
                   ` (21 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

If an established MPTCP connection falls back to TCP while a zero window
probe or reinjected data is queued or in flight, recv() can return data
twice with no error, so the stream is silently corrupted.

After a fallback mptcp_established_options() writes a DSS option only
for an infinite mapping, so an skb that mptcp_sendmsg_frag() queued with
a mapping to data sequence numbers (DSN) is sent without that mapping.
The receiver treats the bytes of the subflow, in sequence order, as the
rest of the stream, so a fallback is only correct if the subflow carries
each byte of the stream once. But allow_infinite_fallback, the flag that
permits a fallback, stays set in two cases in which old data is queued
again on the only subflow.

First, a zero window probe is a copy of the next unsent byte, mapped to
the last acknowledged DSN so that the peer drops it as a duplicate.
Second, when a subflow whose MP_JOIN handshake has failed is closed,
__mptcp_retransmit_pending_data() marks all data that has no DATA_ACK
yet as unsent, although no second subflow has joined. If the sender
falls back while such bytes are queued, they are sent without their
mapping and the receiver delivers them as new data, as here for a probe:

    sender                            receiver
    ======                            ========
    queue a probe, a copy of byte N
    get data with no DSS, fall back
                                      read, open the window
    send the probe with no DSS
                                      no DSS: fall back
                                      deliver byte N
    send byte N as data
                                      deliver byte N again /* corrupt */

The fix used here is to refuse the fallback while old data is in flight:
- when mptcp_sendmsg_frag() maps bytes to a DSN below snd_nxt of the
  MPTCP socket, set the new bit old_data_pending of the subflow, and
  store the TCP sequence number after these bytes in its new member
  old_data_end
- clear the bit in mptcp_incoming_options() when a segment with a DSS,
  other than an infinite mapping, acknowledges that sequence number
- make mptcp_try_fallback() fail while the bit is set, so that its
  callers reset the subflow
- delay the infinite mapping that answers an MP_FAIL, and the fallback
  that comes with it, to the first data that is queued with the bit
  clear, and send plain mappings until then
- after a fallback, skip data below snd_nxt in mptcp_sendmsg_frag(): a
  reinjection that has not reached the subflow yet does not set the bit

This only prevents a fallback of this side: if a middlebox removes the
DSS of these old bytes, the peer can still fall back on its own, and
deliver them as new data, as it cannot tell that they are old. The next
commits limit this case, but cannot prevent it entirely.

A consequence: if the old data reached the peer with its mapping, but
the DSS acknowledging it is still on its way back, or lost its options,
a fallback attempted meanwhile resets the subflow, although it would
have been safe. This window lasts about one round trip, or as long as
the acknowledgments lose their options.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch:
between two unmodified Linux hosts, nftables removing the MPTCP options,
e.g. while a zero window probe is pending, or after a failed MP_JOIN.
Without this patch, the reader got some data twice, with a regular end
of file: the stream was silently corrupted:

  receiver   4.692: READ-TOTAL outcome iii-repeat-or-gap bytes 8388609 of 8388608 missing 0 twice 1 [...] end: eof
  [...]
  receiver   8.611: READ-TOTAL outcome iii-repeat-or-gap bytes 26000 of 14000 missing 0 twice 12000 [...] end: eof

Note for the backports: this patch depends on commit 119d51e225fe
("mptcp: fallback when MPTCP opts are dropped after 1st data") and
commit f8a1d9b18c5e ("mptcp: make fallback action and fallback decision
atomic"), two fixes which may have already been backported: they allowed
the fallback in the reproduced cases, once data has been acknowledged
without checksums, and after a failed MP_JOIN.

Fixes: 1e39e5a32ad7 ("mptcp: infinite mapping sending")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comments. Move old_data_end to an existing hole, after
  subflow_id. Commit message: mention the reset that can now replace a
  safe fallback + how the issue was found, and its symptoms + note for
  the backports. Moved before "mptcp: continue the last mapping after a
  fallback". Commit message: the peer can still fall back alone. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: commit message: the peer can still fall back alone (Clashiko). Only
    clamp to one MSS when sending the infinite mapping (Sashiko)

Note (Sashiko on v1): an infinite mapping can stay pending, but nothing
waits for it: an MP_FAIL is only accepted before any join or MPTCP-level
retransmission, so TCP retransmits the data in flight.
---
 net/mptcp/options.c  |  6 ++++++
 net/mptcp/protocol.c | 20 ++++++++++++++++++--
 net/mptcp/protocol.h |  9 ++++++++-
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 6b1a3994fb49..9133e3d6e5d9 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -1333,6 +1333,12 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 			return true;
 	}
 
+	/* DSS acking the old data, not an infinite map: no peer fallback */
+	if (unlikely(subflow->old_data_pending) &&
+	    !(mp_opt.use_map && !mp_opt.data_len) &&
+	    !before(TCP_SKB_CB(skb)->ack_seq, subflow->old_data_end))
+		subflow->old_data_pending = 0;
+
 	/* we can't wait for recvmsg() to update the ack_seq, otherwise
 	 * monodirectional flows will stuck
 	 */
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index e2fb81f52df2..95257ec8537a 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1486,9 +1486,16 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 	/* After the fallback, the MSS no longer includes the DSS option of the
 	 * infinite mapping: send it in a single segment.
 	 */
-	if (unlikely(mptcp_subflow_ctx(ssk)->send_infinite_map))
+	if (unlikely(mptcp_subflow_ctx(ssk)->send_infinite_map &&
+		     !mptcp_subflow_ctx(ssk)->old_data_pending))
 		copy = info->mss_now;
 
+	/* after a fallback, the subflow got all data below snd_nxt already */
+	if (unlikely(__mptcp_check_fallback(msk) &&
+		     before64(data_seq, msk->snd_nxt)))
+		return min_t(u64, msk->snd_nxt - data_seq,
+			     info->limit - info->sent);
+
 	skb = tcp_write_queue_tail(ssk);
 	if (skb && copy > skb->len) {
 		/* Limit the write to the size available in the
@@ -1569,6 +1576,12 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 	TCP_SKB_CB(skb)->end_seq += copy;
 	tcp_skb_pcount_set(skb, 0);
 
+	/* old data mapped again: no fallback until acked with a DSS */
+	if (unlikely(before64(data_seq, msk->snd_nxt))) {
+		mptcp_subflow_ctx(ssk)->old_data_end = tcp_sk(ssk)->write_seq;
+		mptcp_subflow_ctx(ssk)->old_data_pending = 1;
+	}
+
 	/* on skb reuse we just need to update the DSS len */
 	if (reuse_skb) {
 		TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_PSH;
@@ -1599,7 +1612,10 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 out:
 	if (READ_ONCE(msk->csum_enabled))
 		mptcp_update_data_checksum(skb, copy);
-	if (mptcp_subflow_ctx(ssk)->send_infinite_map)
+
+	/* the infinite map implies a fallback: wait for old data acks */
+	if (mptcp_subflow_ctx(ssk)->send_infinite_map &&
+	    !mptcp_subflow_ctx(ssk)->old_data_pending)
 		mptcp_update_infinite_map(msk, ssk, mpext);
 	trace_mptcp_sendmsg_frag(mpext);
 	mptcp_subflow_ctx(ssk)->rel_write_seq += copy;
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 888ee9d66967..6dbd912e08d8 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -605,7 +605,8 @@ struct mptcp_subflow_context {
 		is_mptfo : 1,	    /* subflow is doing TFO */
 		mpc_drop : 1,	    /* the MPC option has been dropped in a rtx */
 		resetting : 1,	    /* subflow is resetting */
-		__unused : 9;
+		old_data_pending : 1, /* old_data_end not acked with a DSS */
+		__unused : 8;
 	bool	data_avail;
 	bool	scheduled;
 	bool	pm_listener;	    /* a listener managed by the kernel PM? */
@@ -633,6 +634,7 @@ struct mptcp_subflow_context {
 				     */
 
 	u32	subflow_id;
+	u32	old_data_end;	    /* TCP write_seq after the last old data */
 
 	unsigned long	fail_tout;
 
@@ -1346,6 +1348,11 @@ static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib)
 	struct mptcp_sock *msk;
 
 	msk = mptcp_sk(sk);
+
+	/* queued old data would be sent without mapping after a fallback */
+	if (subflow->old_data_pending && !__mptcp_check_fallback(msk))
+		return false;
+
 	if (!__mptcp_try_fallback(msk, fb_mib))
 		return false;
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 41/62] mptcp: stop resending data to a peer that fell back
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (39 preceding siblings ...)
  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 ` 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)
                   ` (20 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

recv() on an established MPTCP connection can silently return data that
it has returned before, again and again, if the receiver falls back to
TCP and the sender does not.

While no DATA_ACK arrives, the MPTCP retransmit timer makes
mptcp_sendmsg_frag() queue old data on the subflow again: either
fragments from __mptcp_retrans(), or a zero window probe. That is only
correct while the receiver reads the DSS mapping of these bytes and
drops them as duplicates: a receiver that has fallen back to TCP
delivers them as new data. But mptcp_incoming_options() ignores a bare
ACK, one with no MPTCP option, on a fully established subflow, so a
sender that gets only bare ACKs from that receiver stays in MPTCP mode:

    sender                            receiver
    ======                            ========
    send bytes N to M
    (a middlebox removes the DSS)
                                      no DSS: fall back
                                      deliver N to M, send a bare ACK
    no DATA_ACK, the timer expires
    send bytes N to M again
                                      deliver N to M again  <-- wrong
                                      send a bare ACK

The fix used here is to:
- reset the subflow, with the reason "middlebox interference", when
  mptcp_sendmsg_frag() has more old data to queue and only bare ACKs
  have acknowledged the old data queued so far. The test reads
  old_data_pending, which the earlier commit "mptcp: do not fallback
  while old data is in flight" sets when old data is queued. That commit
  clears it when a segment with a DSS, other than an infinite mapping,
  acknowledges old_data_end, the TCP sequence number after that data.
  The reset is counted in FallbackFailed: the peer has likely fallen
  back, but this side cannot
- clear old_data_pending for a segment with any other MPTCP option too,
  in mptcp_incoming_options(). An infinite mapping stays the exception
- skip a zero window probe while the TCP retransmit queue of the subflow
  holds data: the MPTCP retransmit timer, armed when a push leaves data
  behind, tries again later
- drop the segment in mptcp_incoming_options() if the push done when
  processing its DATA_ACK resets the subflow: it is not queued on the
  closed subflow then, as with a reset done earlier

This limits the repeats, but does not prevent the first one: data that
was new when it was first sent does not set old_data_pending, so its
first MPTCP-level retransmission is still delivered twice by a peer that
has fallen back. After a failed MP_JOIN, more of the reinjected data can
be. The same is true for a zero window probe whose DSS is removed: a
peer falling back on it delivers it as the next byte, then this byte
again, when it is sent as new data.

A consequence: a peer still in MPTCP mode, whose options are removed on
the way back for a while only, recovered once the options came back.
Its subflow is now reset as soon as more old data is due.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch:
between two unmodified Linux hosts, nftables removing the MPTCP options
in the middle of the transfer, so that only the receiver falls back.
Without this patch, the reader got the same data again and again, here
65 MB more than once in 120 seconds:

  receiver 127.514: READ-TOTAL outcome iii-repeat-or-gap bytes 68255744 of 8388608 missing 0 twice 65650688 [...]
  [...] took 120.0 s end: limit: still data after 120 s

Fixes: 119d51e225fe ("mptcp: fallback when MPTCP opts are dropped after 1st data")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comments, also in struct mptcp_subflow_context. No timer
  arming when a probe is skipped: "mptcp: arm the rtx timer if a push
  leaves data behind" already does it. Commit message: the first repeat
  is still delivered, and a peer that loses its options for a while only
  is now reset + how the issue was found, and its symptoms. Count the
  reset in MPTCP_MIB_FALLBACKFAILED. Drop the segment if the push resets
  the subflow, update comments, and commit message: the zero window probe
  whose DSS is removed. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: drop the segment if the push resets the subflow, update comments,
    and mention the probe case (Sashiko, Clashiko)
---
 net/mptcp/mib.h      |  2 +-
 net/mptcp/options.c  | 16 ++++++++++------
 net/mptcp/protocol.c | 21 ++++++++++++++++++++-
 net/mptcp/protocol.h |  2 +-
 4 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h
index 1ebdb55e9534..34a065b9e8dd 100644
--- a/net/mptcp/mib.h
+++ b/net/mptcp/mib.h
@@ -93,7 +93,7 @@ enum linux_mptcp_mib_field {
 	MPTCP_MIB_DSSFALLBACK,		/* Bad or missing DSS */
 	MPTCP_MIB_DSSRESET,		/* MP_RST: bad data mapping */
 	MPTCP_MIB_SIMULTCONNFALLBACK,	/* Simultaneous connect */
-	MPTCP_MIB_FALLBACKFAILED,	/* Can't fallback due to msk status */
+	MPTCP_MIB_FALLBACKFAILED,	/* Can't fallback: msk/subflow status */
 	MPTCP_MIB_WINPROBE,		/* MPTCP-level zero window probe */
 	MPTCP_MIB_BACKLOGDROP,		/* Backlog over memory limit */
 	MPTCP_MIB_RCVPRUNED,		/* Dropped due to memory constraints */
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 9133e3d6e5d9..f9b65d0c6290 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -1287,6 +1287,12 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 	if (!check_fully_established(msk, sk, subflow, skb, &mp_opt))
 		return sk->sk_state != TCP_CLOSE;
 
+	/* MPTCP opt acking the old data, not an infinite map: no fallback */
+	if (unlikely(subflow->old_data_pending) && mp_opt.suboptions &&
+	    !(mp_opt.use_map && !mp_opt.data_len) &&
+	    !before(TCP_SKB_CB(skb)->ack_seq, subflow->old_data_end))
+		subflow->old_data_pending = 0;
+
 	if (unlikely(mp_opt.suboptions != OPTION_MPTCP_DSS)) {
 		if ((mp_opt.suboptions & OPTION_MPTCP_FASTCLOSE) &&
 		    READ_ONCE(msk->local_key) == mp_opt.fc_recv_key) {
@@ -1333,12 +1339,6 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 			return true;
 	}
 
-	/* DSS acking the old data, not an infinite map: no peer fallback */
-	if (unlikely(subflow->old_data_pending) &&
-	    !(mp_opt.use_map && !mp_opt.data_len) &&
-	    !before(TCP_SKB_CB(skb)->ack_seq, subflow->old_data_end))
-		subflow->old_data_pending = 0;
-
 	/* we can't wait for recvmsg() to update the ack_seq, otherwise
 	 * monodirectional flows will stuck
 	 */
@@ -1359,6 +1359,10 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 		return true;
 	}
 
+	/* the push from ack_update_msk() can reset the subflow */
+	if (unlikely(sk->sk_state == TCP_CLOSE))
+		return false;
+
 	mpext = skb_ext_add(skb, SKB_EXT_MPTCP);
 	if (!mpext)
 		return false;
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 95257ec8537a..b60c54ea4d3f 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1455,6 +1455,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 			      struct mptcp_data_frag *dfrag,
 			      struct mptcp_sendmsg_info *info)
 {
+	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
 	u64 data_seq = dfrag->data_seq + info->sent;
 	int offset = dfrag->offset + info->sent;
 	struct mptcp_sock *msk = mptcp_sk(sk);
@@ -1545,11 +1546,29 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 			return 0;
 		}
 
+		/* a new probe would move old_data_end: one at a time */
+		if (!tcp_rtx_queue_empty(ssk)) {
+			tcp_remove_empty_skb(ssk);
+			return 0;
+		}
+
 		zero_window_probe = true;
 		data_seq = snd_una - 1;
 		copy = 1;
 	}
 
+	/* old data acked without MPTCP opts: the peer may have fallen back */
+	if (unlikely(before64(data_seq, msk->snd_nxt) &&
+		     subflow->old_data_pending &&
+		     !before(tcp_sk(ssk)->snd_una, subflow->old_data_end))) {
+		tcp_remove_empty_skb(ssk);
+		MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_FALLBACKFAILED);
+		subflow->reset_transient = 0;
+		subflow->reset_reason = MPTCP_RST_EMIDDLEBOX;
+		mptcp_subflow_reset(ssk);
+		return -EAGAIN;
+	}
+
 	copy = min_t(size_t, copy, info->limit - info->sent);
 
 	/* like TCP, allow some progress up to tcp_wmem[0] */
@@ -1576,7 +1595,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 	TCP_SKB_CB(skb)->end_seq += copy;
 	tcp_skb_pcount_set(skb, 0);
 
-	/* old data mapped again: no fallback until acked with a DSS */
+	/* old data mapped again: no fallback until acked with MPTCP opts */
 	if (unlikely(before64(data_seq, msk->snd_nxt))) {
 		mptcp_subflow_ctx(ssk)->old_data_end = tcp_sk(ssk)->write_seq;
 		mptcp_subflow_ctx(ssk)->old_data_pending = 1;
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 6dbd912e08d8..dfeabe03180b 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -605,7 +605,7 @@ struct mptcp_subflow_context {
 		is_mptfo : 1,	    /* subflow is doing TFO */
 		mpc_drop : 1,	    /* the MPC option has been dropped in a rtx */
 		resetting : 1,	    /* subflow is resetting */
-		old_data_pending : 1, /* old_data_end not acked with a DSS */
+		old_data_pending : 1, /* old data not acked with MPTCP opts */
 		__unused : 8;
 	bool	data_avail;
 	bool	scheduled;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 42/62] mptcp: don't resend data acked without MPTCP opts
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (40 preceding siblings ...)
  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 ` 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)
                   ` (19 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

The previous commit resets the subflow, instead of resending data that
has been acked without MPTCP options, but only if this data had already
been resent. Data acked without these options the first time was still
resent once: a peer that had fallen back to TCP alone, e.g. because a
middlebox removed the DSS of new data after a zero window probe,
delivered it a second time to the application, without error.

Track the TCP sequence number acked with MPTCP options, to also catch
data acked without them the first time. Only before any MP_JOIN subflow
has been established: after that, the peer can no longer fall back to
TCP, and the Data ACK can be omitted when its value does not advance,
see RFC 8684, sections 3.7 and 3.3.2. On a single subflow, a peer
omitting the Data ACK like this can then see its subflow reset if this
Data ACK is lost, as before at the next resend, or if it drops data
after having acked it at the TCP level.

This issue has been reported by Clashiko, and reproduced with a new
Packetdrill test: data acked without MPTCP options was resent at the
MPTCP level, instead of a reset:

  dss_resend_after_bare_ack_reset_server.pkt:28: error handling packet: live packet payload: expected 0 bytes vs actual 1000 bytes

Two other new tests check that this data is still resent after a join,
but not after a join rejected by the peer.

Fixes: 119d51e225fe ("mptcp: fallback when MPTCP opts are dropped after 1st data")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue spotted by Clashiko
---
 net/mptcp/options.c  | 19 ++++++++++++++-----
 net/mptcp/protocol.c | 11 ++++++++---
 net/mptcp/protocol.h |  2 ++
 net/mptcp/subflow.c  |  2 ++
 4 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index f9b65d0c6290..05b9c66aaed6 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -1055,6 +1055,10 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,
 		WARN_ONCE(1, "bogus mpc option on established client sk");
 
 set_fully_established:
+	/* the peer can no longer fall back to TCP */
+	if (subflow->request_join)
+		set_bit(MPTCP_JOINED, &msk->flags);
+
 	if (mp_opt->deny_join_id0)
 		WRITE_ONCE(msk->pm.remote_deny_join_id0, true);
 
@@ -1287,11 +1291,16 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 	if (!check_fully_established(msk, sk, subflow, skb, &mp_opt))
 		return sk->sk_state != TCP_CLOSE;
 
-	/* MPTCP opt acking the old data, not an infinite map: no fallback */
-	if (unlikely(subflow->old_data_pending) && mp_opt.suboptions &&
-	    !(mp_opt.use_map && !mp_opt.data_len) &&
-	    !before(TCP_SKB_CB(skb)->ack_seq, subflow->old_data_end))
-		subflow->old_data_pending = 0;
+	/* MPTCP opts, not an infinite map: the peer did not fall back */
+	if (mp_opt.suboptions && !(mp_opt.use_map && !mp_opt.data_len)) {
+		u32 ack_seq = TCP_SKB_CB(skb)->ack_seq;
+
+		if (after(ack_seq, subflow->opt_ack_seq))
+			subflow->opt_ack_seq = ack_seq;
+		if (unlikely(subflow->old_data_pending) &&
+		    !before(ack_seq, subflow->old_data_end))
+			subflow->old_data_pending = 0;
+	}
 
 	if (unlikely(mp_opt.suboptions != OPTION_MPTCP_DSS)) {
 		if ((mp_opt.suboptions & OPTION_MPTCP_FASTCLOSE) &&
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index b60c54ea4d3f..d90e6a5cc9ff 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1090,6 +1090,9 @@ static void mptcp_subflow_joined(struct mptcp_sock *msk, struct sock *ssk)
 {
 	mptcp_subflow_ctx(ssk)->map_seq = READ_ONCE(msk->ack_seq);
 	msk->allow_infinite_fallback = false;
+	/* an active join is added once fully established, see options.c */
+	if (!mptcp_subflow_ctx(ssk)->request_join)
+		set_bit(MPTCP_JOINED, &msk->flags);
 	mptcp_event(MPTCP_EVENT_SUB_ESTABLISHED, msk, ssk, GFP_ATOMIC);
 }
 
@@ -1557,10 +1560,12 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 		copy = 1;
 	}
 
-	/* old data acked without MPTCP opts: the peer may have fallen back */
+	/* data acked without MPTCP opts: the peer may have fallen back, only
+	 * possible before a join, see RFC 8684
+	 */
 	if (unlikely(before64(data_seq, msk->snd_nxt) &&
-		     subflow->old_data_pending &&
-		     !before(tcp_sk(ssk)->snd_una, subflow->old_data_end))) {
+		     !test_bit(MPTCP_JOINED, &msk->flags) &&
+		     after(tcp_sk(ssk)->snd_una, subflow->opt_ack_seq))) {
 		tcp_remove_empty_skb(ssk);
 		MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_FALLBACKFAILED);
 		subflow->reset_transient = 0;
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index dfeabe03180b..d0ae782c9ade 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -118,6 +118,7 @@
 #define MPTCP_WORK_CLOSE_SUBFLOW 3
 #define MPTCP_RTX_ENABLED	4
 #define MPTCP_ORPHAN_COUNTED	5
+#define MPTCP_JOINED		6
 
 /* MPTCP socket release cb flags */
 #define MPTCP_PUSH_PENDING	1
@@ -648,6 +649,7 @@ struct mptcp_subflow_context {
 	int     cached_sndbuf;	    /* sndbuf size when last synced with the msk sndbuf,
 				     * protected by the msk socket lock
 				     */
+	u32	opt_ack_seq;	    /* highest TCP ack_seq with MPTCP opts */
 
 	struct	sock *tcp_sock;	    /* tcp sk backpointer */
 	struct	sock *conn;	    /* parent mptcp_sock */
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index a216d88d35ee..3590c1207e88 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -587,6 +587,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
 
 	msk = mptcp_sk(parent);
 	subflow->rel_write_seq = 1;
+	subflow->opt_ack_seq = tcp_sk(sk)->snd_una;
 	subflow->conn_finished = 1;
 	subflow->ssn_offset = TCP_SKB_CB(skb)->seq;
 	pr_debug("subflow=%p synack seq=%x\n", subflow, subflow->ssn_offset);
@@ -2161,6 +2162,7 @@ static void subflow_ulp_clone(const struct request_sock *req,
 	new_ctx->tcp_state_change = old_ctx->tcp_state_change;
 	new_ctx->tcp_error_report = old_ctx->tcp_error_report;
 	new_ctx->rel_write_seq = 1;
+	new_ctx->opt_ack_seq = tcp_rsk(req)->snt_isn + 1;
 
 	if (subflow_req->mp_capable) {
 		/* see comments in subflow_syn_recv_sock(), MPTCP connection

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 43/62] mptcp: pm: kernel: don't count signal+subflow ID 0 endp
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (41 preceding siblings ...)
  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 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 44/62] selftests: mptcp: join: check re-adding " Matthieu Baerts (NGI0)
                   ` (18 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Josef Bacik

From: Josef Bacik <josef@toxicpanda.com>

local_addr_used must not be incremented for the endpoint of the initial
subflow, because __mark_subflow_endp_available() does not decrement it
for ID 0. mptcp_pm_create_subflow_or_signal_addr() tells that endpoint
by local.addr.id == msk->mpc_endpoint_id, in the loop that creates the
subflows and after it.

For an endpoint with both the signal and the subflow flag that
comparison comes too late: the part that announces the address has
replaced local.addr.id by 0 already. So the counter goes up each time
such an endpoint is removed and added again while a connection that
started from its address is alive, and never comes down. When it has
reached the number of subflow endpoints, the connection does not use any
new endpoint: after four rounds local_addr_used was 5 instead of 1, and
an endpoint added then got no subflow.

ID 0 can't be the ID of any other endpoint: look at that, after the
replacement.

This issue has been found with the help of an LLM. It has been
reproduced with the modified "delete and re-add" subtest of
mptcp_join.sh, from the next commit: without this patch, the subflow of
the ID 0 endpoint was not created again at the third round,
local_addr_used being above local_addr_max:

  # 002 delete and re-add
  [...]
  #       after re-add id 0 (3)               [FAIL] got 2:2 subflows expected 3
  [...]
  [...] subflows:2 [...] local_addr_used:4 local_addr_max:3 [...]

The check after the loop comes from commit 579a752464a6 ("mptcp: pm:
in-kernel: always mark signal+subflow endp as used"), which is in all
the stable versions having the commit below.

Fixes: 9366922adc6a ("mptcp: pm: fix ID 0 endp usage after multiple re-creations")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
[ Keep the original one-line comment. Commit message: 'behind it' ->
  'after it' + how the issue was found, and its symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm_kernel.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
index 73261685ae4c..47c6ccb0a29e 100644
--- a/net/mptcp/pm_kernel.c
+++ b/net/mptcp/pm_kernel.c
@@ -411,7 +411,9 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 		/* Special case for ID0: set the correct ID */
 		if (local.addr.id == msk->mpc_endpoint_id)
 			local.addr.id = 0;
-		else /* local_addr_used is not decr for ID 0 */
+
+		/* local_addr_used is not decr for ID 0 */
+		if (local.addr.id)
 			msk->pm.local_addr_used++;
 
 		nr = fill_remote_addresses_vec(msk, &local.addr, fullmesh,
@@ -432,7 +434,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 	 * case. This avoids issues later when removing the endpoint and calling
 	 * __mark_subflow_endp_available(), which expects the increment here.
 	 */
-	if (signal_and_subflow && local.addr.id != msk->mpc_endpoint_id)
+	if (signal_and_subflow && local.addr.id)
 		msk->pm.local_addr_used++;
 
 	mptcp_pm_nl_check_work_pending(msk);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 44/62] selftests: mptcp: join: check re-adding signal+subflow ID 0 endp
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (42 preceding siblings ...)
  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 ` 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)
                   ` (17 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

This test extends "delete and re-add" to validate the previous commit:
when the endpoint linked to the initial subflow (ID 0) had both the
signal and subflow flags, it was counted as used each time it was
re-added, while this counter is not decremented for this special
endpoint. Once the counter reached the number of subflow endpoints, no
more subflows were created.

From the second round, this endpoint is now re-added with the signal
flag too: without the previous commit, the subflow is not re-created at
the third round.

The ADD_ADDR sent at these two rounds are dropped, and not
retransmitted: if the server received them before the new subflow, it
would try to connect back to the address and port of the client, and
fail, which would change the counters. If they cannot be dropped, e.g.
with an older version of nft, the signal flag is not added, and the
subtest is marked as skipped.

The 'Fixes' tag here below is the same as the one from the previous
commit: this patch here is not fixing anything wrong in the selftests,
but it validates the previous fix for an issue introduced by this commit
ID.

Fixes: 9366922adc6a ("mptcp: pm: fix ID 0 endp usage after multiple re-creations")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: skip the signal part if the nft rule cannot be added (Clashiko)
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index c3ccce96b45b..4c045532f137 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -4387,17 +4387,26 @@ endpoint_tests()
 		ip netns exec "${ns2}" nft insert rule ip filter OUTPUT \
 			ip saddr 10.0.1.2 meta l4proto tcp \
 			"${RM_ADDR_OFFSETS}" drop || nft=0
-		local i
+		# No ADD_ADDR to ns1: it could try to connect back to ns2's port
+		local i flags="subflow" signal="signal,subflow"
+		ip netns exec "${ns2}" sysctl -q net.mptcp.add_addr_timeout=0
+		if ! ip netns exec "${ns2}" nft insert rule ip filter OUTPUT \
+				meta l4proto tcp \
+				tcp option mptcp subtype add-addr drop; then
+			mark_as_skipped "unable to set the 'add addr' rule"
+			signal="subflow"
+		fi
 		for i in $(seq 3); do
 			pm_nl_del_endpoint $ns2 1 10.0.1.2
 			sleep 0.5
 			chk_subflow_nr "after delete id 0 ($i)" 2
 			chk_mptcp_info subflows 2 subflows 2 # only decr for additional sf
 
-			pm_nl_add_endpoint $ns2 10.0.1.2 id 1 dev ns2eth1 flags subflow
+			pm_nl_add_endpoint $ns2 10.0.1.2 id 1 dev ns2eth1 flags "${flags}"
 			wait_mpj $((3 + i))
 			chk_subflow_nr "after re-add id 0 ($i)" 3
 			chk_mptcp_info subflows 3 subflows 3
+			flags="${signal}" # ID 0 not counted as used either
 		done
 		[ "${nft}" = 1 ] && ip netns exec "${ns2}" nft flush chain ip filter OUTPUT
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 45/62] tcp: do not pass a BPF reqsk to an MPTCP listener
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (43 preceding siblings ...)
  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 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 46/62] mptcp: reclaim forward memory after coalescing skbs Matthieu Baerts (NGI0)
                   ` (16 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

A slab-out-of-bounds write and a panic can occur if a tc BPF program
that validates SYN cookies assigns an ACK to a TCP listener, and the ACK
then goes to an MPTCP listener of the same SO_REUSEPORT group.

bpf_sk_assign_tcp_reqsk() attaches a plain TCP request sock to the skb,
and returns -EINVAL if the program passes in an MPTCP listener. But
inet_steal_sock() and inet6_steal_sock() select a listener again from
the SO_REUSEPORT group of the listener that was passed in, and the
result can be an MPTCP listener. cookie_bpf_check() then passes the
request sock to mptcp_subflow_init_cookie_req(), which writes to members
of the larger struct mptcp_subflow_request_sock, so the writes can land
in the next object of the slab.

The fix used here is to drop the segment in cookie_bpf_check() if the
listener is an MPTCP listener.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch:
a tc BPF program validating SYN cookies -- the one from the BPF
selftests -- and an SO_REUSEPORT group with a TCP listener and an MPTCP
one, the latter being selected. With KASAN, the original version of this
patch reported:

  BUG: KASAN: slab-out-of-bounds in mptcp_subflow_init_cookie_req
  Write of size 1 at addr ... by task python3
   mptcp_subflow_init_cookie_req
   cookie_bpf_check
   cookie_v4_check
   tcp_v4_do_rcv
   tcp_v4_rcv

Without debug options, and with request sockets of half-open connections
next to the corrupted one, the kernel panicked a second later, when the
timer of a request socket fired:

  BUG: kernel NULL pointer dereference, address: 000000000000058f
  #PF: supervisor read access in kernel mode
  #PF: error_code(0x0000) - not-present page
  Oops: Oops: 0000 [#1] SMP NOPTI
  CPU: 3 UID: 0 PID: 0 Comm: swapper/3 Not tainted 7.4.0-rc1+ #1 PREEMPT(lazy)
  RIP: 0010:tcp_syn_ack_timeout+0xd/0x30
  Call Trace:
   <IRQ>
   reqsk_timer_handler+0x22e/0x500
   call_timer_fn+0x2a/0x140
   __run_timers+0x1f7/0x280
   run_timer_softirq+0x49/0xf0
   handle_softirqs+0xfa/0x300
   __irq_exit_rcu+0xb5/0xf0
   sysvec_apic_timer_interrupt+0x73/0x80
   </IRQ>
  Kernel panic - not syncing: Fatal exception in interrupt

Fixes: e472f88891ab ("bpf: tcp: Support arbitrary SYN Cookie.")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comment. Commit message: how the issue was found, and its
  symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/ipv4/syncookies.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 89169c82431c..f39600ee3f17 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -312,7 +312,8 @@ struct request_sock *cookie_bpf_check(struct sock *sk, struct sk_buff *skb)
 	skb->sk = NULL;
 	skb->destructor = NULL;
 
-	if (cookie_tcp_reqsk_init(sk, skb, req)) {
+	/* reuseport can pick an MPTCP listener: req is too small for it */
+	if (sk_is_mptcp(sk) || cookie_tcp_reqsk_init(sk, skb, req)) {
 		reqsk_free(req);
 		req = NULL;
 	}

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 46/62] mptcp: reclaim forward memory after coalescing skbs
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (44 preceding siblings ...)
  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-21  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 47/62] mptcp: don't charge a shared page twice at accept() Matthieu Baerts (NGI0)
                   ` (15 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

If MPTCP sockets receive many small segments whose data stays queued,
TCP can stall on the whole host, and an MPTCP server can be OOM killed
in its memory cgroup, although almost no memory is in use.

When the MPTCP socket (msk) takes over an skb from a subflow,
mptcp_borrow_fwdmem() adds skb->truesize to the sk_forward_alloc of the
msk, and the subflow reserves new memory for the next skb. Both
sk_forward_alloc and sk_rmem_alloc count against tcp_mem and the memory
cgroup, but only sk_rmem_alloc has a limit, sk_rcvbuf, so what queueing
the skb does not move to sk_rmem_alloc has to be released. But
mptcp_try_coalesce() moves only the increase in truesize of the skb that
receives the data, and skb_condense() in mptcp_data_queue_ofo() can
lower skb->truesize, so the rest piles up in sk_forward_alloc.

The fix used here is to return every whole page of sk_forward_alloc with
sk_mem_reclaim(), in mptcp_try_coalesce() once the merged skb is freed,
and in mptcp_data_queue_ofo() once the skb is queued.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch:
a remote peer sends 33000 segments of one byte after a hole in the data
sequence, which are merged in the out-of-order queue. Without this
patch, the memory forward-allocated by the MPTCP socket -- msk_f -- grew
with each merged segment, above 29 MB, versus 3200 bytes with it:

  SNAP label=stage1-1-connections tcp_mem_pages=7168 [...] msk_f=29445248 [...]
  [...] OFOQueue=33000 OFOMerge=32862 [...]

With more connections, the original version of this patch reported that
the TCP memory went above tcp_mem[2], stalling the other TCP
connections, or that the memory cgroup went above its limit.

Fixes: 9db5b3cec4ec ("mptcp: borrow forward memory from subflow")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comment. Commit message: the rest of the borrowed amount has
  to be released + how the issue was found, and its symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/protocol.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index d90e6a5cc9ff..adae675227df 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -197,6 +197,9 @@ static bool mptcp_try_coalesce(struct sock *sk, struct sk_buff *to,
 	sk_mem_charge(sk, delta);
 	kfree_skb_partial(from, fragstolen);
 
+	/* release what is left of the borrowed 'from' truesize */
+	sk_mem_reclaim(sk);
+
 	return true;
 }
 
@@ -422,6 +425,9 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *msk, struct sk_buff *skb)
 end:
 	skb_condense(skb);
 	skb_set_owner_r(skb, sk);
+
+	/* skb_condense() can shrink the truesize borrowed from the subflow */
+	sk_mem_reclaim(sk);
 }
 
 static void mptcp_init_skb(struct sock *ssk, struct sk_buff *skb, int offset,

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 47/62] mptcp: don't charge a shared page twice at accept()
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (45 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 46/62] mptcp: reclaim forward memory after coalescing skbs Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 48/62] mptcp: don't charge the backlog " Matthieu Baerts (NGI0)
                   ` (14 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

accept() of an MPTCP connection that has already received data can leak
one page of memory cgroup charge, and the leaked charges can get the
server OOM killed.

At accept(), __inet_accept() charges the MPTCP socket (msk) for the
memory that it holds, rounded up to whole pages, and
mptcp_graft_subflows() does the same for each subflow. A page is
uncharged only once, when the socket that holds it releases it, so
rounding up each socket on its own is only correct while each page
belongs to one socket. But for each skb that the msk takes over from a
subflow, it borrows skb->truesize bytes from the pages that the subflow
reserved, so the two can share a page:

    reserved by the subflow      4096 bytes  1 page
      now held by the msk         896 bytes  charged for 1 page
      still held by the subflow  3200 bytes  charged for 1 page

The fix used here is to keep a running sum of what the msk and its
subflows hold, and to let the new mptcp_charge_subflow() charge each
subflow only for the pages that it adds to the rounded-up sum.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch:
an MPTCP server in a memory cgroup, the first byte of the client
arriving before accept(). Without this patch, 4096 bytes stayed charged
to the memory cgroup for each connection, after its end:

  SNAP label=after-1000 rounds=1000 sockets_left_in_srv=0 [...] c_sock=4096000 [...]
  SNAP label=after-5000 rounds=5000 sockets_left_in_srv=0 [...] c_sock=20480000 [...]

With a memory limit, the original version of this patch reported that
the server was killed by the OOM killer after about 14,400 connections.

Fixes: 9db5b3cec4ec ("mptcp: borrow forward memory from subflow")
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comment. Commit message: how the issue was found, and its
  symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/protocol.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index adae675227df..8749ba146363 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -4636,10 +4636,26 @@ static int mptcp_listen(struct socket *sock, int backlog)
 	return err;
 }
 
+/* The msk and its subflows share pages: charge their rounded-up sum */
+static int mptcp_charge_subflow(struct sock *sk, struct sock *ssk, int mem)
+{
+	int new_mem = mem + ssk->sk_forward_alloc +
+		      atomic_read(&ssk->sk_rmem_alloc);
+	int amt = sk_mem_pages(new_mem) - sk_mem_pages(mem);
+	gfp_t gfp = GFP_KERNEL | __GFP_NOFAIL;
+
+	mem_cgroup_sk_inherit(sk, ssk);
+	if (amt > 0)
+		mem_cgroup_sk_charge(ssk, amt, gfp);
+	kmem_cache_charge(ssk, gfp);
+	return new_mem;
+}
+
 static void mptcp_graft_subflows(struct sock *sk)
 {
 	struct mptcp_subflow_context *subflow;
 	struct mptcp_sock *msk = mptcp_sk(sk);
+	int mem;
 
 	if (mem_cgroup_sockets_enabled) {
 		LIST_HEAD(join_list);
@@ -4657,6 +4673,9 @@ static void mptcp_graft_subflows(struct sock *sk)
 		__mptcp_flush_join_list(sk, &join_list);
 	}
 
+	/* What __inet_accept() just charged for the msk, before rounding up. */
+	mem = sk->sk_forward_alloc + atomic_read(&sk->sk_rmem_alloc);
+
 	mptcp_for_each_subflow(msk, subflow) {
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 
@@ -4672,7 +4691,7 @@ static void mptcp_graft_subflows(struct sock *sk)
 			goto unlock;
 
 		__mptcp_inherit_cgrp_data(sk, ssk);
-		__mptcp_inherit_memcg(sk, ssk, GFP_KERNEL);
+		mem = mptcp_charge_subflow(sk, ssk, mem);
 
 unlock:
 		release_sock(ssk);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 48/62] mptcp: don't charge the backlog twice at accept()
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (46 preceding siblings ...)
  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 ` 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)
                   ` (13 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

accept() can permanently overcharge the memory cgroup of an MPTCP
server, so the server can be OOM killed, if the new connection received
data while its MPTCP socket was locked.

The sockets of an MPTCP connection have no memory cgroup before
accept(), which then charges the sk_forward_alloc and the sk_rmem_alloc
of the MPTCP socket (msk) and of each subflow. mptcp_graft_subflows()
also charges msk->backlog_unaccounted: the truesize of the skbs that
__mptcp_add_backlog() queued while the socket lock of the msk was held
and their subflow had no memory cgroup. But the first charge already
covers each of these skbs that has not been freed, in the sk_rmem_alloc
of its subflow or of the msk, so no later uncharge matches the extra
charge.

The fix used here is to remove msk->backlog_unaccounted, its charge in
mptcp_graft_subflows() and the warning that tests it in
mptcp_can_spool_backlog(). An RFC patch [1] removes the same lines, as
part of another approach.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch,
on a kernel with the previous patch: 100,000 connections to an MPTCP
server in a memory cgroup. Without this patch, about 63 MB stayed
charged to this memory cgroup once all the connections were closed, and
to its parent after its removal:

  SNAP label=after-100000 rounds=100000 sockets_left_in_srv=0 tcp_mem_pages=0 [...] c_sock=63295488 [...]
  [...]
  SNAP label=c-removed rounds=100000 sockets_left_in_srv=0 tcp_mem_pages=0 c=removed [...] p_sock=63295488 [...]

And about 12 MB with only 50 connections, each getting 20,000 duplicates
of a byte before accept(), beside bare ACKs with RM_ADDR, which make the
MPTCP worker take the socket lock:

  SNAP label=after-50 rounds=50 sockets_left_in_srv=0 tcp_mem_pages=256 [...] c_sock=12881920 [...]

Fixes: 6228efe0cc01 ("mptcp: leverage the backlog for RX packet processing")
Link: https://lore.kernel.org/all/20260924080219.1036588-4-caixinchen1@huawei.com/ [1]
Signed-off-by: Chris Mason <mason@kernel.org>
[ No comment change: the commit message explains why the backlog is
  covered. Commit message: refer to the RFC [1] removing the same lines
  + how the issue was found, and its symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/protocol.c | 35 +----------------------------------
 net/mptcp/protocol.h |  1 -
 2 files changed, 1 insertion(+), 35 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 8749ba146363..9f5e8b5cde60 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -802,12 +802,6 @@ static void __mptcp_add_backlog(struct sock *sk,
 
 account:
 	WRITE_ONCE(msk->backlog_len, msk->backlog_len + delta);
-
-	/* Possibly not accept()ed yet, keep track of memory not CG
-	 * accounted, mptcp_graft_subflows() will handle it.
-	 */
-	if (!mem_cgroup_from_sk(ssk))
-		msk->backlog_unaccounted += delta;
 }
 
 static bool __mptcp_move_skbs_from_subflow(struct mptcp_sock *msk,
@@ -2454,12 +2448,6 @@ static bool mptcp_can_spool_backlog(struct sock *sk, struct list_head *skbs)
 {
 	struct mptcp_sock *msk = mptcp_sk(sk);
 
-	/* After CG initialization, subflows should never add skb before
-	 * gaining the CG themself.
-	 */
-	DEBUG_NET_WARN_ON_ONCE(msk->backlog_unaccounted && sk->sk_socket &&
-			       mem_cgroup_from_sk(sk));
-
 	if (list_empty(&msk->backlog_list))
 		return false;
 
@@ -4663,8 +4651,7 @@ static void mptcp_graft_subflows(struct sock *sk)
 		/* Subflows joining after __inet_accept() will get the
 		 * mem CG properly initialized at mptcp_finish_join() time,
 		 * but subflows pending in join_list need explicit
-		 * initialization before flushing `backlog_unaccounted`
-		 * or MPTCP can later unexpectedly observe unaccounted memory.
+		 * initialization by the loop below.
 		 */
 		mptcp_data_lock(sk);
 		list_splice_init(&msk->join_list, &join_list);
@@ -4696,26 +4683,6 @@ static void mptcp_graft_subflows(struct sock *sk)
 unlock:
 		release_sock(ssk);
 	}
-
-	if (mem_cgroup_sk_enabled(sk)) {
-		gfp_t gfp = GFP_KERNEL | __GFP_NOFAIL;
-		int amt;
-
-		/* Account the backlog memory; prior accept() is aware of
-		 * fwd and rmem only.
-		 */
-		mptcp_data_lock(sk);
-		amt = sk_mem_pages(sk->sk_forward_alloc +
-				   msk->backlog_unaccounted +
-				   atomic_read(&sk->sk_rmem_alloc)) -
-		      sk_mem_pages(sk->sk_forward_alloc +
-				   atomic_read(&sk->sk_rmem_alloc));
-		msk->backlog_unaccounted = 0;
-		mptcp_data_unlock(sk);
-
-		if (amt)
-			mem_cgroup_sk_charge(sk, amt, gfp);
-	}
 }
 
 static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index d0ae782c9ade..9a9dbab672af 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -394,7 +394,6 @@ struct mptcp_sock {
 
 	struct list_head backlog_list;	/* protected by the data lock */
 	u32		backlog_len;
-	u32		backlog_unaccounted;
 };
 
 #define mptcp_data_lock(sk) spin_lock_bh(&(sk)->sk_lock.slock)

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 49/62] mptcp: don't charge a subflow twice when it joins during accept()
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (47 preceding siblings ...)
  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 ` 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)
                   ` (12 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

A subflow that joins an MPTCP connection while accept() runs can be
charged twice to the memory cgroup of the server, for the memory that
it already holds when accept() charges it. Nothing removes this extra
charge.

At accept(), __inet_accept() gives the MPTCP socket (msk) the memory
cgroup of the caller, then sets its sk_socket. From then on,
mptcp_finish_join() gives this memory cgroup to a joining subflow, via
mptcp_sock_check_graft(), and each page that the subflow reserves is
charged. Because accept() owns the msk, such a subflow is added to the
join list, which mptcp_graft_subflows() moves to the subflow list
before charging each subflow for the memory that it holds. A subflow
that joined in between is then charged a second time for this memory,
which will be uncharged only once.

The window is short: from the end of __inet_accept() to the start of
mptcp_graft_subflows(). And the extra charge is not zero only if data
was received on the new subflow before mptcp_graft_subflows() gets to
it, while a peer must not send data on it before the fourth ACK
(RFC 8684, section 3.2).

The fix used here is to skip, in mptcp_graft_subflows(), the subflows
that already have a memory cgroup: they got it when they joined, and
their memory has been charged since then.

This issue has been found by an AI code review agent, while reviewing
the code of the commit "mptcp: don't charge a shared page twice at
accept()". It cannot be triggered on demand: the window is too narrow.
It has been reproduced with a 500 ms sleep added after __inet_accept(),
to widen it, and a Packetdrill script sending 1000 bytes on a subflow
joining during accept(). Without this patch, a page stayed charged to
the memory cgroup once all the sockets were freed, and none with it:

  memcg sock: 4096 bytes

Fixes: 6228efe0cc01 ("mptcp: leverage the backlog for RX packet processing")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: update a comment (Clashiko)
---
 net/mptcp/protocol.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 9f5e8b5cde60..c16daa461290 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -4650,8 +4650,8 @@ static void mptcp_graft_subflows(struct sock *sk)
 
 		/* Subflows joining after __inet_accept() will get the
 		 * mem CG properly initialized at mptcp_finish_join() time,
-		 * but subflows pending in join_list need explicit
-		 * initialization by the loop below.
+		 * even if pending in join_list. The ones that joined before
+		 * need explicit initialization by the loop below.
 		 */
 		mptcp_data_lock(sk);
 		list_splice_init(&msk->join_list, &join_list);
@@ -4674,7 +4674,8 @@ static void mptcp_graft_subflows(struct sock *sk)
 		if (!ssk->sk_socket)
 			mptcp_sock_graft(ssk, sk->sk_socket);
 
-		if (!mem_cgroup_sk_enabled(sk))
+		/* Got the memcg when joining: its memory is already charged */
+		if (!mem_cgroup_sk_enabled(sk) || mem_cgroup_from_sk(ssk))
 			goto unlock;
 
 		__mptcp_inherit_cgrp_data(sk, ssk);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 50/62] mptcp: continue the last mapping after a fallback
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (48 preceding siblings ...)
  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 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 51/62] mptcp: keep the first byte after a simult connect Matthieu Baerts (NGI0)
                   ` (11 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0), Chris Mason

From: Chris Mason <mason@kernel.org>

An established MPTCP connection that falls back to TCP after a zero
window probe or a reinjection can stall in one direction, so that recv()
returns neither the remaining data nor end of file.

After a fallback, subflow_check_data_avail() gives each skb a dummy
mapping, at the data sequence number (DSN) iasn + SSN - 1, where iasn is
the DSN of the peer's first byte and SSN is the subflow sequence number.
This is right only as long as DSNs and SSNs advance together, but a zero
window probe or a reinjection maps old data a second time, which takes
new SSNs and no new DSN. Each later dummy mapping is then too high, so
__mptcp_move_skb() treats all further data as out of order:

    data    SSN 1 to 1000    DSN iasn to iasn + 999
    probe   SSN 1001         DSN iasn + 999, dropped
    ack_seq                  iasn + 1000, the next DSN expected
    dummy   SSN 1002         DSN iasn + 1001

The fix used here is to:
- keep in the new member dsn_base of the subflow context the first DSN
  of the peer's last mapping, minus its first SSN, plus 1
- compute the DSN of a dummy mapping as dsn_base + SSN - 1
- keep in the new member dsn_end the highest end of a mapping of the
  peer so far
- make mptcp_try_fallback() fail while the peer's last mapping ends
  below dsn_end, so that the caller resets the subflow

32 bits are enough for both: the dummy mapping only takes the lower 32
bits of its DSN, see __mptcp_expand_seq(), and the end of a mapping
stays within a window of dsn_end.

One case is left: if only the receiver falls back after a zero window
probe or a reinjection, it now delivers data resent at the MPTCP level
as new data, unless the sender resets the subflow before, as it does
since "mptcp: don't resend data acked without MPTCP opts". Without this
patch, the receiver stalled instead.

This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch,
and with a new Packetdrill test: between two unmodified Linux hosts,
nftables removing the MPTCP options after a zero window probe, a DSS
checksum failure, or a failed MP_JOIN. Without this patch, the reader
stalled for good, the data staying in the out-of-order queue:

  receiver  22.764: READ-TOTAL outcome ii-right-so-far-then-nothing bytes 2670592 of 8388608 [...]
  [...] end: hang: no data and no end of file for 20 s
  RESULT [...] R: DssFallback=1 [...] OFOQueue=204 NoDSSInWindow=145 [...]

And with the Packetdrill test:

  dss_fallback_after_probe_server.pkt:25: runtime error in read call: Expected result 2000 but got 1000 with errno 22 (Invalid argument)

Fixes: 2834f8edd74d ("mptcp: cleanup fallback dummy mapping generation")
Signed-off-by: Chris Mason <mason@kernel.org>
[ dsn_base and dsn_end on 32 bits: struct mptcp_subflow_context grows by
  8 bytes instead of 16, and lent_mem_frag stays in the same cacheline.
  Shorter comments. Moved after "mptcp: stop resending data to a peer
  that fell back": alone, this patch turns a stall into data delivered
  twice, when only the receiver falls back after a probe or a
  reinjection. Commit message: mention the remaining case + how the
  issue was found, and its symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: msg: the sender now resets in the remaining case (Clashiko)

Note (Sashiko): the remaining case, when only the receiver falls back,
needs a sender not resetting the subflow, e.g. with an older kernel: the
data is then delivered twice, instead of a stall before this patch. The
RFC at the end of this series resets instead of falling back.
---
 net/mptcp/protocol.h |  9 ++++++++-
 net/mptcp/subflow.c  | 21 ++++++++++++++++++---
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 9a9dbab672af..7cdd0a7e8296 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -582,6 +582,8 @@ struct mptcp_subflow_context {
 	__wsum	map_data_csum;
 	u32	map_csum_len;
 	u32	prev_rtt_seq;
+	u32	dsn_base;	    /* MPC: DSN - SSN + 1 of peer's last map */
+	u32	dsn_end;	    /* MPC: highest end of the peer's maps */
 	u32	request_mptcp : 1,  /* send MP_CAPABLE */
 		request_join : 1,   /* send MP_JOIN */
 		request_bkup : 1,
@@ -606,7 +608,8 @@ struct mptcp_subflow_context {
 		mpc_drop : 1,	    /* the MPC option has been dropped in a rtx */
 		resetting : 1,	    /* subflow is resetting */
 		old_data_pending : 1, /* old data not acked with MPTCP opts */
-		__unused : 8;
+		map_old : 1,	    /* MPC: peer's last map is below dsn_end */
+		__unused : 7;
 	bool	data_avail;
 	bool	scheduled;
 	bool	pm_listener;	    /* a listener managed by the kernel PM? */
@@ -1350,6 +1353,10 @@ static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib)
 
 	msk = mptcp_sk(sk);
 
+	/* the peer might still be resending old data */
+	if (subflow->map_old && !__mptcp_check_fallback(msk))
+		return false;
+
 	/* queued old data would be sent without mapping after a fallback */
 	if (subflow->old_data_pending && !__mptcp_check_fallback(msk))
 		return false;
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 3590c1207e88..f73e4b8deca4 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -540,6 +540,8 @@ static void subflow_set_remote_key(struct mptcp_sock *msk,
 
 	/* for fallback's sake */
 	subflow->map_seq = subflow->iasn;
+	subflow->dsn_base = subflow->iasn;
+	subflow->dsn_end = subflow->iasn;
 
 	WRITE_ONCE(msk->remote_key, subflow->remote_key);
 	WRITE_ONCE(msk->ack_seq, subflow->iasn);
@@ -1438,6 +1440,17 @@ static bool mptcp_subflow_fail(struct mptcp_sock *msk, struct sock *ssk)
 	return true;
 }
 
+/* Fallback: dummy maps go on from the last valid one, unless it is old */
+static void subflow_update_dsn_base(struct mptcp_subflow_context *subflow)
+{
+	u32 end = subflow->map_seq + subflow->map_data_len;
+
+	subflow->dsn_base = subflow->map_seq - subflow->map_subflow_seq + 1;
+	subflow->map_old = before(end, subflow->dsn_end);
+	if (!subflow->map_old)
+		subflow->dsn_end = end;
+}
+
 static bool subflow_check_data_avail(struct sock *ssk)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
@@ -1471,6 +1484,8 @@ static bool subflow_check_data_avail(struct sock *ssk)
 		if (unlikely(!READ_ONCE(msk->can_ack)))
 			goto fallback;
 
+		subflow_update_dsn_base(subflow);
+
 		old_ack = READ_ONCE(msk->ack_seq);
 		ack_seq = mptcp_subflow_get_mapped_dsn(subflow);
 		pr_debug("msk ack_seq=%llx subflow ack_seq=%llx\n", old_ack,
@@ -1501,6 +1516,7 @@ static bool subflow_check_data_avail(struct sock *ssk)
 				subflow->reset_reason = MPTCP_RST_EMIDDLEBOX;
 				goto reset;
 			}
+			subflow_update_dsn_base(subflow);
 			WRITE_ONCE(subflow->data_avail, true);
 			return true;
 		}
@@ -1532,9 +1548,8 @@ static bool subflow_check_data_avail(struct sock *ssk)
 	subflow->map_data_len = skb->len;
 	subflow->map_subflow_seq = TCP_SKB_CB(skb)->seq - subflow->ssn_offset;
 	subflow->map_seq = __mptcp_expand_seq(subflow->map_seq,
-					      subflow->iasn +
-					      TCP_SKB_CB(skb)->seq -
-					      subflow->ssn_offset - 1);
+					      subflow->dsn_base +
+					      subflow->map_subflow_seq - 1);
 	WRITE_ONCE(subflow->data_avail, true);
 	return true;
 }

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 51/62] mptcp: keep the first byte after a simult connect
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (49 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 50/62] mptcp: continue the last mapping after a fallback Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` 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)
                   ` (10 subsequent siblings)
  61 siblings, 1 reply; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

A simultaneous connect leads to a fallback to TCP, decided when sending
the SYN-ACK from the SYN_RECV state. The received data is then mapped
with dummy mappings, based on ssn_offset, the peer's ISN, normally set
by subflow_finish_connect() when receiving the SYN-ACK. But here, it is
only called on the next packet, received in ESTABLISHED: its sequence
number was then used as ssn_offset, and the first received byte was
dropped.

Set ssn_offset when sending the SYN-ACK after a simultaneous connect,
and only take it from a SYN in subflow_finish_connect().

This issue has been reported by Sashiko, while reviewing another fix,
and confirmed with a new Packetdrill test: after a simultaneous connect,
10 bytes are received. Without this patch, only 9 were read:

  simult_connect_data.pkt:24: runtime error in read call: Expected result 10 but got 9 with errno 115 (Operation now in progress)

Fixes: 2834f8edd74d ("mptcp: cleanup fallback dummy mapping generation")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue spotted by Sashiko
---
 net/mptcp/options.c | 5 +++++
 net/mptcp/subflow.c | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 05b9c66aaed6..41eb39968a9a 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -474,6 +474,11 @@ bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb,
 	 * in mptcp_established_options_mp()
 	 */
 	subflow->snd_isn = TCP_SKB_CB(skb)->end_seq;
+
+	/* simult connect: the peer's SYN-ACK will not set ssn_offset */
+	if (unlikely(sk->sk_state == TCP_SYN_RECV))
+		subflow->ssn_offset = tcp_sk(sk)->rcv_nxt - 1;
+
 	if (subflow->request_mptcp) {
 		if (unlikely(subflow_simultaneous_connect(sk))) {
 			WARN_ON_ONCE(!mptcp_try_fallback(sk, MPTCP_MIB_SIMULTCONNFALLBACK));
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index f73e4b8deca4..439a11d92281 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -591,7 +591,9 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
 	subflow->rel_write_seq = 1;
 	subflow->opt_ack_seq = tcp_sk(sk)->snd_una;
 	subflow->conn_finished = 1;
-	subflow->ssn_offset = TCP_SKB_CB(skb)->seq;
+	/* simult connect: not a SYN-ACK, see mptcp_syn_options() */
+	if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)
+		subflow->ssn_offset = TCP_SKB_CB(skb)->seq;
 	pr_debug("subflow=%p synack seq=%x\n", subflow, subflow->ssn_offset);
 
 	mptcp_get_options(skb, &mp_opt);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 52/62] mptcp: move to ESTABLISHED after a simult connect
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (50 preceding siblings ...)
  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  9:41 ` 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)
                   ` (9 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

After a simultaneous connect, the subflow moves from SYN_RECV to
ESTABLISHED when it receives the peer's SYN-ACK. Since the commit
mentioned below, the MPTCP socket only follows when
subflow_finish_connect() is called, on the next received packet. Until
then, it stays in SYN_SENT: POLLOUT is not reported, write() returns
EAGAIN, and a blocking connect() waits, until the peer sends something.

As it was done before this commit, propagate the state from
subflow_state_change() in this case.

This issue has been found by an AI code review agent, while checking a
review from Sashiko, and confirmed with a new Packetdrill test: after a
simultaneous connect, poll() is called. Without this patch, POLLOUT was
not reported:

  simult_connect_write.pkt:18: runtime error in poll call: Expected result 1 but got 0 with errno 115 (Operation now in progress)

Fixes: 71154bbe4942 ("mptcp: fallback earlier on simult connection")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue found by a review agent, after a Sashiko review
---
 net/mptcp/subflow.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 439a11d92281..7dbad6debdf0 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1988,6 +1988,16 @@ static void subflow_state_change(struct sock *sk)
 
 	__subflow_state_change(sk);
 
+	/* simult connect: not finished by subflow_finish_connect() */
+	if (unlikely(!subflow->conn_finished &&
+		     sk->sk_state == TCP_ESTABLISHED &&
+		     inet_sk_state_load(parent) == TCP_SYN_SENT &&
+		     mptcp_check_fallback(sk))) {
+		subflow->rel_write_seq = 1;
+		subflow->conn_finished = 1;
+		mptcp_propagate_state(parent, sk, subflow, NULL);
+	}
+
 	/* Rx queue processing is unneeded, error reporting will take place at
 	 * __mptcp_close_ssk() time and subflow reset can't happen in case of
 	 * fallback: subflow_sched_work_if_closed() would be a no-op.

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 53/62] mptcp: fix MSG_PEEK after a partly peeked skb
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (51 preceding siblings ...)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 52/62] mptcp: move to ESTABLISHED " Matthieu Baerts (NGI0)
@ 2026-11-21  9:41 ` 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)
                   ` (8 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

When recvmsg() with MSG_PEEK needs another pass, e.g. after having moved
the data from the backlog, the data already peeked is skipped. If this
data ends in the middle of an skb, e.g. the last one peeked, extended
since then by coalescing, the following skbs were skipped too, entirely
or partly, because the length of the data skipped in the first skb was
not counted: the peeked data was then corrupted.

This issue was likely causing a subtest from mptcp_connect_sendfile.sh
to fail, e.g. on NIPA, with a debug kernel. In the "saveWithPeek" mode,
the client saves the data peeked before reading it: the received file
had the same size, but not the same content.

  # 46 ns1 MPTCP -> ns1 (10.0.1.1:10043      ) TCP       (duration   264ms) [FAIL] file received by client does not match (in, out):

The root cause has been confirmed with a debug patch holding the MPTCP
socket lock for 200ms after the first MSG_PEEK pass in recvmsg(): 1000
bytes are peeked, then 1000 bytes are received and coalesced with them,
and 60000 more bytes in other skbs. Without this patch, only 60000 bytes
were peeked instead of 62000, and they were different from the data read
after:

  peek repro: peeked 60000 bytes, DIFFERENT data

To fix this, count the data skipped in the first skb, so that the next
ones are not skipped.

Fixes: 8e04ce45a8db ("mptcp: fix MSG_PEEK stream corruption")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue causing a flaky selftest
---
 net/mptcp/protocol.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index c16daa461290..992e1832398f 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2299,6 +2299,7 @@ static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg,
 			delta = copied_total - total_data_len;
 			offset += delta;
 			data_len -= delta;
+			total_data_len += delta;
 		}
 
 		count = min_t(size_t, len - copied, data_len);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 54/62] mptcp: send the DATA_ACK after moving the backlog
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (52 preceding siblings ...)
  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 ` 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)
                   ` (7 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

The data received while the MPTCP socket is owned by the user is put in
the backlog, and only moved to the MPTCP socket later. The TCP ACK sent
for this data then carries the previous DATA_ACK, and after having moved
the data, an updated DATA_ACK was only sent if a TCP ACK was still
pending, for more than one MSS.

If the peer had nothing else to send, it then didn't get the new
DATA_ACK, until another ACK was sent, e.g. when the reader frees enough
space in the receive buffer. Its MPTCP retransmission timer could then
fire, and the data was retransmitted for nothing at the MPTCP level.
Such a retransmission also prevents a later fallback to TCP, after an
MP_FAIL: this was causing the "Infinite map" subtest from mptcp_join.sh
to fail from time to time, with an unexpected MP_RST.

This behaviour has been introduced by commit bc68b0efa1bf ("mptcp: move
the whole rx path under msk socket lock protection"): before, this data
was moved to the MPTCP socket right away, even if it was owned by the
user.

To fix this, schedule a delayed ACK on the subflow of the last skb taken
from the backlog, if no ACK is pending there: the new DATA_ACK is then
sent with the next ACK on this subflow, or when the delayed ACK timer
expires. TCP sends its ACK when processing its own backlog, possibly
delayed too.

The root cause has been confirmed with a Packetdrill script and a debug
patch keeping the MPTCP socket lock in recvmsg() while data is received.
Without this patch, the DATA_ACK was not updated after having read the
data:

  error handling packet: Timed out waiting for packet

Fixes: bc68b0efa1bf ("mptcp: move the whole rx path under msk socket lock protection")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue causing a flaky selftest
---
 net/mptcp/protocol.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 992e1832398f..cc438ae46089 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2415,10 +2415,21 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)
 	msk->rcvq_space.time = mstamp;
 }
 
+/* The ACKs of the data put in the backlog carried the previous DATA_ACK */
+static void mptcp_subflow_schedule_ack(struct sock *ssk)
+{
+	bool slow = lock_sock_fast(ssk);
+
+	if (tcp_can_send_ack(ssk) && !inet_csk_ack_scheduled(ssk))
+		tcp_send_delayed_ack(ssk);
+	unlock_sock_fast(ssk, slow);
+}
+
 static bool __mptcp_move_skbs(struct sock *sk, struct list_head *skbs, u32 *delta)
 {
 	struct sk_buff *skb = list_first_entry(skbs, struct sk_buff, list);
 	struct mptcp_sock *msk = mptcp_sk(sk);
+	struct sock *ssk = NULL;
 	bool moved = false;
 
 	while (1) {
@@ -2426,6 +2437,9 @@ static bool __mptcp_move_skbs(struct sock *sk, struct list_head *skbs, u32 *delt
 		list_del(&skb->list);
 		*delta += skb->truesize;
 
+		/* NULL if the subflow has been closed */
+		if (skb->sk)
+			ssk = skb->sk;
 		moved |= __mptcp_move_skb(sk, skb);
 		if (list_empty(skbs))
 			break;
@@ -2437,6 +2451,9 @@ static bool __mptcp_move_skbs(struct sock *sk, struct list_head *skbs, u32 *delt
 	if (!moved)
 		return false;
 
+	if (ssk && !__mptcp_check_fallback(msk))
+		mptcp_subflow_schedule_ack(ssk);
+
 	/* Only the worker can close an orphan, as it must then destroy it */
 	if (!sock_flag(sk, SOCK_DEAD))
 		mptcp_check_data_fin(sk);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 55/62] selftests: mptcp: join: infinite map: no spurious rtx
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (53 preceding siblings ...)
  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 ` Matthieu Baerts (NGI0)
  2026-11-21  9:41 ` [PATCH mptcp-net v2 56/62] selftests: mptcp: connect: trunc: wait for acks Matthieu Baerts (NGI0)
                   ` (6 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

The "Infinite map" subtest sometimes failed with a reset instead of a
fallback to TCP, and the transfer was then stuck:

  [FAIL] client exit code 2, server 2
  (...)
    MPTcpExtMPTCPRetrans            1
  (...)
    MPTcpExtDuplicateData           1
  (...)
        reset tx server      [FAIL] got 1 MP_RST[s] TX expected 0
        infi tx client       [FAIL] got 0 infinite map[s] TX expected 1

Once some data has been retransmitted at the MPTCP level, a fallback
with an infinite mapping is no longer allowed: a checksum failure then
leads to a reset. Here, the retransmission is spurious: in the 'fast'
mode used by this subtest, each side writes 100 bytes, then waits
200ms. The 100 bytes from the server can be received while the client
socket is owned, e.g. when it is writing its own data: the TCP ACK is
then sent with the previous DATA_ACK, and the next one is only sent with
the next data, 200ms later. Meanwhile, the MPTCP retransmission timer
of the server, armed with the minimum RTO of its MPTCP socket, 200ms by
default, can expire.

This has been confirmed by setting tcp_rto_min_us to 20ms in both
netns, with a capture showing the stale DATA_ACK, then the
retransmission of the same data 20ms later, with a new subflow sequence
number:

  S>C [P.], seq 1:101, ack 1, [mptcp 24 dss ack 3936022471 seq 1159191301011008422 subseq 1 len 100 (...)], length 100
  C>S [.], ack 101, [mptcp 12 dss ack 1159191301011008422], length 0
  (...)
  S>C [P.], seq 101:201, ack 101, [mptcp 28 dss ack (...) seq 1159191301011008422 subseq 101 len 100 (...)], length 100

These MPTCP retransmissions are expected here. To avoid them, increase
the minimum RTO to 1 second in this subtest: the corrupted packet is
the next one sent by the client, after its 200ms pause. The MPTCP socket
only uses this sysctl since commit ea4eb2adb0d3 ("mptcp: honour
configured min/max RTO in retransmit paths"), in v7.3: before, this
change only increases the minimum RTO of the subflows. Errors are
ignored on kernels without this sysctl.

Fixes: b6e074e171bc ("selftests: mptcp: add infinite map testcase")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for a flaky selftest
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 4c045532f137..3d48b02ee8c9 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -3828,6 +3828,12 @@ fail_tests()
 	# single subflow
 	if reset_with_fail "Infinite map" 1; then
 		MPTCP_LIB_SUBTEST_FLAKY=1
+		# MPTCP retransmissions prevent the fallback: avoid spurious
+		# ones during the 200ms pause of the 'fast' mode
+		ip netns exec $ns1 sysctl -q net.ipv4.tcp_rto_min_us=1000000 \
+			2>/dev/null || true
+		ip netns exec $ns2 sysctl -q net.ipv4.tcp_rto_min_us=1000000 \
+			2>/dev/null || true
 		test_linkfail=128 \
 			run_tests $ns1 $ns2 10.0.1.1
 		join_csum_ns1=+1 join_csum_ns2=+0 \

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 56/62] selftests: mptcp: connect: trunc: wait for acks
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (54 preceding siblings ...)
  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 ` 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)
                   ` (5 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

The "fastclose server test" subtest from mptcp_join.sh was still failing
from time to time, because the client output file didn't have the
expected size, e.g. on NIPA:

  [FAIL] file received by client output file has wrong size (866, 1024)
  Server ns stats (...)
  (...)
    TcpExtTCPOrigDataSent           3
    TcpExtTCPDelivered              2

Here, the server sent 3 data segments only, the last one not acked yet,
and the client received all the data from these segments. The rest of
the data, already written by the server, was still queued, e.g. held by
Nagle, waiting for the last segment to be acked. But the server then
closed its socket, with data from the client still to read, as expected
here: an MP_FASTCLOSE is then sent, and the data still queued is
discarded, as with a TCP reset.

To fix this, wait for the written data to be acked, with SIOCOUTQ,
before stopping in the truncate mode, so before closing the socket. A
timeout is reported: it would look like this issue otherwise.

This issue has been confirmed on a debug kernel, where this subtest
failed a few times: each time, the client didn't have any data left in
its queues, and the data received matched the data in the segments sent
by the server. With this patch, it no longer failed.

Fixes: 6bf41020b72b ("selftests: mptcp: update and extend fastclose test-cases")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for a flaky selftest
---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 24 ++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index 8c788977e594..861fa2bd70d0 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -643,6 +643,26 @@ static void shut_wr(int fd)
 	shutdown(fd, SHUT_WR);
 }
 
+/* the data still queued would be dropped by a reset: wait for its ack */
+static void wait_for_ack(int fd)
+{
+	struct pollfd pfd = { .fd = fd };
+	int i, queued;
+
+	for (i = 0; poll_timeout < 0 || i < poll_timeout; i += 10) {
+		if (quit || ioctl(fd, SIOCOUTQ, &queued) < 0 || queued <= 0)
+			return;
+
+		/* e.g. reset: the data will not be acked */
+		if (poll(&pfd, 1, 0) > 0 && (pfd.revents & POLLERR))
+			return;
+
+		usleep(10000);
+	}
+
+	fprintf(stderr, "timeout while waiting for the data to be acked\n");
+}
+
 static int copyfd_io_poll(int infd, int peerfd, int outfd,
 			  bool *in_closed_after_out, struct wstate *winfo)
 {
@@ -768,8 +788,10 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd,
 		}
 
 		if (cfg_truncate > 0 && total_wlen >= cfg_truncate &&
-		    total_rlen >= cfg_truncate)
+		    total_rlen >= cfg_truncate) {
+			wait_for_ack(peerfd);
 			break;
+		}
 	}
 
 	/* leave some time for late join/announce */

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 57/62] mptcp: order write_seq and DATA_FIN flag for fallback
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (55 preceding siblings ...)
  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 ` 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)
                   ` (4 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

mptcp_try_fallback() can run in BH, without the msk socket lock. Since
the commit mentioned below, it reads write_seq after
snd_data_fin_enable, not to send a FIN before new data. But
__mptcp_wr_shutdown() sets these two fields without ordering them: on a
weakly ordered CPU, mptcp_try_fallback() could see the flag with the old
write_seq, and send a FIN before the last byte of data.

Use a release/acquire pair, to read the new write_seq with the flag.

This issue has been found by Clashiko, while reviewing the commit
mentioned below. It is theoretical: it has not been reproduced, and it
needs a shutdown racing with a fallback, with exactly one byte not sent
yet. Still, it is fine to fix it like that, without real impact: the
release/acquire pair is cheap -- plain accesses on x86 -- with the
release done once at shutdown time, and the acquire only when falling
back.

Fixes: d0e88ecfae68 ("mptcp: don't send a FIN before the pending data on fallback")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue spotted by Clashiko
---
 net/mptcp/protocol.c | 3 ++-
 net/mptcp/protocol.h | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index cc438ae46089..174ffd0d3e68 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3666,7 +3666,8 @@ static void __mptcp_wr_shutdown(struct sock *sk)
 
 	/* will be ignored by fallback sockets */
 	WRITE_ONCE(msk->write_seq, msk->write_seq + 1);
-	WRITE_ONCE(msk->snd_data_fin_enable, 1);
+	/* pairs with the acquire in mptcp_try_fallback() */
+	smp_store_release(&msk->snd_data_fin_enable, 1);
 
 	mptcp_check_send_data_fin(sk);
 }
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 7cdd0a7e8296..be57804f1bb3 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -1364,8 +1364,10 @@ static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib)
 	if (!__mptcp_try_fallback(msk, fb_mib))
 		return false;
 
-	/* no FIN before new data: see mptcp_check_send_data_fin() */
-	if (READ_ONCE(msk->snd_data_fin_enable) &&
+	/* no FIN before new data: see mptcp_check_send_data_fin(), and the
+	 * release in __mptcp_wr_shutdown()
+	 */
+	if (smp_load_acquire(&msk->snd_data_fin_enable) &&
 	    !before64(READ_ONCE(msk->snd_nxt) + 1, READ_ONCE(msk->write_seq)) &&
 	    !(ssk->sk_shutdown & SEND_SHUTDOWN)) {
 		gfp_t saved_allocation = ssk->sk_allocation;

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 58/62] Squash to "bpf: Add mptcp packet scheduler struct_ops"
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (56 preceding siblings ...)
  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 ` 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)
                   ` (3 subsequent siblings)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

A BPF scheduler can return 0 from get_send() without picking any
subflow, e.g. the bkup one from the BPF selftests, when all the subflows
are backup on both sides. With data to send, a DATA_ACK received while
the msk is not owned by the user then makes the push loop of
__mptcp_subflow_push_pending() spin forever, in softirq:

  watchdog: BUG: soft lockup - CPU#2 stuck for 49s! [python3:182]
  (...)
  RIP: 0010:bpf_iter_mptcp_subflow_next+0xf/0x40
  (...)
  Call Trace:
   <IRQ>
   bpf_prog_bf2471f1d206d5cc_bpf_bkup_get_send+0x78/0xd7
   bpf__mptcp_sched_ops_get_send+0x4c/0xb0
   __mptcp_subflow_push_pending+0x148/0x390
   mptcp_incoming_options+0x836/0xba0
   tcp_data_queue+0x6da/0x10c0
   tcp_rcv_established+0x2d5/0xce0
   tcp_v4_do_rcv+0x13f/0x300
   tcp_v4_rcv+0xbff/0x1200
   (...)

Stop this loop when the current subflow is not picked: if another one
is, the loop already stops after delegating the push to it. The default
scheduler always picks a subflow when returning 0: not affected.

This issue has been found by an AI code review agent, while reviewing a
patch for the BPF schedulers, and confirmed with a reproducer: the bkup
scheduler on the client side, its only subflow marked as backup on both
sides, data queued by the client, then data sent by the server, carrying
the DATA_ACK causing the soft lockup above.

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue found by a review agent
---
 net/mptcp/protocol.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 174ffd0d3e68..09514166c98b 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1961,6 +1961,9 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk, bool
 				keep_pushing = false;
 			else
 				copied += ret;
+		} else {
+			/* a BPF scheduler might not pick any subflow */
+			keep_pushing = false;
 		}
 
 		mptcp_for_each_subflow(msk, subflow) {

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-net v2 59/62] Squash to "bpf: Export mptcp packet scheduler helpers"
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (57 preceding siblings ...)
  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 ` 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)
                   ` (2 subsequent siblings)
  61 siblings, 1 reply; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

With a BPF scheduler, the rtx timer interval, msk->timer_ival, is only
set if the scheduler calls the mptcp_set_timeout() kfunc: only the
burst one does. This interval is 0 once all the data has been acked, and
the rtx timer can then be armed with it, e.g. by the next push: it then
fires every jiffy, retransmitting the data in flight until it is acked.

Since "mptcp: arm the rtx timer if a push leaves data behind", this also
happens when a push sends nothing, e.g. in a memory shortage: the
timer then fires every jiffy, until a push succeeds.

Set this interval before calling a BPF scheduler, as the default one
does when picking a subflow.

This issue has been found by Clashiko, while reviewing "mptcp: arm the
rtx timer if a push leaves data behind". Not reproduced.

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for an issue spotted by Clashiko

Note: when squashing, the commit message could mention that
mptcp_sched_get_send() now sets the rtx timer interval before calling a
BPF scheduler, as the default one does.
---
 net/mptcp/sched.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
index 1e59072d478c..2f685986698b 100644
--- a/net/mptcp/sched.c
+++ b/net/mptcp/sched.c
@@ -189,6 +189,9 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)
 
 	if (msk->sched == &mptcp_sched_default || !msk->sched)
 		return mptcp_sched_default_get_send(msk);
+
+	/* as the default scheduler: the rtx timer needs an interval */
+	mptcp_set_timeout((struct sock *)msk);
 	return msk->sched->get_send(msk);
 }
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-next mptcp-net v2 60/62] mptcp: push pending data after a fallback on reception
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (58 preceding siblings ...)
  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  9:41 ` 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  9:42 ` [PATCH RFC mptcp-next mptcp-net v2 62/62] mptcp: reset when the DSS disappears after a DATA_ACK Matthieu Baerts (NGI0)
  61 siblings, 0 replies; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

When received data without DSS makes the MPTCP socket fall back to TCP,
the data not sent yet is not pushed: on fallback, this is done by
mptcp_incoming_options(), which already processed this packet before
the fallback. This data, and the FIN of an earlier shutdown, then wait
for the next packet from the peer, or for the MPTCP retransmission
timer armed before the fallback: up to one RTO.

Push it from mptcp_data_ready(), which follows these fallbacks, also
the ones after a DSS corruption. For the next packets, this push comes
after the one from mptcp_incoming_options(), which already sent what it
could.

This issue has been found by Clashiko, while reviewing "mptcp: don't
send a FIN before the pending data on fallback", and confirmed with a
new Packetdrill test: after a shutdown, with data still in the MPTCP
socket, the peer sends data without MPTCP options. Without this patch,
with an RTO of one second, the data is sent about one second later:

  dss_fallback_push_pending_server.pkt:27: error handling packet: timing error: expected outbound packet at 0.312538 sec but happened at 1.274089 sec; tolerance 0.100000 sec

With this patch, the data and the FIN are sent right after the fallback.

Note for the backports: the fallback after receiving data without DSS
comes from commit 119d51e225fe ("mptcp: fallback when MPTCP opts are
dropped after 1st data"), also in v6.12, and backported down to v5.15.

Fixes: e32d262c89e2 ("mptcp: handle consistently DSS corruption")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for mptcp-next, for an issue spotted by Clashiko in a fix
    pending in net
---
 net/mptcp/protocol.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 09514166c98b..1088caa788f6 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1083,6 +1083,10 @@ void mptcp_data_ready(struct sock *sk, struct sock *ssk)
 	} else {
 		__mptcp_move_skbs_from_subflow(msk, ssk, false);
 	}
+
+	/* mptcp_incoming_options() can't push if this data caused a fallback */
+	if (__mptcp_check_fallback(msk) && sk_stream_memory_free(ssk))
+		__mptcp_check_push(sk, ssk);
 	mptcp_data_unlock(sk);
 }
 

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH mptcp-next mptcp-net v2 61/62] mptcp: report errors as TCP does when closing
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (59 preceding siblings ...)
  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 ` 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)
  61 siblings, 1 reply; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:41 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

When the close timeout expires, or when the last subflow is closed in
another state than ESTABLISHED, the MPTCP socket moves to TCP_CLOSE
without error, and recv() then reports ENOTCONN instead of EOF. In
these cases, TCP sets SHUTDOWN_MASK and an error depending on the
state: ETIMEDOUT after a timeout, and ECONNRESET, EPIPE or ECONNREFUSED
after a reset.

Do the same, as tcp_done_with_error() does, also in the late cleanup
done by accept(), when the first subflow has been closed before: with
the error of the last subflow, e.g. ETIMEDOUT after its RTO. After a
reset, or without error, the error depends on the MPTCP-level state,
e.g. EPIPE after a DATA_FIN. When a subflow error closes the socket,
SHUTDOWN_MASK is now set too, as tcp_done() does.

This changes the errors seen by the applications: after the close
timeout, reading or writing now reports ETIMEDOUT once, instead of
ENOTCONN or EPIPE, then EOF and EPIPE, as with TCP after a timeout. The
tests checking these errors in the MPTCP Packetdrill repository have to
be adapted.

With the reproducer from the GitHub issue, where the only subflow dies
by RTO, send() now returns ETIMEDOUT after the subflow timeout and the
close timeout, instead of EPIPE.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/648
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: new, for mptcp-next, as suggested in issue #648 on GitHub
---
 net/mptcp/protocol.c | 88 +++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 67 insertions(+), 21 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 1088caa788f6..5733ab548d12 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -518,6 +518,56 @@ static void mptcp_close_wake_up(struct sock *sk)
 		sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
 }
 
+/* Mirror the tcp_reset() error propagation */
+static int mptcp_reset_err(const struct sock *sk)
+{
+	int err;
+
+	switch (sk->sk_state) {
+	case TCP_SYN_SENT:
+		err = ECONNREFUSED;
+		break;
+	case TCP_CLOSE_WAIT:
+		err = EPIPE;
+		break;
+	default:
+		err = ECONNRESET;
+	}
+
+	return err;
+}
+
+/* No more data can be exchanged: report it, as tcp_done_with_error() does */
+static void mptcp_close_err(struct sock *sk, int err)
+{
+	WRITE_ONCE(sk->sk_err, err);
+	/* This barrier is coupled with smp_rmb() in mptcp_poll() */
+	smp_wmb();
+	WRITE_ONCE(sk->sk_shutdown, SHUTDOWN_MASK);
+	mptcp_set_state(sk, TCP_CLOSE);
+	if (sock_flag(sk, SOCK_DEAD))
+		return;
+
+	mptcp_close_wake_up(sk);
+	sk_error_report(sk);
+}
+
+/* As TCP: the error of the last subflow, e.g. ETIMEDOUT, but after a reset
+ * (EBADMSG: by MPTCP) or without error, it depends on the msk state
+ */
+static void mptcp_close_last_err(struct sock *sk, int err)
+{
+	switch (err) {
+	case 0:
+	case ECONNREFUSED:
+	case ECONNRESET:
+	case EPIPE:
+	case EBADMSG:
+		err = mptcp_reset_err(sk);
+	}
+	mptcp_close_err(sk, err);
+}
+
 static void mptcp_shutdown_subflows(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow;
@@ -983,7 +1033,7 @@ static bool __mptcp_subflow_error_report(struct sock *sk, struct sock *ssk)
 	if (ssk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DEAD)) {
 		/* This barrier is coupled with smp_rmb() in mptcp_poll() */
 		smp_wmb();
-		WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN);
+		WRITE_ONCE(sk->sk_shutdown, SHUTDOWN_MASK);
 		mptcp_set_state(sk, ssk_state);
 	}
 	report = true;
@@ -2810,7 +2860,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 {
 	struct mptcp_sock *msk = mptcp_sk(sk);
 	bool dispose_it, need_push = false;
-	int fwd_remaining;
+	int fwd_remaining, ssk_err;
 
 	/* Do not pass RX data to the msk, even if the subflow socket is not
 	 * going to be freed (i.e. even for the first subflow on graceful
@@ -2818,6 +2868,8 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 	 */
 	lock_sock_nested(ssk, SINGLE_DEPTH_NESTING);
 	subflow->closing = 1;
+	/* in case it is the last subflow: before its disconnect or dispose */
+	ssk_err = READ_ONCE(ssk->sk_err);
 
 	if (flags & MPTCP_CF_PUSH)
 		mptcp_cleanup_ssk_backlog(sk, ssk);
@@ -2905,13 +2957,15 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 			mptcp_set_close_tout(sk, tcp_jiffies32 -
 					     (mptcp_close_timeout(sk) + 1));
 			mptcp_schedule_work(sk);
+		} else if (sk->sk_state == TCP_CLOSE) {
+			mptcp_close_wake_up(sk);
 		} else if (sk->sk_state != TCP_ESTABLISHED ||
 			   msk->in_accept_queue) {
 			mptcp_check_rcv_close(sk);
-			mptcp_set_state(sk, TCP_CLOSE);
-			WRITE_ONCE(sk->sk_shutdown,
-				   sk->sk_shutdown | SEND_SHUTDOWN);
-			mptcp_close_wake_up(sk);
+			if (sk->sk_state == TCP_CLOSE)
+				mptcp_close_wake_up(sk);
+			else
+				mptcp_close_last_err(sk, ssk_err);
 		} else {
 			mptcp_start_tout_timer(sk);
 		}
@@ -3085,20 +3139,10 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)
 		unlock_sock_fast(tcp_sk, slow);
 	}
 
-	/* Mirror the tcp_reset() error propagation */
-	switch (sk->sk_state) {
-	case TCP_SYN_SENT:
-		WRITE_ONCE(sk->sk_err, ECONNREFUSED);
-		break;
-	case TCP_CLOSE_WAIT:
-		WRITE_ONCE(sk->sk_err, EPIPE);
-		break;
-	case TCP_CLOSE:
+	if (sk->sk_state == TCP_CLOSE)
 		return;
-	default:
-		WRITE_ONCE(sk->sk_err, ECONNRESET);
-	}
 
+	WRITE_ONCE(sk->sk_err, mptcp_reset_err(sk));
 	mptcp_set_state(sk, TCP_CLOSE);
 	WRITE_ONCE(sk->sk_shutdown, SHUTDOWN_MASK);
 	smp_mb__before_atomic(); /* SHUTDOWN must be visible first */
@@ -3416,8 +3460,7 @@ static void mptcp_worker(struct work_struct *work)
 		mptcp_do_fastclose(sk);
 		mptcp_for_each_subflow_safe(msk, subflow, tmp)
 			__mptcp_close_ssk(sk, subflow->tcp_sock, subflow, 0);
-		WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN);
-		mptcp_close_wake_up(sk);
+		mptcp_close_err(sk, ETIMEDOUT);
 	}
 
 	if (sock_flag(sk, SOCK_DEAD) && sk->sk_state == TCP_CLOSE) {
@@ -4768,8 +4811,11 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,
 		 */
 		if (unlikely(inet_sk_state_load(msk->first) == TCP_CLOSE)) {
 			if (unlikely(list_is_singular(&msk->conn_list))) {
+				int err = READ_ONCE(msk->first->sk_err);
+
 				mptcp_check_rcv_close(newsk);
-				mptcp_set_state(newsk, TCP_CLOSE);
+				if (newsk->sk_state != TCP_CLOSE)
+					mptcp_close_last_err(newsk, err);
 			}
 			mptcp_close_ssk(newsk, msk->first,
 					mptcp_subflow_ctx(msk->first));

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* [PATCH RFC mptcp-next mptcp-net v2 62/62] mptcp: reset when the DSS disappears after a DATA_ACK
  2026-11-21  9:40 [PATCH mptcp-net v2 00/62] mptcp: misc fixes Matthieu Baerts (NGI0)
                   ` (60 preceding siblings ...)
  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  9:42 ` Matthieu Baerts (NGI0)
  2026-11-21 10:20   ` sashiko-bot
  61 siblings, 1 reply; 72+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-11-21  9:42 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Matthieu Baerts (NGI0)

RFC 8684, section 3.7, describes a fallback to TCP for the case where
the MPTCP options get through on the SYN, but not on the next packets.
A sender includes a DSS option in each segment "until one of the sent
segments has been acknowledged with a DSS option containing a Data
ACK": it then has "the confirmation that the DSS option passes in both
directions". After that, a subflow that loses its MPTCP options "SHOULD
be treated as broken and closed with a RST", with the "Middlebox
interference" reason. It's a *SHOULD*.

Commit 119d51e225fe ("mptcp: fallback when MPTCP opts are dropped after
1st data") did this fallback as long as allow_infinite_fallback is set,
i.e. also after this confirmation, and left the check of the DATA_ACK
for later [1]. Such a late fallback is fragile: the peer might still
resend data that was mapped before, or a zero window probe might have
mapped old data again. The previous commits "mptcp: do not fallback
while old data is in flight", "mptcp: stop resending data to a peer that
fell back", "mptcp: don't resend data acked without MPTCP opts" and
"mptcp: continue the last mapping after a fallback" handle these cases,
except one: if only the receiver falls back, it can deliver data resent
at the MPTCP level as new data, if the sender does not reset the subflow
before, e.g. with an older kernel. Yeah, a very specific corner case.

Now, when data without DSS is found on a subflow, the subflow is reset
if a DATA_ACK received on it acknowledged data that had been sent: the
MPTCP options then passed in both directions. Except after an MP_FAIL
exchange: a fallback to TCP is then in progress, so data without DSS is
expected, even if the infinite mapping has not been seen. This also
closes the case above, but only for a receiver whose data has been
acknowledged.

Receiving a DATA_ACK is not enough: when the MPTCP options are only
dropped in one direction, the peer can fall back while the DATA_ACKs it
sent before acknowledged no data. A client that is not fully
established falls back when a packet from the server has no MPTCP
options, e.g. an ACK of its data, and the other hosts when they receive
data without DSS. Except after an MP_FAIL, Linux falls back without
sending an infinite mapping, then sends data without DSS: the other
side can only fall back too, as before, if its data had not been
acknowledged. For the same reason, the amount of received data -- e.g.
more than an initial window -- is not used.

The same is done when a mapping does not cover the received data, e.g.
after a resegmentation by a middlebox, but not for an infinite mapping,
the fallback signal from the RFC: it gets a new MAPPING_INFINITE status.

When a middlebox starts dropping the MPTCP options in the middle of a
connection, after a DATA_ACK acknowledged data, the subflow is then
reset, instead of falling back to TCP when it was safe. If it was the
only subflow, the MPTCP connection stays without subflow until the
close timeout -- 60 seconds by default, see net.mptcp.close_timeout --
unless a new one is created in between.

New Packetdrill tests check these resets.

Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/519 [1]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
v2: also reset on an invalid mapping (Clashiko), and commit message: the
    remaining case is now handled by the sender

Note: this commit changes the behaviour, it is for next. It fixes a very
specific corner case (but it follows what the RFC 8684 recommends to do)
but for that it needs an extra flag and more checks. Is it worth it? (I
think so, but that's why it is flagged as RFC.)
---
 net/mptcp/options.c  | 11 +++++++----
 net/mptcp/protocol.h |  3 ++-
 net/mptcp/subflow.c  | 29 +++++++++++++++++++++++++----
 3 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 41eb39968a9a..e561143dd121 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -1144,7 +1144,7 @@ static void rwin_update(struct mptcp_sock *msk, struct sock *ssk,
 	subflow->rcv_wnd_sent = mptcp_rcv_wnd;
 }
 
-static void ack_update_msk(struct mptcp_sock *msk,
+static bool ack_update_msk(struct mptcp_sock *msk,
 			   struct sock *ssk,
 			   const struct sk_buff *skb,
 			   struct mptcp_options_received *mp_opt)
@@ -1153,6 +1153,7 @@ static void ack_update_msk(struct mptcp_sock *msk,
 	u32 win = ntohs(tcp_hdr(skb)->window);
 	struct sock *sk = (struct sock *)msk;
 	u64 snd_nxt;
+	bool acked;
 
 	mptcp_data_lock(sk);
 
@@ -1185,7 +1186,8 @@ static void ack_update_msk(struct mptcp_sock *msk,
 	if (after64(msk->wnd_end, snd_nxt))
 		__mptcp_check_push(sk, ssk);
 
-	if (after64(new_snd_una, old_snd_una)) {
+	acked = after64(new_snd_una, old_snd_una);
+	if (acked) {
 		__mptcp_snd_una_update(msk, new_snd_una);
 		__mptcp_data_acked(sk);
 	}
@@ -1195,6 +1197,7 @@ static void ack_update_msk(struct mptcp_sock *msk,
 	trace_ack_update_msk(mp_opt->data_ack,
 			     old_snd_una, new_snd_una,
 			     new_wnd_end, READ_ONCE(msk->wnd_end));
+	return acked;
 }
 
 bool mptcp_update_rcv_data_fin(struct mptcp_sock *msk, u64 data_fin_seq, bool use_64bit)
@@ -1356,8 +1359,8 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 	/* we can't wait for recvmsg() to update the ack_seq, otherwise
 	 * monodirectional flows will stuck
 	 */
-	if (mp_opt.use_ack)
-		ack_update_msk(msk, sk, skb, &mp_opt);
+	if (mp_opt.use_ack && ack_update_msk(msk, sk, skb, &mp_opt))
+		subflow->dss_confirmed = 1; /* MPTCP opts pass both ways */
 	rwin_update(msk, sk, skb);
 
 	/* Zero-data-length packets are dropped by the caller and not
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index be57804f1bb3..7bc45ce0d47c 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -609,7 +609,8 @@ struct mptcp_subflow_context {
 		resetting : 1,	    /* subflow is resetting */
 		old_data_pending : 1, /* old data not acked with MPTCP opts */
 		map_old : 1,	    /* MPC: peer's last map is below dsn_end */
-		__unused : 7;
+		dss_confirmed : 1,  /* a DATA_ACK acked our data */
+		__unused : 6;
 	bool	data_avail;
 	bool	scheduled;
 	bool	pm_listener;	    /* a listener managed by the kernel PM? */
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 7dbad6debdf0..e66d8416fe79 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1072,7 +1072,8 @@ enum mapping_status {
 	MAPPING_DATA_FIN,
 	MAPPING_DUMMY,
 	MAPPING_BAD_CSUM,
-	MAPPING_NODSS
+	MAPPING_NODSS,
+	MAPPING_INFINITE
 };
 
 static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn)
@@ -1242,7 +1243,7 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
 	if (data_len == 0) {
 		pr_debug("infinite mapping received\n");
 		MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_INFINITEMAPRX);
-		return MAPPING_INVALID;
+		return MAPPING_INFINITE;
 	}
 
 	if (mpext->data_fin == 1) {
@@ -1453,6 +1454,22 @@ static void subflow_update_dsn_base(struct mptcp_subflow_context *subflow)
 		subflow->dsn_end = end;
 }
 
+/* RFC 8684, 3.7: no fallback once a DATA_ACK acked our data, except MP_FAIL */
+static bool subflow_nodss_is_fatal(struct mptcp_sock *msk,
+				   const struct mptcp_subflow_context *subflow)
+{
+	bool fatal;
+
+	if (!subflow->dss_confirmed)
+		return false;
+
+	/* before a fallback, only an MP_FAIL clears allow_subflows */
+	spin_lock_bh(&msk->fallback_lock);
+	fatal = msk->allow_subflows;
+	spin_unlock_bh(&msk->fallback_lock);
+	return fatal;
+}
+
 static bool subflow_check_data_avail(struct sock *ssk)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
@@ -1473,7 +1490,9 @@ static bool subflow_check_data_avail(struct sock *ssk)
 		status = get_mapping_status(ssk, msk);
 		trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue));
 		if (unlikely(status == MAPPING_INVALID || status == MAPPING_DUMMY ||
-			     status == MAPPING_BAD_CSUM || status == MAPPING_NODSS))
+			     status == MAPPING_BAD_CSUM ||
+			     status == MAPPING_NODSS ||
+			     status == MAPPING_INFINITE))
 			goto fallback;
 
 		if (status != MAPPING_OK)
@@ -1523,7 +1542,9 @@ static bool subflow_check_data_avail(struct sock *ssk)
 			return true;
 		}
 
-		if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) {
+		if (((status == MAPPING_NODSS || status == MAPPING_INVALID) &&
+		     subflow_nodss_is_fatal(msk, subflow)) ||
+		    !mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) {
 			/* fatal protocol error, reset the subflow and let the
 			 * worker close it
 			 */

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 72+ messages in thread

* Re: [PATCH mptcp-net v2 28/62] mptcp: no fastclose reset from SYN_SENT subflows
  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
  0 siblings, 0 replies; 72+ messages in thread
From: sashiko-bot @ 2026-11-21 10:11 UTC (permalink / raw)
  To: Matthieu Baerts (NGI0), MPTCP Linux

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mptcp: race on TCP_SYN_SENT subflow in mptcp_do_fastclose()
  after unlock
--

commit 7e20c0b8af4ba4b67481ee3130ee19f18fec3566
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

mptcp: no fastclose reset from SYN_SENT subflows

This commit skips calling tcp_send_active_reset() in mptcp_do_fastclose()
when a subflow socket is in TCP_SYN_SENT.

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index f80fac0c22c06..55ff0298e5dd2 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -3297,6 +3297,10 @@ static void mptcp_do_fastclose(struct sock *sk)
>  
>  		subflow->send_fastclose = 1;
>  
> +		/* no reset in SYN_SENT, as TCP does */
> +		if (ssk->sk_state == TCP_SYN_SENT)
> +			goto unlock;

[Severity: Medium]
Can an incoming SYN-ACK race with release_sock(ssk) here because ssk is
left in TCP_SYN_SENT with subflow->send_fastclose = 1 until the caller
invokes __mptcp_close_ssk()?

CPU0                                  CPU1 (softirq)
mptcp_do_fastclose()
  lock_sock(ssk)
  subflow->send_fastclose = 1
  if (ssk->sk_state == TCP_SYN_SENT)
    goto unlock;
                                      tcp_v4_rcv() (SYN-ACK arrives)
                                        sk_add_backlog(ssk, skb, ...)
  release_sock(ssk)
    __release_sock(ssk)
      tcp_v4_do_rcv()
        tcp_rcv_state_process()
          tcp_rcv_synsent_state_process()
            tcp_set_state(ssk, TCP_ESTABLISHED)
            tcp_send_ack(ssk)
__mptcp_close_ssk()
  lock_sock_nested(ssk, ...)
  if (subflow->send_fastclose &&
      ssk->sk_state != TCP_CLOSE)
    tcp_set_state(ssk, TCP_CLOSE)     <-- silently closes without RST/FIN

If the SYN-ACK completes the handshake in that window, __mptcp_close_ssk()
 sees subflow->send_fastclose == 1 and forces ssk to TCP_CLOSE before
__mptcp_subflow_disconnect() or __tcp_close(), leaving the peer in
ESTABLISHED without sending a RST or FIN.  Conversely, if
subflow_finish_connect() rejects the SYN-ACK (for example on an MP_JOIN
subflow because the parent msk is already in TCP_CLOSE) and calls
mptcp_subflow_reset(), having subflow->send_fastclose == 1 still attaches
MP_FASTCLOSE to that reset.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org?part=28

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH mptcp-net v2 24/62] mptcp: process pending close events at accept()
  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
  0 siblings, 0 replies; 72+ messages in thread
From: sashiko-bot @ 2026-11-21 10:13 UTC (permalink / raw)
  To: Matthieu Baerts (NGI0), MPTCP Linux

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mptcp: dummy fallback DATA_FIN processed on reset in
  mptcp_stream_accept()
--

commit 41ac450ef8d0029d02acbe4bb5044a609c4a37c5
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

mptcp: process pending close events at accept()

This commit calls mptcp_check_rcv_close() in mptcp_stream_accept() before
transitioning an accepted MPTCP socket whose only subflow is already
closed to TCP_CLOSE.

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index a4dbe6d3a466f..7700265a13ce8 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -4679,8 +4679,10 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,
>  		 * deal with bad peers not doing a complete shutdown.
>  		 */
>  		if (unlikely(inet_sk_state_load(msk->first) == TCP_CLOSE)) {
> -			if (unlikely(list_is_singular(&msk->conn_list)))
> +			if (unlikely(list_is_singular(&msk->conn_list))) {
> +				mptcp_check_rcv_close(newsk);
>  				mptcp_set_state(newsk, TCP_CLOSE);
> +			}
>  			mptcp_close_ssk(newsk, msk->first,
>  					mptcp_subflow_ctx(msk->first));
>  		}

[Severity: Medium]
Can calling mptcp_check_rcv_close(newsk) here process a dummy fallback
DATA_FIN when a passive socket falls back to TCP and is reset by the peer
before accept()?

When a socket in the accept queue falls back to TCP (for example, on
receiving data without a DSS option) and then receives a peer TCP RST
without a FIN, subflow_error_report() skips propagating ssk->sk_err while
sk->sk_socket is NULL, and subflow_sched_work_if_closed() emulates
msk->rcv_data_fin = 1 even though SOCK_DONE is not set on msk->first.

Calling mptcp_check_rcv_close(newsk) here runs mptcp_check_data_fin():

net/mptcp/protocol.c:mptcp_check_data_fin() {
    ...
		WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | RCV_SHUTDOWN);
		/* on fallback, also emulated after a reset: check for a FIN */
		if (!__mptcp_check_fallback(msk) ||
		    (msk->first && sock_flag(msk->first, SOCK_DONE)))
			sock_set_flag(sk, SOCK_DONE);
		smp_mb__before_atomic(); /* SHUTDOWN must be visible first */

		switch (sk->sk_state) {
		case TCP_ESTABLISHED:
			mptcp_set_state(sk, TCP_CLOSE_WAIT);
			break;
    ...
}

Because __mptcp_close_ssk() takes the !dispose_it path for msk->first and
skips __mptcp_subflow_error_report(), newsk is left with RCV_SHUTDOWN set
and sk_err == 0, so a subsequent recv() returns 0 (EOF) instead of
-ECONNRESET.  Even with the follow-up commit "mptcp: report errors as TCP
does when closing", mptcp_check_data_fin() has already moved newsk to
TCP_CLOSE_WAIT without setting SOCK_DONE, causing mptcp_close_last_err()
-> mptcp_reset_err() to overwrite ECONNRESET with EPIPE.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org?part=24

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH mptcp-net v2 23/62] mptcp: no sf left: process pending DATA_FIN
  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
  0 siblings, 0 replies; 72+ messages in thread
From: sashiko-bot @ 2026-11-21 10:17 UTC (permalink / raw)
  To: Matthieu Baerts (NGI0), MPTCP Linux

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] mptcp: tcp_disconnect() clears SOCK_DONE before
  mptcp_check_rcv_close()
- [Medium] mptcp: pending DATA_FIN skipped for TCP_ESTABLISHED in
  __mptcp_close_ssk()
--

commit 95271396d761d6456e08d69c39becd026df9d3ed
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

mptcp: no sf left: process pending DATA_FIN

This commit introduces mptcp_check_rcv_close() to spool the backlog and
process a pending DATA_FIN or MP_FASTCLOSE before __mptcp_close_ssk()
transitions the MPTCP socket to TCP_CLOSE.

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 518321aedd1e4..a4dbe6d3a466f 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2707,6 +2707,18 @@ static void mptcp_cleanup_ssk_backlog(struct sock *sk, struct sock *ssk)
>  
>  static void mptcp_check_fastclose(struct mptcp_sock *msk);
>  
> +/* After the close, a pending DATA_FIN or MP_FASTCLOSE would be ignored */
> +static void mptcp_check_rcv_close(struct sock *sk)
> +{
> +	/* process the DATA_FIN after the data still in the backlog */
> +	if (READ_ONCE(mptcp_sk(sk)->rcv_data_fin)) {
> +		mptcp_move_skbs(sk);
> +		mptcp_check_data_fin(sk);
> +	}
> +
> +	mptcp_check_fastclose(mptcp_sk(sk));
> +}
> +
>  /* subflow sockets can be either outgoing (connect) or incoming
>   * (accept).
>   *
> @@ -2818,9 +2830,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
>  			mptcp_schedule_work(sk);
>  		} else if (sk->sk_state != TCP_ESTABLISHED ||
>  			   msk->in_accept_queue) {
> -			/* After the close, an MP_FASTCLOSE would be ignored */
> -			mptcp_check_fastclose(msk);
> -
> +			mptcp_check_rcv_close(sk);

[Severity: Medium]
On a fallback connection, does calling mptcp_check_rcv_close(sk) here fail
to propagate SOCK_DONE to sk?

When __mptcp_close_ssk() closes msk->first without disposing it, it calls
__mptcp_subflow_disconnect() -> tcp_disconnect(ssk, 0) before reaching
out:, which clears SOCK_DONE on msk->first.  When mptcp_check_rcv_close()
then calls mptcp_check_data_fin(), the fallback check cannot set SOCK_DONE:

net/mptcp/protocol.c:mptcp_check_data_fin() {
    ...
		/* on fallback, also emulated after a reset: check for a FIN */
		if (!__mptcp_check_fallback(msk) ||
		    (msk->first && sock_flag(msk->first, SOCK_DONE)))
			sock_set_flag(sk, SOCK_DONE);
    ...
}

If sk->sk_err is set (for example, if a RST follows the peer's FIN),
mptcp_recvmsg() and mptcp_splice_read() will return the error instead of
EOF after draining the spooled data.

[Severity: Medium]
Can gating mptcp_check_rcv_close(sk) behind sk->sk_state != TCP_ESTABLISHED
skip a pending DATA_FIN when the peer's final data is still in
msk->backlog_list?

When final data and a DATA_FIN arrive on an established, accepted socket
while mptcp_worker() holds the socket lock, the data sits in
msk->backlog_list.  In mptcp_worker(), mptcp_check_data_fin() sees
msk->ack_seq < msk->rcv_data_fin_seq and leaves sk in TCP_ESTABLISHED
before __mptcp_close_subflow() runs.  Because sk->sk_state is still
TCP_ESTABLISHED here, __mptcp_close_ssk() skips mptcp_check_rcv_close()
and starts the close timeout timer instead.  When release_sock() later
spools the backlog, mptcp_check_data_fin() moves sk to TCP_CLOSE_WAIT
after msk->first is already closed, leaving sk in TCP_CLOSE_WAIT without
SEND_SHUTDOWN until the close timeout expires.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org?part=23

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH RFC mptcp-next mptcp-net v2 62/62] mptcp: reset when the DSS disappears after a DATA_ACK
  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
  0 siblings, 0 replies; 72+ messages in thread
From: sashiko-bot @ 2026-11-21 10:20 UTC (permalink / raw)
  To: Matthieu Baerts (NGI0), MPTCP Linux

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] mptcp: fallback after dss_confirmed in mptcp_dss_corruption()
  on partial map
- [Low] mptcp: missing MAPPING_INFINITE in show_mapping_status() trace
  macro
--

commit 066a0ac232910122a63844ec66369cf60e694e69
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

mptcp: reset when the DSS disappears after a DATA_ACK

This commit tracks whether a DATA_ACK has acknowledged sent data on a
subflow (dss_confirmed) and resets the subflow instead of falling back to
TCP when a subsequent segment arrives without a DSS option or with an
invalid mapping.

> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 7dbad6debdf07..e66d8416fe797 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -1072,7 +1072,8 @@ enum mapping_status {
>  	MAPPING_DATA_FIN,
>  	MAPPING_DUMMY,
>  	MAPPING_BAD_CSUM,
> -	MAPPING_NODSS
> +	MAPPING_NODSS,
> +	MAPPING_INFINITE
>  };
>  
>  static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn)
> @@ -1242,7 +1243,7 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
>  	if (data_len == 0) {
>  		pr_debug("infinite mapping received\n");
>  		MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_INFINITEMAPRX);
> -		return MAPPING_INVALID;
> +		return MAPPING_INFINITE;
>  	}

[Severity: Low]
Should show_mapping_status() in include/trace/events/mptcp.h also be
updated for MAPPING_INFINITE (along with MAPPING_BAD_CSUM and
MAPPING_NODSS) so trace_subflow_check_data_avail() does not print raw
numeric values?

>  
>  	if (mpext->data_fin == 1) {
> @@ -1453,6 +1454,22 @@ static void subflow_update_dsn_base(struct mptcp_subflow_context *subflow)
>  		subflow->dsn_end = end;
>  }
>  
> +/* RFC 8684, 3.7: no fallback once a DATA_ACK acked our data, except MP_FAIL */
> +static bool subflow_nodss_is_fatal(struct mptcp_sock *msk,
> +				   const struct mptcp_subflow_context *subflow)
> +{
> +	bool fatal;
> +
> +	if (!subflow->dss_confirmed)
> +		return false;
> +
> +	/* before a fallback, only an MP_FAIL clears allow_subflows */
> +	spin_lock_bh(&msk->fallback_lock);
> +	fatal = msk->allow_subflows;
> +	spin_unlock_bh(&msk->fallback_lock);
> +	return fatal;
> +}
> +
>  static bool subflow_check_data_avail(struct sock *ssk)
>  {
>  	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
> @@ -1473,7 +1490,9 @@ static bool subflow_check_data_avail(struct sock *ssk)
>  		status = get_mapping_status(ssk, msk);
>  		trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue));
>  		if (unlikely(status == MAPPING_INVALID || status == MAPPING_DUMMY ||
> -			     status == MAPPING_BAD_CSUM || status == MAPPING_NODSS))
> +			     status == MAPPING_BAD_CSUM ||
> +			     status == MAPPING_NODSS ||
> +			     status == MAPPING_INFINITE))
>  			goto fallback;
>  
>  		if (status != MAPPING_OK)
> @@ -1523,7 +1542,9 @@ static bool subflow_check_data_avail(struct sock *ssk)
>  			return true;
>  		}
>  
> -		if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) {
> +		if (((status == MAPPING_NODSS || status == MAPPING_INVALID) &&
> +		     subflow_nodss_is_fatal(msk, subflow)) ||
> +		    !mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) {

[Severity: Medium]
Can an incoming skb that starts within the current mapping but extends
beyond subflow->map_data_len (for instance, after middlebox coalescing or
resegmentation across a mapping boundary) still trigger a fallback to TCP
after subflow->dss_confirmed is set?

validate_mapping() in get_mapping_status() only checks that the starting
SSN of the skb lies within [subflow->map_subflow_seq,
subflow->map_subflow_seq + subflow->map_data_len), so get_mapping_status()
returns MAPPING_OK and bypasses subflow_nodss_is_fatal() here.  When
__mptcp_move_skbs_from_subflow() then sees map_remaining < len, it calls
mptcp_dss_corruption(), which invokes mptcp_try_fallback() without
checking whether subflow->dss_confirmed is set:

net/mptcp/protocol.c:mptcp_dss_corruption() {
	if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSCORRUPTIONFALLBACK)) {
		MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DSSCORRUPTIONRESET);
		mptcp_subflow_reset(ssk);
	}
}

As a result, the receiver still performs a one-sided fallback to TCP after
a DATA_ACK has confirmed bidirectional MPTCP options instead of resetting
the subflow.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org?part=62

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH mptcp-net v2 20/62] mptcp: start close timeout on initial sf shutdown
  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
  0 siblings, 0 replies; 72+ messages in thread
From: sashiko-bot @ 2026-11-21 10:20 UTC (permalink / raw)
  To: Matthieu Baerts (NGI0), MPTCP Linux

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mptcp: incomplete state handling on initial sf shutdown in
  __mptcp_close_ssk()
--

commit 3ae1ff0e0bee2b5a84597ed1abd7a652f3bfc9b1
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

mptcp: start close timeout on initial sf shutdown

This commit starts the MPTCP close timeout in __mptcp_close_ssk() when
only the shut-down initial subflow remains in the connection list and is
not yet in TCP_CLOSE.

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 835796fd4f771..d3a793e96c9cc 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2823,6 +2823,14 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
>  		} else {
>  			mptcp_start_tout_timer(sk);
>  		}
> +	} else if (list_is_singular(&msk->conn_list) && msk->first &&
> +		   mptcp_subflow_ctx(msk->first)->closing &&
> +		   !inet_csk(sk)->icsk_mtup.probe_timestamp &&
> +		   sk->sk_state != TCP_CLOSE) {
> +		/* The initial subflow has only been shut down, and its later
> +		 * close will be ignored: start the close timeout now.
> +		 */
> +		mptcp_start_tout_timer(sk);
>  	}
>  }

[Severity: Medium]
Should this branch fold `mptcp_subflow_ctx(msk->first)->closing` into the
`inet_sk_state_load(msk->first) == TCP_CLOSE` condition above so that
`SOCK_DEAD`, `sk->sk_state != TCP_ESTABLISHED`, and `msk->in_accept_queue`
are handled the same way?

Because `mptcp_close_ssk()` already set `subflow->close_event_done = true`
when shutting down `msk->first`, the later transition of `msk->first` to
`TCP_CLOSE` will return early in `mptcp_close_ssk()` and never run the
`TCP_CLOSE` branch:

- If `sk->sk_state != TCP_ESTABLISHED` (for instance `TCP_CLOSE_WAIT` or
  `TCP_FIN_WAIT1`), no new subflows can join, yet `sk` waits for the full
  close timeout instead of moving to `TCP_CLOSE` immediately.
- If `msk->in_accept_queue` is set when the peer sends a TCP FIN without
  `DATA_FIN`, starting the timer instead of closing `sk` leaves the
  unaccepted socket in `TCP_ESTABLISHED`; if the peer ACKs our FIN before
  `accept()`, `mptcp_stream_accept()` later sees `msk->first` in
  `TCP_CLOSE`, sets `newsk` to `TCP_CLOSE`, and calls `mptcp_close_ssk()`,
  which returns early without setting `SEND_SHUTDOWN`.
- If `sock_flag(sk, SOCK_DEAD)` is set, `__mptcp_close()` already set
  `icsk_mtup.probe_timestamp`, so `!inet_csk(sk)->icsk_mtup.probe_timestamp`
  is false and the orphan waits for the full close timeout instead of
  expiring immediately.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org?part=20

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH mptcp-net v2 59/62] Squash to "bpf: Export mptcp packet scheduler helpers"
  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
  0 siblings, 0 replies; 72+ messages in thread
From: sashiko-bot @ 2026-11-21 10:21 UTC (permalink / raw)
  To: Matthieu Baerts (NGI0), MPTCP Linux

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mptcp: mptcp_sched_get_send() skips mptcp_set_timeout() if
  already scheduled
--

commit be05849933557cf4aa59c7bd40312183567d8767
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

Squash to "bpf: Export mptcp packet scheduler helpers"

This commit calls mptcp_set_timeout() in mptcp_sched_get_send() before
invoking a custom packet scheduler so that msk->timer_ival is initialized.

> diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
> index 1e59072d478c9..2f685986698b7 100644
> --- a/net/mptcp/sched.c
> +++ b/net/mptcp/sched.c
> @@ -189,6 +189,9 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)
>  
>  	if (msk->sched == &mptcp_sched_default || !msk->sched)
>  		return mptcp_sched_default_get_send(msk);
> +
> +	/* as the default scheduler: the rtx timer needs an interval */
> +	mptcp_set_timeout((struct sock *)msk);
>  	return msk->sched->get_send(msk);
>  }

[Severity: Medium]
Can mptcp_sched_get_send() still leave msk->timer_ival at 0 when a subflow
already has subflow->scheduled set?

Right above this hunk, mptcp_sched_get_send() returns 0 early if any
subflow has subflow->scheduled set:

net/mptcp/sched.c:mptcp_sched_get_send() {
	...
	mptcp_for_each_subflow(msk, subflow) {
		if (READ_ONCE(subflow->scheduled))
			return 0;
	}
	...
}

When a BPF scheduler marks multiple subflows as scheduled (such as
bpf_red), the active subflow can drain mptcp_send_head(sk) and delegate
the remaining scheduled subflow.  Because mptcp_send_head(sk) is now NULL,
__mptcp_subflow_push_pending() does not enter its send loop on the
delegated subflow and leaves subflow->scheduled set to true.

Once all in-flight data is acknowledged, mptcp_stop_rtx_timer() resets
msk->timer_ival to 0.  On the next send, mptcp_sched_get_send() takes the
early return above without calling mptcp_set_timeout().  If
__subflow_push_pending() then stops after the first fragment because
msk->snd_burst <= 0 (or fails under memory pressure), it exits before its
own mptcp_set_timeout() call, and mptcp_reset_rtx_timer() arms the
retransmit timer with a 0 interval, firing every jiffy.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org?part=59

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH mptcp-net v2 15/62] mptcp: return EOF after a DATA_FIN, as TCP does
  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
  0 siblings, 0 replies; 72+ messages in thread
From: sashiko-bot @ 2026-11-21 10:25 UTC (permalink / raw)
  To: Matthieu Baerts (NGI0), MPTCP Linux

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] mptcp: mptcp_check_data_fin() misses SOCK_DONE after subflow
  disconnect
- [Medium] mptcp: early return in mptcp_check_fastclose() skips subflow
  close in FIN_WAIT2
--

commit b22772fa5573efd7e1960e51f06a318dfce6573b
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

mptcp: return EOF after a DATA_FIN, as TCP does

This commit sets SOCK_DONE on the MPTCP socket when a DATA_FIN (or a TCP FIN
after fallback) is processed and checks SOCK_DONE before sock_error() in
mptcp_recvmsg() so that a subsequent reset still returns EOF after the queued
data.

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
> @@ -714,6 +714,10 @@ static void mptcp_check_data_fin(struct sock *sk)
>  		WRITE_ONCE(msk->rcv_data_fin, 0);
>  
>  		WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | RCV_SHUTDOWN);
> +		/* on fallback, also emulated after a reset: check for a FIN */
> +		if (!__mptcp_check_fallback(msk) ||
> +		    (msk->first && sock_flag(msk->first, SOCK_DONE)))
> +			sock_set_flag(sk, SOCK_DONE);
>  		smp_mb__before_atomic(); /* SHUTDOWN must be visible first */
>  
>  		switch (sk->sk_state) {
> @@ -972,6 +976,9 @@ static bool __mptcp_subflow_error_report(struct sock *sk, struct sock *ssk)
>  	 * destroy the msk as needed.
>  	 */
>  	ssk_state = inet_sk_state_load(ssk);
> +	/* a FIN received before still leads to EOF, as with TCP */
> +	if (sock_flag(ssk, SOCK_DONE) && mptcp_pending_data_fin(sk, NULL))
> +		sock_set_flag(sk, SOCK_DONE);
>  	if (ssk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DEAD))
>  		mptcp_set_state(sk, ssk_state);
>  	WRITE_ONCE(sk->sk_err, -err);

[Severity: Medium]
On a fallback connection, can __mptcp_close_ssk() clear SOCK_DONE on
msk->first via tcp_disconnect() before mptcp_check_data_fin() or
__mptcp_subflow_error_report() observes it?

mptcp_worker                      <softirq>
lock_sock(sk)
                                  tcp_fin(ssk)
                                    sock_set_flag(ssk, SOCK_DONE)
                                  mptcp_data_ready()
                                    __mptcp_move_skbs_from_subflow()
                                      /* queued to msk->backlog_list */
                                      subflow_sched_work_if_closed()
                                        msk->rcv_data_fin = 1
                                        set_bit(MPTCP_WORK_CLOSE_SUBFLOW)
                                  tcp_reset(ssk)
                                    subflow_error_report()
                                      __set_bit(MPTCP_ERROR_REPORT)
mptcp_check_data_fin(sk)
  /* backlog not spooled yet:
   * ack_seq < rcv_data_fin_seq
   */
__mptcp_close_subflow(sk)
  __mptcp_close_ssk()
    /* ssk == msk->first: !dispose_it */
    __mptcp_subflow_disconnect()
      tcp_disconnect(ssk, 0)
        sock_reset_flag(ssk, SOCK_DONE)
    goto out;
release_sock(sk)
  mptcp_release_cb()
    __mptcp_move_skbs()
      mptcp_check_data_fin()
        sock_flag(msk->first, SOCK_DONE)  <-- false
    __mptcp_error_report()
      __mptcp_subflow_error_report()
        sock_flag(ssk, SOCK_DONE)         <-- false

Because msk->backlog_list is not spooled before mptcp_worker() runs
mptcp_check_data_fin() and __mptcp_close_subflow(), ssk->sk_receive_queue is
already empty while msk->ack_seq has not yet caught up to
msk->rcv_data_fin_seq.  __mptcp_close_ssk() then disconnects msk->first and
clears SOCK_DONE on ssk before mptcp_release_cb() processes the backlog and
MPTCP_ERROR_REPORT, leaving SOCK_DONE unset on sk so mptcp_recvmsg() returns
the reset error instead of EOF.

[ ... ]

> @@ -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]
When sk is in TCP_FIN_WAIT2 and has both a pending DATA_FIN and an
MP_FASTCLOSE, does calling mptcp_check_data_fin(sk) here cause
mptcp_check_fastclose() to return early without setting
MPTCP_WORK_CLOSE_SUBFLOW?

In TCP_FIN_WAIT2, mptcp_check_data_fin(sk) calls mptcp_shutdown_subflows(msk)
and mptcp_send_ack(msk) (queuing a TCP FIN and transmitting FIN/ACK segments
on subflows that are about to be reset) and transitions sk->sk_state to
TCP_CLOSE:

net/mptcp/protocol.c:mptcp_check_data_fin() {
    ...
		case TCP_FIN_WAIT2:
			mptcp_shutdown_subflows(msk);
			mptcp_set_state(sk, TCP_CLOSE);
			break;
    ...
}

After the subflow loop sends active resets and calls tcp_set_state(tcp_sk,
TCP_CLOSE), switch (sk->sk_state) in mptcp_check_fastclose() hits case
TCP_CLOSE and returns before setting MPTCP_WORK_CLOSE_SUBFLOW, leaving the
subflow sockets uncleaned on msk->conn_list until the parent MPTCP socket is
closed.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org?part=15

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH mptcp-next mptcp-net v2 61/62] mptcp: report errors as TCP does when closing
  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
  0 siblings, 0 replies; 72+ messages in thread
From: sashiko-bot @ 2026-11-21 10:30 UTC (permalink / raw)
  To: Matthieu Baerts (NGI0), MPTCP Linux

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] mptcp: premature TCP_CLOSE and wakeup before
  mptcp_close_err() on timeout
- [Medium] mptcp: tcp_disconnect() clears SOCK_DONE before
  mptcp_check_rcv_close()
- [Medium] mptcp: dummy fallback DATA_FIN changes state before
  mptcp_close_last_err()
- [Medium] mptcp: missing mptcp_check_data_fin_ack() before
  mptcp_close_last_err()
--

commit 0c5fc2bb3f82340912e87636cc6d5fef891b87cb
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

mptcp: report errors as TCP does when closing

This commit updates MPTCP socket closure on close timeouts and last-subflow
closure to set SHUTDOWN_MASK and populate sk_err based on the subflow error
or MPTCP socket state, matching tcp_done_with_error().

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

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 1088caa788f60..5733ab548d12d 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c

[ ... ]

> @@ -2905,13 +2957,15 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
>  			mptcp_set_close_tout(sk, tcp_jiffies32 -
>  					     (mptcp_close_timeout(sk) + 1));
>  			mptcp_schedule_work(sk);
> +		} else if (sk->sk_state == TCP_CLOSE) {
> +			mptcp_close_wake_up(sk);
>  		} else if (sk->sk_state != TCP_ESTABLISHED ||
>  			   msk->in_accept_queue) {
>  			mptcp_check_rcv_close(sk);
> -			mptcp_set_state(sk, TCP_CLOSE);
> -			WRITE_ONCE(sk->sk_shutdown,
> -				   sk->sk_shutdown | SEND_SHUTDOWN);
> -			mptcp_close_wake_up(sk);
> +			if (sk->sk_state == TCP_CLOSE)
> +				mptcp_close_wake_up(sk);
> +			else
> +				mptcp_close_last_err(sk, ssk_err);
>  		} else {
>  			mptcp_start_tout_timer(sk);
>  		}

[Severity: Medium]
Can a fallback socket closed by a clean FIN report EPIPE or ECONNRESET
from recv() instead of EOF here?

When ssk is msk->first and dispose_it is false, earlier in
__mptcp_close_ssk() the call to __mptcp_subflow_disconnect() ->
tcp_disconnect() clears SOCK_DONE on msk->first.  When
mptcp_check_rcv_close() then drains the backlog and calls
mptcp_check_data_fin(), sock_flag(msk->first, SOCK_DONE) is already false:

net/mptcp/protocol.c:mptcp_check_data_fin() {
    ...
		/* on fallback, also emulated after a reset: check for a FIN */
		if (!__mptcp_check_fallback(msk) ||
		    (msk->first && sock_flag(msk->first, SOCK_DONE)))
			sock_set_flag(sk, SOCK_DONE);
    ...
}

Because SOCK_DONE is not copied to sk, and mptcp_close_last_err() then sets
sk->sk_err to EPIPE or ECONNRESET (when sk transitions to TCP_CLOSE_WAIT or
TCP_CLOSING), mptcp_recvmsg() sees !sock_flag(sk, SOCK_DONE) and returns
the error instead of 0.

[Severity: Medium]
Does calling mptcp_check_rcv_close() without also checking
mptcp_check_data_fin_ack() cause a cleanly closed connection to report
ECONNRESET?

If sk is in TCP_LAST_ACK, TCP_CLOSING, or TCP_FIN_WAIT1 and the peer's
DATA_ACK acknowledging our DATA_FIN has already updated msk->snd_una in
softirq before __mptcp_close_ssk() runs, mptcp_check_rcv_close() only
checks rcv_data_fin and rcv_fastclose.  Without mptcp_check_data_fin_ack()
advancing sk->sk_state to TCP_CLOSE (or to TCP_FIN_WAIT2 before
mptcp_check_data_fin() moves it to TCP_CLOSE), sk->sk_state != TCP_CLOSE
remains true and mptcp_close_last_err() sets sk->sk_err to ECONNRESET even
though the DATA_FIN handshake completed cleanly.

Also, because this branch is skipped when sk->sk_state == TCP_ESTABLISHED,
an accepted socket in TCP_ESTABLISHED that receives final data, DATA_FIN
(or MP_FASTCLOSE), and subflow close in its backlog while locked by
mptcp_worker() will skip mptcp_check_rcv_close() and start the close
timeout timer instead of processing the backlog and closing immediately.

> @@ -3085,20 +3139,10 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)
>  		unlock_sock_fast(tcp_sk, slow);
>  	}
>  
> -	/* Mirror the tcp_reset() error propagation */
> -	switch (sk->sk_state) {
> -	case TCP_SYN_SENT:
> -		WRITE_ONCE(sk->sk_err, ECONNREFUSED);
> -		break;
> -	case TCP_CLOSE_WAIT:
> -		WRITE_ONCE(sk->sk_err, EPIPE);
> -		break;
> -	case TCP_CLOSE:
> +	if (sk->sk_state == TCP_CLOSE)
>  		return;
> -	default:
> -		WRITE_ONCE(sk->sk_err, ECONNRESET);
> -	}
>  
> +	WRITE_ONCE(sk->sk_err, mptcp_reset_err(sk));
>  	mptcp_set_state(sk, TCP_CLOSE);
>  	WRITE_ONCE(sk->sk_shutdown, SHUTDOWN_MASK);
>  	smp_mb__before_atomic(); /* SHUTDOWN must be visible first */
> @@ -3416,8 +3460,7 @@ static void mptcp_worker(struct work_struct *work)
>  		mptcp_do_fastclose(sk);
>  		mptcp_for_each_subflow_safe(msk, subflow, tmp)
>  			__mptcp_close_ssk(sk, subflow->tcp_sock, subflow, 0);
> -		WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN);
> -		mptcp_close_wake_up(sk);
> +		mptcp_close_err(sk, ETIMEDOUT);
>  	}

[Severity: Medium]
Can a thread in mptcp_poll() or getsockopt(SO_ERROR) be woken on close
timeout before mptcp_close_err() publishes ETIMEDOUT and SHUTDOWN_MASK?

kworker                               CPU1
mptcp_worker()
  mptcp_do_fastclose(sk)
    mptcp_set_state(sk, TCP_CLOSE)
  __mptcp_close_ssk(sk, ...)
    if (sk->sk_state == TCP_CLOSE)
      mptcp_close_wake_up(sk)
                                      mptcp_poll()
                                        state == TCP_CLOSE
                                        sk_shutdown == 0, sk_err == 0
                                        <-- misses EPOLLERR/EPOLLIN/EPOLLOUT
  mptcp_close_err(sk, ETIMEDOUT)

mptcp_close_err() writes sk_err and SHUTDOWN_MASK before setting TCP_CLOSE
and waking waiters so lockless pollers see a consistent state.  However, on
close timeout, mptcp_do_fastclose() already sets TCP_CLOSE, and
__mptcp_close_ssk() then hits the new sk->sk_state == TCP_CLOSE branch and
calls mptcp_close_wake_up() while sk_err and sk_shutdown are still 0.  In
mptcp_check_fastclose() above, mptcp_set_state(sk, TCP_CLOSE) is likewise
called before WRITE_ONCE(sk->sk_shutdown, SHUTDOWN_MASK).

> @@ -4768,8 +4811,11 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,
>  		 */
>  		if (unlikely(inet_sk_state_load(msk->first) == TCP_CLOSE)) {
>  			if (unlikely(list_is_singular(&msk->conn_list))) {
> +				int err = READ_ONCE(msk->first->sk_err);
> +
>  				mptcp_check_rcv_close(newsk);
> -				mptcp_set_state(newsk, TCP_CLOSE);
> +				if (newsk->sk_state != TCP_CLOSE)
> +					mptcp_close_last_err(newsk, err);
>  			}
>  			mptcp_close_ssk(newsk, msk->first,
>  					mptcp_subflow_ctx(msk->first));

[Severity: Medium]
On a fallback socket closed by a TCP reset or timeout without a FIN, does
mptcp_check_rcv_close() corrupt the state before mptcp_close_last_err()
maps the error?

When a fallback subflow reaches TCP_CLOSE, subflow_sched_work_if_closed()
emulates a dummy rcv_data_fin = 1 even if no FIN was received:

net/mptcp/subflow.c:subflow_sched_work_if_closed() {
    ...
	if (__mptcp_check_fallback(msk) && subflow_is_done(ssk) &&
	    msk->first == ssk &&
	    mptcp_update_rcv_data_fin(msk, subflow->map_seq +
				      subflow->map_data_len, true))
		mptcp_schedule_work(sk);
    ...
}

When mptcp_check_data_fin() processes that dummy rcv_data_fin (here in
mptcp_stream_accept(), in __mptcp_close_ssk(), or earlier in
mptcp_worker()), it leaves SOCK_DONE unset on sk because msk->first lacks
SOCK_DONE, yet it still advances sk->sk_state from TCP_ESTABLISHED to
TCP_CLOSE_WAIT, or from TCP_FIN_WAIT2 to TCP_CLOSE.  As a result, a TCP RST
in TCP_ESTABLISHED sees TCP_CLOSE_WAIT in mptcp_close_last_err() and
reports EPIPE instead of ECONNRESET, and a reset or timeout in
TCP_FIN_WAIT2 sees sk->sk_state == TCP_CLOSE and skips
mptcp_close_last_err() completely.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org?part=61

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [PATCH mptcp-net v2 51/62] mptcp: keep the first byte after a simult connect
  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
  0 siblings, 0 replies; 72+ messages in thread
From: sashiko-bot @ 2026-11-21 10:31 UTC (permalink / raw)
  To: Matthieu Baerts (NGI0), MPTCP Linux

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mptcp: mptcp_syn_options() sets ssn_offset on MP_JOIN simult
  connect
--

commit f7213d49d43afa61976fc0d20b767c461864c635
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

mptcp: keep the first byte after a simult connect

This commit sets subflow->ssn_offset when sending a SYN-ACK in
TCP_SYN_RECV during a simultaneous connect and only updates it from
packets with TCPHDR_SYN in subflow_finish_connect().

> diff --git a/net/mptcp/options.c b/net/mptcp/options.c
> index 05b9c66aaed63..41eb39968a9a6 100644
> --- a/net/mptcp/options.c
> +++ b/net/mptcp/options.c
> @@ -474,6 +474,11 @@ bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb,
>  	 * in mptcp_established_options_mp()
>  	 */
>  	subflow->snd_isn = TCP_SKB_CB(skb)->end_seq;
> +
> +	/* simult connect: the peer's SYN-ACK will not set ssn_offset */
> +	if (unlikely(sk->sk_state == TCP_SYN_RECV))
> +		subflow->ssn_offset = tcp_sk(sk)->rcv_nxt - 1;
> +
>  	if (subflow->request_mptcp) {
>  		if (unlikely(subflow_simultaneous_connect(sk))) {
>  			WARN_ON_ONCE(!mptcp_try_fallback(sk, MPTCP_MIB_SIMULTCONNFALLBACK));

[Severity: Medium]
Should setting subflow->ssn_offset here be restricted to the
subflow->request_mptcp simultaneous connect branch?

If an active MP_JOIN subflow (subflow->request_join == 1,
subflow->remote_key_valid == 1, subflow->mp_join == 0) receives a
crossed SYN in TCP_SYN_SENT, tcp_rcv_synsent_state_process() moves it to
TCP_SYN_RECV and calls tcp_send_synack() -> mptcp_syn_options(), which
now initializes subflow->ssn_offset to the peer's ISN.

When the third ACK arrives with seq == subflow->ssn_offset + 1,
tcp_rcv_state_process() transitions the subflow to TCP_ESTABLISHED
before subflow_finish_connect() runs and calls tcp_data_queue() ->
mptcp_incoming_options() -> check_fully_established():

net/mptcp/options.c:check_fully_established() {
	if (TCP_SKB_CB(skb)->seq != subflow->ssn_offset + 1) {
		...
	}

	if (subflow->remote_key_valid &&
	    (((mp_opt->suboptions & OPTION_MPTCP_DSS) && mp_opt->use_ack) ||
	     ((mp_opt->suboptions & OPTION_MPTCP_ADD_ADDR) &&
	      (!mp_opt->echo || subflow->mp_join)))) {
		goto set_fully_established;
	}

	if (!(mp_opt->suboptions & OPTIONS_MPTCP_MPC)) {
		if (subflow->mp_join)
			goto reset;
		subflow->mp_capable = 0;
		if (!mptcp_try_fallback(ssk, MPTCP_MIB_MPCAPABLEDATAFALLBACK)) {
    ...
}

Because TCP_SKB_CB(skb)->seq == subflow->ssn_offset + 1 now matches
while subflow->mp_join is 0 and subflow->remote_key_valid is 1, a plain
ACK calls mptcp_try_fallback() on the parent connection instead of
resetting the subflow, while an ACK carrying a DSS ACK with data jumps
to set_fully_established without MP_JOIN authentication and triggers the
WARN_ON_ONCE() in subflow_data_ready().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org?part=51

^ permalink raw reply	[flat|nested] 72+ messages in thread

end of thread, other threads:[~2026-11-21 10:31 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-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-21  9:41 ` [PATCH mptcp-net v2 13/62] mptcp: limit an orphan probing a zero window Matthieu Baerts (NGI0)
2026-11-21  9:41 ` [PATCH mptcp-net v2 14/62] mptcp: count orphans as TCP does Matthieu Baerts (NGI0)
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-21  9:41 ` [PATCH mptcp-net v2 16/62] mptcp: let TCP send orphan data after fallback Matthieu Baerts (NGI0)
2026-11-21  9:41 ` [PATCH mptcp-net v2 17/62] mptcp: reset the subflow on abort " Matthieu Baerts (NGI0)
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-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-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-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-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-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-21  9:41 ` [PATCH mptcp-net v2 29/62] mptcp: keep listening after MSG_FASTOPEN errors Matthieu Baerts (NGI0)
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-21  9:41 ` [PATCH mptcp-net v2 39/62] mptcp: keep room for infinite map after fallback Matthieu Baerts (NGI0)
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-21  9:41 ` [PATCH mptcp-net v2 46/62] mptcp: reclaim forward memory after coalescing skbs Matthieu Baerts (NGI0)
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-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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.