From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254140; b=SQPkqIMz2p8NzDIXWtppJMrQ+MnN14k3OrWTEN9YQAtUfD4dgqkgnmmWY2Nner0+ZrZw HcGPf5TYCUukOy59o8b+kv9IqGR9WpH4sK2RMNuszuw0svrE+kMYp8sQno7m8gn+P1o9r +GkLvL0lMjz1FD7SdY5X5QOeZC8zw4LhKB+0XJ/1BTw64kQ8CR/wRR+qSLGW4ovXWKzS2 qkrcRkMEbf0Cg+GgwWJDYJIBxzty5C2db/W6Xkg2RNA/dVRq04cbtp2aXHgQGLYgbXVU9 QXQeQ0xYbJoFxwOJ+/xTcCa6cU6+qjUoo24RGFlWsiXaa34nLIh5YBwoMGvHK0B6JVQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254140; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=zdkOP5u3F8iJrSXZpJujP1iIRDBzaID9prVsX1HDW8s=; b=HfGeteU2UR2ABBHURQo8HN+2HUUJyyzDHUpgRifpBK0ppYAw+UMuLXBglg97JaXTR/Qu GPLM7Xr9lu0NPYOtqD9dP8MZDe60ngogmy5hK1QMeuQSdVxuWdEL1lL37lY7dQMCFvlZ3 4aHHZRvcFrHbY5KmkqnHzNh0KkbyL833S947rzfFGAXhWLUqFZaavQRDnehvxKeVbTNO1 nPqo2VWz6LNYvJIA1UesJ67l1k5YL+izQVt6ADLCydvCX1+tla0CEdK0DsyfttCBfR034 Y0p/0J1jJgZP/++XOwrsjCgFgjyi3XYdaU0Op3rbXdHZ+lQQQ0+/6vJ+BsnYkuWRx6g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HhStdCg8; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86B12606A320 for ; Sat, 21 Nov 2026 09:42:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HhStdCg8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DA0A1F000CF; Sat, 21 Nov 2026 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254140; bh=zdkOP5u3F8iJrSXZpJujP1iIRDBzaID9prVsX1HDW8s=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=HhStdCg8qy4uy1vCv50fNRmycgWKUXBVf4W07IMQdinsT2cHUo4gq8cKbI/NqsqMd O3DBw19vPTjmMxq7jmcg6jOtB9hR0Jlcczq89IS+QI2wd0NrT7hcyKUINE/FlyItjY 3dxp0PMI0rkm4osOH4Y19WtpE0c8gQxh+JkLpxzY2YDWnVGUvLTJlfYwjSr7y6JIMa gGA9IlwXanGU1BM+/ejhYBr9I5e43L5fbuT2/j3wB1o7/3tozsHivPjASoQHGflve5 SbGlndkLf+ImtO+Ac5XVKkx/HP7IP5Xq9SEb5o3pMmRuwrvgI74lz9Sz7LKNmNBA2q BbhqhtvjCsGtA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:40:59 +0100 Subject: [PATCH mptcp-net v2 01/62] tcp: drain the queues of a listen() that fails X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-1-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3641; i=matttbe@kernel.org; h=from:subject:message-id; bh=LlcC3gecNJA9oVVjOA445C6SC7Y9d9nYfwqNr2w5AiE=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0z3MrnBpsnvzv9KavHRpvemS9uOHWQKlw/TWmhnof N4eK+zcUcrCIMbFICumyCLdFpk/83kVb4mXnwXMHFYmkCEMXJwCMBH1uQz/VLw+pXkv+Vgmt2mL kGNdMn945BmGZ80n3Tvv7VD1fxu3hOF/5vaLf2J+7f4ZOGmldoD/Hwa3zdM9Q25eMH0l3X10d+w ZDgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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 l= eft [...] 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 [ 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) --- 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_soc= k.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) =20 /* 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 =3D sk->sk_prot->get_port(sk, inet->inet_num); @@ -1390,9 +1390,13 @@ int inet_csk_listen_start(struct sock *sk) =20 /* 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; } =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254141; b=V+EQuO+cXYECLA43uvk0A++K0TziLZeWAWAWfxnVmcOfs6Od3CvdTDX9QEisdWAGJdsu EqADFwkWFQY7vw2dmZceYJ0ky5FReT6l3HSlGcm547tH0cC+vE49Zg1M0IqW8BAUNKc1B 7kt9NUWv4YDClp9xfuoYzwvFv4sDJpHu9QvGLXHO2UZNgsZAo2PzFUpXr+RrOSBippmg5 hQyIYiYiYhb67AYi1TtW6kiKwhhMMU3MBdxArrx3UaZylFPsABm8CWqQjprgRYe0hc+Wm iv1DbCVTu4yIcOcqAxxWKV3A2m04B4mbnQzFayNqdO1FSg82SfcfK5N9ymO8FcWxykQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254141; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=WxsmbNMicaVwMZEG5JHAy06m1AL8tBuQiO8AbzOL7eE=; b=VzhvuANLxVV0CVQs6XISPj2g5mJ+r9SPgOjRzA7psLZi3zj6LKXef282kXn7TrC979hx CwfMRGvU1L9dPp8OGVMxYs7iv/MOLDK6Bd/BxgfEKoWUx462i5i/HFOOfnKQJrKD/1acC nWlm160b66VDLCIBGCHzDJiHlca7uERfY992JJjGxwsq85QxRzC2C8762I03GdDvEdiM4 FFcV+qDwji07g2wtPn1MMLmc05Vd4ieszukmG4Nc9i3MNOReIUTPr0ZcrHHRZR/GH1uJR M391ijbF6bSPMdYyS+s+GQGB0FHZXwwt3tPbS7iEFlxCNYxDGHu+JrjJpYKaHitg/2A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nO51gOnk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B274606A320 for ; Sat, 21 Nov 2026 09:42:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nO51gOnk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 966F31F000C4; Sat, 21 Nov 2026 09:42:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254141; bh=WxsmbNMicaVwMZEG5JHAy06m1AL8tBuQiO8AbzOL7eE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=nO51gOnkZTmFLCT+ZsBRwBCjMHHsB/ftZawy0r1aCb5pxf8MgJ6DONhJOmgKTWpfc UeRqcYKVLUbwGSMS62Y07ZnbyGmIGihxzuL32gHf2aIGoUJ/Aq1hrCVzERZ0VZxsuf Cnjqzinl0ILy87b5R8j7B/qR5RU9nTxVTap+2IQbbhjJaQuImXkYFx+VHbb+TZb7pZ YyLOfMrEY1RONxFdtmGzvXfN7S8lhIynvYqkBV74eFVg3MY1Jo9j1O+Li1QEC9YXbE 8WbMB3xRiLhYRehmoslaMDTSMrjY6B0/ADpbBAS29xtA2arS4gH4DdGKvTD/wKYLEH /NUswAGlIRakA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:00 +0100 Subject: [PATCH mptcp-net v2 02/62] mptcp: drain the queues of a listen() that fails X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-2-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2495; i=matttbe@kernel.org; h=from:subject:message-id; bh=8rExIGGyB9E4T4HHurHBbodR4Zj5UvBwD2NP5qj7ZoA=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0z3zcz21Hv2fO3nRjYinL2tjvl/k05zn/Xm17KZZy e85ff6ydZSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAEyEw4iRYVmbCs8t/Z0T+SJa ZgS8fVly6vj7u3e6M2+W/OYsPygo4svIcECldA3DCZ/282uVD4R4v/Z0mBm4i5/nRmXh1u0Vjr5 xjAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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 l= eft [...] result: namespaces: 1000 made, 923 taken down, 77 left Fixes: 76e2a55d1625 ("mptcp: better msk-level shutdown.") Signed-off-by: Chris Mason [ Shorter comment. Add a Fixes tag. Commit message: how the issue was found, and its symptoms. ] Signed-off-by: Matthieu Baerts (NGI0) --- 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 bac= klog) =20 lock_sock(ssk); err =3D __inet_listen_sk(ssk, backlog); + if (err && ssk->sk_state =3D=3D 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)); =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254142; b=tyxIC21XoW9A1pXWLEjWcaqCFImNoHIfV/CW9N+957LCnOX60j1Btew7xZywhdf6pzLX +fG9OgUUDAWUhUXLhgNWWpCu1kDjncEk3llTGnlC1CGHseD0QZBAX2RFNjoQDw6N4HWtZ If8boIKTunH5+i0Z+MGecDrB1aeXldw41YlbgPIuC3M6aG6VOP4hOiN7LfExHoHH1c7V2 S2rzKXqrOa1FdUxy3kGnwGEixVsBmmzVJwWAGkvi4pFHY5kLyUka1U6cHlzXyFGbMAy87 Ylzrr9V3C/qKixJkp+L3RABzeh/ZKDDZRTaNlwejxOxlVpgIVy6wK1mkerS7J2lh1iA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254142; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=mwizWJC4vbYxbo/rfWwMiJAXiRSi3rcOVXN6YPXeJ8c=; b=nVYnxZarzsPeCvr8OZz/HAGQmw22SwUPFEIW5aog3OtEkbqWsmInDsEWywwCOve2GdCV zPHnO3kLOraLS0ZyJyxryprBCskpbQStJo09lHeoeP2X9vdysF1Mch5LfkIDjeGCx8ZzP 6eW10pLKT3eE6IPZIIIw+WUKX46dqPbZNrqOzuzMypwkI1iUWR3N3F73ElBchu2NZuNtj kpp1mnrd2K1JyssKFb8nkrn9ZrjaMX5Ad9lRQyvVZhM1wsfbcC0CYU9UhOVe7Dwj5gFoU BveS4FErjLy/uI4pzS5MbwqK/t+UUtBXCgLdlur2WRTLOb8Mqnquk2kSa1ga2hjHW3A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="NLbMgq7/"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61F42606A320 for ; Sat, 21 Nov 2026 09:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NLbMgq7/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E5B21F000C0; Sat, 21 Nov 2026 09:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254142; bh=mwizWJC4vbYxbo/rfWwMiJAXiRSi3rcOVXN6YPXeJ8c=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=NLbMgq7/fa9dEzztwsxyteF44b+xoUJmBHlYcbjeHpT+1wqESKEgDhTts3DaT0kT9 lZgesa1AFPseInKeH9zlipDDKruho/0ogNBO1WNeWXgzBOQfyrp3i2LDJkzpBYa/hr FKG5bbr5AJhTGfb967FXfonwJOQuD0KfLxc7whfN8QHLBJNPKITI2JrZECZHlibEBs NT1Ei/iN6crl5d+wFprZt5Uu8wkdgIOd2WFtitllJ7S0/l4k3ZhkOnSOGZdi7slyTR 3MDmly2e6KHKzOmVVKV7vOM4H2C1FRLPbdrUxpddblv3H1q6kXIny0DybGr2T1eZPi +DEFb4/PniFNw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:01 +0100 Subject: [PATCH mptcp-net v2 03/62] mptcp: clear inet_opt in the child of an IPv6 listener X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-3-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4179; i=matttbe@kernel.org; h=from:subject:message-id; bh=RpKcXJ5+ychxfYTZbCru/7OJbFKn+vDQg7Vc2/Ieo1U=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ073CI1xFmXtUNryT4blfl/1WaamR5FE+rXaT7q+fu IM2+xztKGVhEONikBVTZJFui8yf+byKt8TLzwJmDisTyBAGLk4BmEjrP0aGF7Okb090D9+RJFQS ztr6Vc5GPLBmWUD/xU+OXUuYylMcGP576LT65XcaTTVs45341GnlSdutglesH08+Ero37J914g4 GAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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: 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 __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 PREEMP= T(full) Call Trace: 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 [ Commit message: how the issue was found, and its symptoms ] Signed-off-by: Matthieu Baerts (NGI0) --- 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) =20 newnp =3D inet6_sk(newsk); =20 + /* The IPv4 options belong to the listener, which frees them */ + RCU_INIT_POINTER(inet_sk(newsk)->inet_opt, NULL); + rcu_read_lock(); opt =3D rcu_dereference(np->opt); if (opt) { --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254143; b=d2zl3oL4Z7auYy8qm3rI676ZUC98lXQJq7KrKV/1z3/ZJHFhdLRaSESCHxHclcHjSX7S qyK9WOFxD8jqHdsg0pz10l6yQqYCAmJUfo6wGe8xR5qJJqex6M5cGl2wXynezIbJFnX+x MH/+Q8HQSi8RPlIvNLa3msUimT1q9d+s12L46dmjB6DLpx11bEGPiVCGlVI01wV/6citE Ao9QHBfECKOGo+fq8QlWYN2I5HHHeXZMHgM7Xo8OzVwaccrBM0canj3eRRzvW5hHZN0PT Q0VOu9ADYY48kHm5wmNqOc9eJN3uDVNagE02P4vefvfQbPm+s51SvEKInQElifsQA0w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254143; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=hVd6hiqFUCnHcgLi3LbAmEYhmx6SH1ijyBmtPpgPEq0=; b=CDYasXWTwXOA43QhDGzT0Cw/fk5Ea+98tc2NEkw6upWxLgMJUQhqDgN7r/jPitOQBrRf UWzTVzSym0fROO5kWiJKLuYvBDdeBj3wjHqypbS7MGqmut66CNHKKheIg1YG+zTdYBtPv HaV4cUuavZbQJGMmN/pmGgItcPFPkFgFkic72QjRU2Z3rZyW8FnSbIazYYl5mvGo/1Qwy NdU8G8o7NHxyUBX9FQ5HSmHfhaqSno/anYr3zEUPQxHWDbncmh0GlYJR4+6uCy9uJIZCi H4YpLiq7LbqRNELXg5FRqBSmvdw/1AzftWH95YvuB3ZUlAypb8X04isKWFbvo6rUxvw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=j5N1sZHE; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E42A606A320 for ; Sat, 21 Nov 2026 09:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=j5N1sZHE Received: by smtp.kernel.org (Postfix) with ESMTPSA id 854B61F000C0; Sat, 21 Nov 2026 09:42:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254143; bh=hVd6hiqFUCnHcgLi3LbAmEYhmx6SH1ijyBmtPpgPEq0=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=j5N1sZHE4oxxIFn4u1zYbXOpwuyZ6Fqt4pbpoOSKPj96TBrlphGYWqPvt8MAz4iEd iA2fwAec8a18dp8PcX3b/JiEvRDbrC7zywknCHzTWMYohWIP0TvrzAcCMzqn//0QRe TLCtm3sPjdnvaWRyKb908qELMa5cx6OJMsLQIZs/sTdnMEAa8RaqPjfBPz25eH15Gd iBhrquRVUCOMVmVfPkOxZFE7Kw6VrJdp6NLRu8ey/OJ4CytiPZAzAfgwn3WgXhtX5+ C0NRlNpmHHXdGSMam9LH5KLKQHnGyk6EuMEJgz7u1CNftZPD4d2ai361ooNBT+g5hD S0HPkqmGnbqmA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:02 +0100 Subject: [PATCH mptcp-net v2 04/62] mptcp: pm: work on a copy of the received RM_ADDR list X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-4-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Josef Bacik X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1776; i=matttbe@kernel.org; h=from:subject:message-id; bh=H2fyBuEiMX3mZSO0V08Z9k1BTg37/v93dXMYAiWsMx8=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0731VLuMH4Ru4n6zx4yR85yF/94Ve7c9/HZ7jvNhi dWfqz7v6ShlYRDjYpAVU2SRbovMn/m8irfEy88CZg4rE8gQBi5OAZhIySWGn4yvira07VrG5TtF uYrT5mPVZje58MbXXq5/zryX3+F7vYSRoTOOwfvjTf9md8HEogtK0idfWeeyHfn95J0uX/cFsW/ MLAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Josef Bacik 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 [ Commit message: how the issue was found, and why it is fine without a reproducer. ] Signed-off-by: Matthieu Baerts (NGI0) --- 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_s= ock *msk, =20 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 =3D msk->pm.rm_list_rx; + + mptcp_pm_rm_addr_or_subflow(msk, &rm_list, MPTCP_MIB_RMADDR); } =20 void mptcp_pm_rm_subflow(struct mptcp_sock *msk, --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254144; b=L+2RPoTLfcZwMOP7XnNKqzbIRtHfReTR2lP2KVPJuAKP9c7f8cwOVFacvfaFDlGVUjb9 h8ax8IRmZpzKIHXsc12+UWp7Y+6GaABi/KelfV8KwRfdg+mEHwzBcZONGXa9G11FbOb62 63Buxw21pwotemaEqACbVNp3+LudMJ+5MzLwENYei3njcSFw6S7cEuIM81OceF0vLodhB M2NMUfntXxeBTtOiySfpjNZYbgMZANKDeTctVagIAzjL52TK8ojIpghh7jD0UvZMeJ+7u pbWVZeZ0kWyk99OGqwDhiXEc7N+2ofRKbLciRzLOWor05uwAtJfM8v3a4WYPAjzq1Rg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254144; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=cr4CNsbsVoztQq7JO0OWsEvUzbN7PEmSYtrgGym3LyU=; b=T1zQR5CHAXSZ02gPwqv074o/VHWsMuLrjFjNe6GP6BIAY7HaLq6+F+zOmzv2QhDKHQYR 2D44rq49Mtc/rIlDTuz2ltbSIADov1JzDMk9rLxYb0pNbl0H2Oied93OPMVQjDOsvRvPY g9eIP1s2TnkmF160Lr1zRQMOmO8VrjfJgz76uJ7/GhrkM/lrJdnXFl/aZyxC2hKLrCWey sp4s0dP5hLlC97n4dKdefzbWXNp/1AN3243KCrk/iOpzWHnAcJmMMQKXyiwIKee+xpsG7 mwndIuED7KiZ7jyWHLocyGgvEQuTk/Cd69rJDm/yQUqsNeWu/ss9XH/Sp8om6ChgRBQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HVd4rjbC; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78208606A320 for ; Sat, 21 Nov 2026 09:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HVd4rjbC Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C39A1F000C0; Sat, 21 Nov 2026 09:42:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254144; bh=cr4CNsbsVoztQq7JO0OWsEvUzbN7PEmSYtrgGym3LyU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=HVd4rjbCCyXoS+ezdImrxgO54guvA8dcX+Vgg2jBCtYXpI9fCcGWI+BTHMPhrx97U Ws04xLfI4ntezC0QRfPm1a/ElexPxA0/zpNGzvkMA+2KwwnPAR8s94WfUGHn2YtDRr pTmvMQk+gEx1QZxL52bDRbY6H9xPJ9nl4F5fCoLlBguziJPWYfQAVapN5UgHzYC3ML f/xYKoHIlIVQFoc1bKksGcG/9iOpF7mh+7MuJ13YSxrEp2JnY2Vo9SNBAbpeBsboQP LvoTOuvtSIV78kKhNj8hz6P5DU3+NkLPdJA4rcO9U9DQ5VERm5FPH0zKga7BVys36R YkiE7xD0hRKhA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:03 +0100 Subject: [PATCH mptcp-net v2 05/62] mptcp: pm: don't drop an RM_ADDR behind a pending one X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-5-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Josef Bacik X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2967; i=matttbe@kernel.org; h=from:subject:message-id; bh=VWdDK5KC2XQ0B/Gz98UUdDiaS7ljfPigv0yw2cJSFtU=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ033Wf97xVornPGfVFUWrH/Mt9WJnFwRp3VxtXhNgs lNiKpNSRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwETaLzAyPNj7+PiWC20fpu46 +HXd7j8n8hjy7LuYJqpvtOaeLvnUagsjQ6/+z1SR/Zce6b9xOfff7om+ZPO6P5vfpRZvYu2atut IDSsA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Josef Bacik 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 [ 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) --- 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 =3D &msk->pm; + bool drop =3D false; u8 i; =20 pr_debug("msk=3D%p remote_ids_nr=3D%d\n", msk, rm_list->nr); =20 - for (i =3D 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 =3D *rm_list; - else + pm->rm_list_rx.nr =3D 0; + + /* the worker may not have got to the previous RM_ADDR yet */ + for (i =3D 0; i < rm_list->nr; i++) { + u8 id =3D rm_list->ids[i]; + + if (!memchr(pm->rm_list_rx.ids, id, pm->rm_list_rx.nr)) { + if (pm->rm_list_rx.nr =3D=3D MPTCP_RM_IDS_MAX) { + drop =3D true; + continue; + } + pm->rm_list_rx.ids[pm->rm_list_rx.nr++] =3D 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); } --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254145; b=zTUnjAZKSVgEw5Ig3l8e0n8G+r17Pwe4N6Z4SewBhMWQdmLUga1sBE1zNxeSC+O8Vndo N6P7P4+D4mXBCkjEuotRy34u5o++LaHjqeWuQ39uK+CIbs8Pp5BEY1YS5tUxNP+ojt9qo OTfwqVXBEeocOwKmt08GSfMSs+Im7b07pZLR6wIsdRfGS3jsZT91FuPBxOI7pQVx/v6pT b8MvG1ax0gsBjLiIamFHzmyEKEHAR7qnQMVpsipIs/QtRTcI6SsmKu3WbilPHuwM36DmP YHyQlJnTHpALrspx1UUGRbgZMVdoNrPpCO69PRwOt6PbiiP9S5Vo8N87lBneeRAfeZg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254145; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=NrHRiJJjs6LTRsR4S/VnHtaXqyEMNcfnoaoksDZJkCg=; b=cAiDDU5KddeyNFy6dk+32o1bzDQ0vUGxPlZUeWibtLpKL5nzsbvnuNfkB+22aEm0+5V2 h3UGSOhxhxBspRQrzjnwF0U1rbZVoN9LoGzgZtqHTDnCemHBISytg+mikxLy6hEag5agm kaKlFFXaTNSjgYruLCzbulrSOmZNTdXbAifhIjiUzeWknGN6TvILYW7AYQPQkc5Db4jes vyjNKtWjhF7smTgF7JIMFFfO8MiGgF/ubW4VMMrrZg0K5DUdvs4j5HdkNVtuNJ/KKbI9h lohA03wJDsyECnljnqkelpjgsUUV+++MVaoBHXj3ZMXdufjut5Go/AHqTinJSCaTDZg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mdv8MGu2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E081606A320 for ; Sat, 21 Nov 2026 09:42:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mdv8MGu2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 737F41F000C4; Sat, 21 Nov 2026 09:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254145; bh=NrHRiJJjs6LTRsR4S/VnHtaXqyEMNcfnoaoksDZJkCg=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=mdv8MGu2CyOn3FU/j27JGutw9X4asVtO9Y9siKFw8VWaw3CB0KG2sc7OhNf8D/0J3 /vahS+MAL50Vs3m0+t5NY0cHQnsnI5MPKfiMw9XNdjhUaQ3JHXRe1Ar9fVwPXp8Kwf LyxOa2lIe1N+SK9zQGuqElCH0iYqaXvO9zKexxPVev9sUEcb8g+8fPbKGPAvnwRK01 S83hhuibz3kQ/i/vt2FEjLrs11fLqMUXQDLTfdNRBpzBVCivYQMap+npcWpz0r+z7e IyzxN5TbGXqtcqchiCSJeNOQ/NjvfcODEumInkOavfg86f3uqMKhTDLtpP8/GjSWsW o9MEirDVQsb7g== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:04 +0100 Subject: [PATCH mptcp-net v2 06/62] mptcp: pm: don't drop an RM_ADDR because of an ADD_ADDR X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-6-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Josef Bacik X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3702; i=matttbe@kernel.org; h=from:subject:message-id; bh=RhpWiFJOubzzETB5WHE8QdEog8R7ekloOjGRrIx0VK8=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ032+T6uZXZpSUVWnzKJ+ipWve7Fisa2x9bXWnDtzH nvlaKV2lLIwiHExyIopski3RebPfF7FW+LlZwEzh5UJZAgDF6cATOTLaYa/MpYld+dWxDvOf+W3 /xp/+bmJnTonzjl4lk2fp/PISairheF/+CX3jrvP2J0nSG9gWvZl46I5E7iq/3Quq7t/yyb62ud UHgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Josef Bacik 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_sign= al each other") Signed-off-by: Josef Bacik [ 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) --- 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_lis= t *rm_list) { u8 rm_addr =3D READ_ONCE(msk->pm.addr_signal); + int i; =20 pr_debug("msk=3D%p, rm_list_nr=3D%d\n", msk, rm_list->nr); =20 - 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 =3D *rm_list; rm_addr |=3D 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 =3D 0; i < 3 && mptcp_pm_should_rm_signal(msk); i++) { + u8 signal =3D 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) =3D=3D signal) + break; + } return 0; } =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254146; b=1N+bX1lQTo05caeM8nGOleQWLeUNJjncyeGCECYQHG9m8TubKghsMug+7baRjDausuZm 23mOs5Om8vd5nskmlszXCSVfXPpkm8bsUentp6GZPJc7DXXkfyP0G1k9RyTAFgy++TyuF 20/INQJtkGVHGovR8fQjOMqxziWOYvmuCC3S40dXZddOwnvwoGvamOaLTOe/yi+hKmyVa APSDeUuY3LEQi6tJv8kcGFohrwKMYX0Hk3YuifpIChGUkEsSQilTlA5qcJiOtj2Od3nR8 jyhbkQpgis7h7YQQJNRt3qpCKw4Ey5WCEcT10722WBR1MeUPkvy4QRezFBjCDzSlarw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254146; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=qMJtYmCoS7IvqzxCfiYm3OmSMWe29KXo2X8yhoU27FM=; b=pjC+kAJa80T3I1FyAtcXiPudwgc6b/Jc/JACqOpOoz85cI3uf6gm96io+B4EAztfNWhq d2p8hzbVT/cZeIM7/uPSUk+AMZlWbSuiNvtWSkfMowVT9hjnrQ87dVyGXbt8xZKxBA9Sn 4eCtWslZJ5AGjL062aEOkPHV5py/2x56tbt2cMRYqAnHjrSnGuR3sY0ZJ4qj7MTeFK6rC 1VY6DqnZ0iDPDN7IDFzjvGzx9rUK2f2NQISoYJEZVXHd00PYUZyMb8f7vZa6FIPIFRJRB F3fWZ6ZNa8zqs1eHWjLc6zcUyUi+LqgMYnvzlYfqfkqCdM48nKeJQKdlTykEHvTZMBg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eEwm0G08; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F37C9606A320 for ; Sat, 21 Nov 2026 09:42:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eEwm0G08 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AA3C1F000C4; Sat, 21 Nov 2026 09:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254145; bh=qMJtYmCoS7IvqzxCfiYm3OmSMWe29KXo2X8yhoU27FM=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=eEwm0G08z8Yd6JM9G4dW+5gcx2P3oQhHaTYuHKsXFXKvk9KqzFoyK0w/MUv9EWnfx F8zRYYHGO7xcLeSIrW7cA56N/ALwO3DsupeY3UOPYn+tvNFFqafj4Hz2Kn0c/ZtNoH CUxycu7UQlgwKwEZcKDM8pYUFyiEZsap+LDArqVB2dDxX317Z2vxx8Tl8RhT1BF1XQ v5gfm6+irfJW+fp38cXAeDikJ9oQ2VO7Fl5tsoQ0mGSvCmDbBczn7WklIygTBOeMWa dYfomlHlCc0LZnfdHaBjFGQ0MoYZ2xmsHJWae39PS5k+BuYy/4GUE8VmRb08TwmoyK zDgCsmWlzRSnA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:05 +0100 Subject: [PATCH mptcp-net v2 07/62] mptcp: pm: keep an RM_ADDR when computing the MSS X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-7-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4323; i=matttbe@kernel.org; h=from:subject:message-id; bh=bap6/1cQgE+Am2AhJ7tvVe6ZKpQpwlMHLQG0tkiHaj8=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ031bsr1fisiUJKZf+Xc9Yl3+rZ6Z0+1NtipeCqkNc DzaxrG3o5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCLVLgz/fSc56ieWFifO+iOk E73+YEssf8FtjcdOHW+9pJZqTZR7wshwosE+o8o3prKnPlB8Zl3/EbHiw1tTag6JvXncm3JsxlN +AA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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 s= ock *sk, return true; } =20 -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 s= ock *sk, int *size, int i; =20 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; =20 + /* without skb, only the size is needed: keep it for the next packet */ + if (!skb) + return true; + opts->suboptions |=3D OPTION_MPTCP_RM_ADDR; opts->rm_list =3D rm_list; =20 @@ -933,7 +938,8 @@ int mptcp_established_options(struct sock *sk, struct s= k_buff *skb, total_size +=3D opt_size; remaining -=3D opt_size; ret =3D true; - } else if (mptcp_established_options_rm_addr(sk, &opt_size, remaining, op= ts)) { + } else if (mptcp_established_options_rm_addr(sk, skb, &opt_size, + remaining, opts)) { total_size +=3D opt_size; remaining -=3D opt_size; ret =3D 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_li= st *rm_list) } =20 bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remainin= g, - struct mptcp_rm_list *rm_list, int *size) + struct mptcp_rm_list *rm_list, int *size, + bool size_only) { int ret =3D 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; =20 *size =3D len; + ret =3D true; + if (size_only) + goto out_unlock; + *rm_list =3D msk->pm.rm_list_tx; WRITE_ONCE(msk->pm.addr_signal, rm_addr); - ret =3D true; =20 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 remainin= g, - 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, --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254147; b=ymztv0/hIfG37qXx8PFznPObLGoTi0/2H5xxF0HTySiiguhGOao74OXjzHtUiIEAsJ71 KKddMn9IXwXSq4H18izeX/5ShS7cRFfKxNE62FjnI41ulrZ2N62Dghy9vPcHDrgbOnIz+ rMXws2uFF1R49EEG6To5mNrJvAKbYpV1OOXe/nkPCoOptVBwdpx98qjhDOPxbnpC0wZQI Y3vh53ojsVw1B3SUeb+Y3pxc2ZwQEFh1LvsyGy2RMwmh06Tqm0yO6uiUWBhz9HTWYH+FG xAxcWHU7daEmfKPATt/RINdGsJxu8XTkOrU2yCMvhimGGGSL2WCZMuRBtKYNYgbKFXA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254147; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=7n1AQslQEPAAxUCmuc1O+7WfE8WOJXjYr5/K+PVKf+o=; b=SnLzbAdCIk+Gl4fiVAOz5s1HbSWdJnRl+Xa9XXrW8NCk1KgL2JBK1gVJ4rHhgZL5OQg7 MP6lp2rh1Pv35GUkSsjM/A7ggYQ1J4eP4dAUp21Pe7se4LbUbYRxpTuRtHslNor2NxfJI xd/4/Qb7zN0jlcBN9eIap/oWBAs9ebo2A+olIC3VeErBvjtMeWRw39waaHlzstMDVkt0o 3CE31bpR/0PapAdlyR66E8KvvJY2Rdd9zSqXjsFYLRHDidjXNzHrY+iNrRu6fICxLlKu8 oTyLZa4aTgKyZlg/EZT1H8jeKZCz1qyxZVpBC8pd0dVJftFR2i6X9ADVn5DRNUmOwpw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FtfrFD0I; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11AA8606A320 for ; Sat, 21 Nov 2026 09:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FtfrFD0I Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D8671F000C4; Sat, 21 Nov 2026 09:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254146; bh=7n1AQslQEPAAxUCmuc1O+7WfE8WOJXjYr5/K+PVKf+o=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=FtfrFD0IvYd3HXyRu90hterXIWNLyqKUICIo1Y2IpPQeq53cYHfCc6G4oiopemf2w wajPZAIAIVirJ9CUCKNgvg8duZ5twXWOZrQoTEhFBcDjz9Y3ziTO6RUqF7LanAfCdc 1InX/FnarOLubTq9cNpl+HVN2Xa/1Ea/O39putJTz2aOqkcbQ8RiRJbJ/Y5S2T4ydX b5TuyxHaB7mQjAXpkDXwXVcOCZ9niNhTtDfhDqInPjpbImUMf0HonpHxo13pqm0kt+ wu1eQl5F7A0fZezfZBakHsYQO2zJktExn4K8nrXFeuqHWD0/hOQkansbWdcmOI2gn4 EIi+zxNHFpMAg== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:06 +0100 Subject: [PATCH mptcp-net v2 08/62] mptcp: arm the rtx timer if a push leaves data behind X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-8-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3919; i=matttbe@kernel.org; h=from:subject:message-id; bh=CqKE6HROO2t3zj/guspHPxEgWY1ZJTzXQyiTQEgjGD4=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0/1cNV91R5+0qBJaIvapOqJ8/7mopVv6ROe/K3iaq tVufOFRRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwETCBRj+8EQzNM1gZrC/zSC+ s7VrQcrFvUWK7TfPvL1wZvnlqSxc5xkZfupbSVcp2v/3n1/iU+7zedryrQafrrlf/zG3dMWzm3X JfAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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 wer= e 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=3Dnever [...] [...] arrived_before_the_second_send=3Dno [...] Fixes: 2ea6190f42d0 ("mptcp: schedule rtx timer only after pushing data") Signed-off-by: Chris Mason [ 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) --- 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); =20 - /* 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); - } } =20 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 soc= k *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); =20 if (msk->snd_data_fin_enable && msk->snd_nxt + 1 =3D=3D 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); } =20 static int mptcp_disconnect(struct sock *sk, int flags); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254148; b=bLEbslHNTRPfb5Ycon0a6mC9ereXyWjVyxDjD66MxmqhmIF8PRdRhwtj6Zx7mQUa4zM/ BzDAmJ0FNo+G8pgqocP5h2inS1sKPCwn38nhvd8G1dbETkoySHRfT7UN6O/1BqFzieqkD tvkWCrSI7Guhca3cGxbmv/xgypKQ+RGWkfoz2p9lDsegxQ5OvtLdscCbvQ16Y7P95DTJT 2bsfaEOkogrv28Mc1BU55iDKnfu38ZsLH8xdBd8fEUrpfv80KwDdBwT4Ykt4C24wGcLMv CNCa4xNCZkvEyeKex05Lwvu0jwkSwmSUqKhNKHAoJqqbtfr+TdMynhHX0cKNnjJlyHg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254148; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=ZIEEoUlkKmOIecp7xQYBG92fVqFc43X1gCRji74IyJ8=; b=tsZF8gfskdV1w+LZjE6wspBPpT9Tw+nMfD/QG34SPrM7cjCsZAx8k/y3pfTxrck5rm9U 8wcqLm1aJm3FgHTx0E+nind6QrEfXJex5dk8Tv/1Z93/auN/p0GIFtconRQdZ/2dTFa43 2P20BKJFIsIDcXk+JZnnuOnGXD60QfRjC2halGNhwwi/YN9in0kHx46stgS1qu4htljJS pypHdzboJ0MataLPAmQJe1U00mX7wqM64SRH7RuYqVFJWBZDLNnhzO7Rl8cd3WHw8pQQQ vagCANrovakJ82R6/NbWmlX5HEbuwGHkkqsJkai0CUIIkUNdc9ckGIdDoegH7qpIAiw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ipt3YkzL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ADE5606A320 for ; Sat, 21 Nov 2026 09:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ipt3YkzL Received: by smtp.kernel.org (Postfix) with ESMTPSA id 354111F000C0; Sat, 21 Nov 2026 09:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254147; bh=ZIEEoUlkKmOIecp7xQYBG92fVqFc43X1gCRji74IyJ8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Ipt3YkzLgFmNSuDRpZshz0zMxFOY8Liz7ZU28ujjIXFTPitX1+SAEO/j3UK5CQNux U8/xmU+0dHeaJTNxuDRo1hflH34xl2OucaI9xKn7jLjD0O2mPbxo5CiqK8YQcyShOh F38Xcjsi5pPgjD+cnOBfbCQpRYv9mFFTvGc6eppWiZBpveyrZNc5ekfJEBC+qVxt4O jVCTJX/bCFNfQ/NEyH15Vt4XJbKYKkOe9Z6j5P7KvIERziUNyu0aHg+Vs7o3hJPNDe efjkCcqUrn5fKvKTaGRX5Pi5M72W1k1i5Wr8WPN5unDl1pyyrJ3tQtZYBhndInM2Qw reUadU3SMegsA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:07 +0100 Subject: [PATCH mptcp-net v2 09/62] mptcp: force the charge for the first skb of a subflow X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-9-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4367; i=matttbe@kernel.org; h=from:subject:message-id; bh=HGPrQWelvsEIVnJtJ3YWyKXWZ1UaVMs81wOcSGQG5FU=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0/3XeifurpG5tdVp2rHM5etZ96UmycnbeM3L8z12u que92h3RykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwEQsXBgZrpZOmRB/87LsSl52 7+P7gvd57Y1a1hsh7aI+c8/L5/7Kyxj+xx29t9h7YZrJ95DmouCYWXvsO5/PdTjf/Wp/lMzzLcs 4mAE= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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=3Dbehind-the-second-send t=3D338.9 conn=3D0 [...] answer_at=3D= 336.4 IDLE label=3Dbehind-the-second-send t=3D338.9 conn=3D1 [...] answer_at=3D= 4.2 Fixes: 724cfd2ee8aa ("mptcp: allocate TX skbs in msk context") Signed-off-by: Chris Mason [ 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) --- 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; =20 - 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; } =20 static struct sk_buff *mptcp_alloc_tx_skb(struct sock *sk, struct sock *ss= k, bool data_lock_held) @@ -1449,6 +1453,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct= sock *ssk, bool reuse_skb =3D true; struct sk_buff *skb; size_t copy; + int avail; int i; =20 pr_debug("msk=3D%p ssk=3D%p sending dfrag at seq=3D%llu len=3D%u already = sent=3D%u\n", @@ -1522,10 +1527,14 @@ static int mptcp_sendmsg_frag(struct sock *sk, stru= ct sock *ssk, } =20 copy =3D 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 =3D tcp_wmem_schedule(ssk, copy); + if (avail <=3D 0) { tcp_remove_empty_skb(ssk); return -ENOMEM; } + copy =3D avail; =20 if (can_coalesce) { skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254149; b=HxyYhyyoaa/y04caohj8wtUvmxoR0aNrNWycUr27r5Dtkcihul7iIObA3Igcmvy3mtdM g/XHapqRWGMroVitYNAzagQeOvwEnJwkqpbigcBKgSnhSKeTqJlFf/NJRreoj1zYSr51v aDlyLzUrDOCWaCC9uwkmRw1uBJO2Sgp7ipC69EahEwr5inWDHutfPo4u64YKpMc4iHYJe yb/4DuX5Dihk1C8dK8BVRnxeZl3X08hzOBe0JBvIjShNWSUtEjQwuURCMxSsTxCVjiV8m zOrDLdd53CoDDa8a+Tq+mFNJOMJlniQ2cTPXmy7uBBxDUhVACA252M1q9+HZaBUUM+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254149; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=1f7An4Hb+QOdkzOwYoQKBvA2ae7xx/jJtrVwvgtdcLg=; b=wuYw9ux0Z91nd+LpkKwlRowEEhB1oclxnvO5cpwC1tR4ez8AV0qOG3ijrHnzjWob/byE ig8QfplmyzbaxYuYHbyy1/bjjgxoFPUGWiNx7Mpgzgnzn1d5LIyiA5BqRDACHpTu8JhZ4 f/ACzExv6Q+UNwCRLPgGv73e6Kw1Rkfe9cQhfCBGw3YaAu6aZs/fj13Ch8xWm79W4H21a T9ghe4ist40mTtbi1ctCgycZjxqJK34vne1PohQrnd1eq/tL/XxaMdMqPUl6j4bMneh+H v97BcHM6HVEVki+POwyxjaAjmUx/WD+UWzWuXrioF9XZj6U1vxsOvajf6FoSQRttD8g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aMKxqBdc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE658606A320 for ; Sat, 21 Nov 2026 09:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aMKxqBdc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 341591F000C4; Sat, 21 Nov 2026 09:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254148; bh=1f7An4Hb+QOdkzOwYoQKBvA2ae7xx/jJtrVwvgtdcLg=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=aMKxqBdcxBLi6n0fdhZbldytBayqhyhqCzL0oblngjDsJ3Ys/XoVA+x5mly5RKva9 zOKycOTQR92MvVK+4W3VkklwG3pABSef3yLI7YFlapnXAUq66G2A+UOS/VNwPFEBf5 Thxs/4SlQxo6xSljlkgGZRvrRtNvcfkgIXwWr9AOWqW99f+hszfAufPaNH5ZvZ8ZFj +0PCPAy1TwYZ3vUMtNa+MHxCv0S8YKBBeBn+/SuQwQ8lajZIlGdzC2utI5VA4aFnZM 9MyfZSpDQnorNa8tQAzGLE1VVO3+oYwgI2lnZxligW2y18NooSMakQbn8QKcrZkYqu df/Xc9Ex126wQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:08 +0100 Subject: [PATCH mptcp-net v2 10/62] mptcp: leave an orphan's DATA_FIN to the worker X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-10-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3194; i=matttbe@kernel.org; h=from:subject:message-id; bh=/G9M7hFeReWrFECsxUjtUr0Cr4ovpysIvD7RDt8ltYg=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0wN4sgLXNTgt9A3o/PhV8Vjqa9agRU+2eL2cKaPl/ Wnewf7fHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABP57sLI0PF+Af9JtjlBHefz hZfHv/CXF8x9pfJtRaVL+kllG9mTExgZjj1/zftIv3S3nKt8eUJGUPGHGy1K1+fmsK+6W/h0+VJ rJgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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() =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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: =3D=3D=3D connections so far : MPTCP sockets of the server in the state C= LOSE: 200000:722, [...] RESULT [...] | left 300 s behind the end: slab_MPTCP=3D722 sockets_MPTCP= =3D722 [...] [...] | veth_end_left=3D1 slab_net_namespace_left=3D2 | [...] Fixes: bc68b0efa1bf ("mptcp: move the whole rx path under msk socket lock p= rotection") Signed-off-by: Chris Mason [ Shorter comment. Commit message: how the issue was found, and its symptoms. ] Signed-off-by: Matthieu Baerts (NGI0) --- 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, struc= t list_head *skbs, u32 *delt } =20 __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; } =20 static bool mptcp_can_spool_backlog(struct sock *sk, struct list_head *skb= s) --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254149; b=GyA30sPr+/XlWWtX0JdR4xEw8JcOPYKQgsiD+WE6F8pVLjJ63xfGLfidCbB5A4/KueS4 F8sqWO1WcF19zdMynvpX8xUogbh1Ko1IN8yQFsektXonH4DfIjLet48NTKKWwDcff8Qt4 9SH5ExjqZwqRKif+XDJfzVga2ra7ShicI+8AKbQ80qTOcsg8CxIfOTc1sM07au3SXCrlT 3IKNGOzbgKSKMLN26nw9R0/5eylvGlGlIbE1e26Wu68ggoXGZd+kYNCTyhg0ctN120Bxm 2qkmxr5jPAV7Lst7mmvQ5ME27uyiQ3kfskimVUBsBo3TBoTqk4ilAaasF8RjhUpIBvA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254149; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=aDdQtZguyY/2cZoXgdqkFPYNOi0VWM3eNkRFzvdZ5tQ=; b=WBw73RSIbanZtqzVyvHl5gFUaOAM12abZ3cjSAyGvRwaekfa7RFuJqwHnbHjePVT2bI3 /vHZulIJAXZSjJhqIemBKI4CWBu0aM8MW5aKnlumRcXRLf14BPj9OWzt906/oMGt4OhS/ SgEWVJIfVlKepXivbN8k0M1M/xNGQjZh+8+khWhTNvGKS4SntXPzlciT9uWEtGV7ijhrb uRWUwkQ87Dt/erMQ3OufOHPf5Ad2rXKD3+Pinamewnz7q4Ij816qcClTJtIaIMWYT62WD eXXSv8pgYcksu22Ql2mAnvO7J4+Fdmoxpr19fGgk7BHFNWZu4tv1nCEvWshsJWxu2Tw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CjyP+JWq; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B32AA606A320 for ; Sat, 21 Nov 2026 09:42:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CjyP+JWq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AFFB1F000C0; Sat, 21 Nov 2026 09:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254149; bh=aDdQtZguyY/2cZoXgdqkFPYNOi0VWM3eNkRFzvdZ5tQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=CjyP+JWqMRbAFUO5YWyn10FpzIYlO9BKAzXueeOfvuJvEcWkJb+n3AeKyyqQkDwJ4 cKVK+hRylfmAYXKwVUTTo3tpRJodluZ+sdPt1mzqBpt9SubBZuoznHGDwpkMEDFwwu NoJtkCxnl0MEPq74XPwD22hymyo4z/CwJMnpckm5+qH4QJ9w6DTfhpRZzcXaVeKEF2 XTDdeP62yNKPEOoXrTeJFWpjKb/Rjgo6ktYu70V1rwsbnnFSfsg9lU+kh4AgdqMpZG YewGG70RampUjwap1mErRnppP/hE5vt0dWQFJdxq3VOo/gUSD72HYIXKs4l5kgfnsn xih1H6FgMMUfQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:09 +0100 Subject: [PATCH mptcp-net v2 11/62] mptcp: don't leak an orphan when the PM closes its last subflow X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-11-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3150; i=matttbe@kernel.org; h=from:subject:message-id; bh=GjPt2W6y/Y4VVZf45pUA/dmGKQTmmSGadM4E00uKWgQ=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0wOk2hn3qYmafshdFCEwKbx/R997izNlU+acubFAZ vvZ9qzgjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgInIhjEyPPV4V1/5/KbFZktx P04/AbfebVzOn2autqybWfdEPmaJJiND68szetsE/81+fdhKeMUXJ5MPapOs2Cf+3fqiqFIsdrc vEwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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, struc= t sock *ssk, */ if (list_is_singular(&msk->conn_list) && msk->first && inet_sk_state_load(msk->first) =3D=3D TCP_CLOSE) { - if (sk->sk_state !=3D 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 !=3D TCP_ESTABLISHED || + msk->in_accept_queue) { mptcp_set_state(sk, TCP_CLOSE); mptcp_close_wake_up(sk); } else { --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254150; b=dODjeazUD2+5XeVJS+euIupM51eS7vW1OCThKLJmPC63vJmbSSrJgQMxtWKeYw/xOLMs yAbRPbM06B5zmb9/MulXFfJx4xJ21WQ4QETy+2FF3MwjYG6tZIEL3attI7R8ehieLR58M criOXlAOAxX9Z0uMwYbL5TWQZIp20C3UQQ/dc26mOkK1h5bZxSXYA2ANhbvIpDhNdRtfw 7DjIoguWU7oEm5+i8k3igsbUYnBWfIFTg7l2+jVEc4vdUziyzVGPgFA8tPAvlcefF1N9M 9/W9pHM+lYePl2PjGiJVWzZy5HGtrttkJ+Bclb4OfPIWIVMVvdv4svHSSEaiwF0xbMA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254150; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=2BPMEhKgZ3yHSrY6kt8NU0qc5xzjd/ULSg6WTSbivek=; b=B/zx3LMnpd/eYEzQXLDW4XF1BqtMcnStcV+gGebQkNVL8jJ9NI4mhFzzoBfCE1q8SQTc rVjDD4iGk+P9aeTNX1tFch/DottQOuXWxqkh4Xd4ZzwI4Zi9bVGe+JALaGRq9FyIPbAmJ JPNkAZAN5euY3IBBup2YYOT6+rcYQbzIxSUAkOW/OvR2Bt3edweXwplPMKcwHYcBMuvxA HI9Ne6cNznEFZKIH1uO0EQWgqPO8buOzw9+ohfPgZYm3HENJketsQguvnza7K8eJpr2p+ Cb636gd2gltFS3ZFwXR/pNYL9fIxiSt5wVeinHP3v1YvlMslCLXM+U7yz0VcjRt1pPg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=StWm1MwU; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 874BC606A320 for ; Sat, 21 Nov 2026 09:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=StWm1MwU Received: by smtp.kernel.org (Postfix) with ESMTPSA id F12B11F000C6; Sat, 21 Nov 2026 09:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254150; bh=2BPMEhKgZ3yHSrY6kt8NU0qc5xzjd/ULSg6WTSbivek=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=StWm1MwUxgF4P8lgHi2NVXkyt3hQfBpjaiEr1U93NuddNqW6v+NFBw0bWiYheQMHo /q4qFhL/1Hv4iGiWOaW8mCV/U7t3ufWgqEOSpATtNXdiSbHNl6AQ0yPu5znV9XXO4n YwGl9jf1RT4+GKqHSjLbBpLc/TSHkzyPsIimHNNSp63PQO9G8rQmnliiVuq6VJlBre NzNtJq8JxhVxubshpR8PnfPG/xg4xs3MYroaGqSPvbVINJZvCQW4L+qUo+EIuBH+vE O/pJofrLExn19HV1a4wFijqDhz1h0ChE3cyMsl+rsux5A2pRO7SdebCFN406hnPeW4 1fma8L8oDoHQg== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:10 +0100 Subject: [PATCH mptcp-net v2 12/62] mptcp: keep an orphan while it can send its data X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-12-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3553; i=matttbe@kernel.org; h=from:subject:message-id; bh=mxA7RXLnyGFxvO9Z1BIjBfGKjNv05o1qeL21uzhz2ho=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0wN5f9/KmtfYV1Cf+sBH1nPr0afy4qkh6WVx/VLpt XeKXl7tKGVhEONikBVTZJFui8yf+byKt8TLzwJmDisTyBAGLk4BmEj0G4b/OZEXw6v3FGQy6bhs ErL49lLz7Jw0F12ngz6q8/6s2bhxFiPDp4yJ5vptRvUpZ97vby2vi/t1cIFQyqkr85x8Gj9OPer LAQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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 so= ck *sk) inet_csk(sk)->icsk_mtup.probe_timestamp + mptcp_close_timeout(sk)); } =20 +/* 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 =3D mptcp_sk(sk); + struct mptcp_subflow_context *subflow; + + if (!sock_flag(sk, SOCK_DEAD) || msk->snd_nxt =3D=3D msk->write_seq) + return false; + + mptcp_for_each_subflow(msk, subflow) { + struct sock *ssk =3D 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); =20 + 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; =20 @@ -3449,6 +3476,10 @@ static void mptcp_check_send_data_fin(struct sock *s= k) =20 WRITE_ONCE(msk->snd_nxt, msk->write_seq); =20 + /* 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 =3D mptcp_subflow_tcp_sock(subflow); =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254151; b=YfnYiZJ3F3QQ6FTK1cXDpOtduROgnX3KrfrzaRVjhT43lJeJ3S8Wqx5k2r/N8uBlgnSJ ML/ET8mBdyn/hY6r73oYNBpRY7KTY16qvePNTo/QvlEJhMHnNnde9hewaCYA3/5kDLjNi mbMImPiOh0VVskzD0bilR4yYqeTDG+9n9xjYZ8dSEcrCoD8FPAn/8M7OSaA73GDuvTi4I uf+4Wn2rKmnyHAtiLemrJB0iv/PiQWpIWj7zywYvyN1RpkvfDJuuxcRESdCAbVxeaehz7 7mzMc/SThSuE+5K6vHsWJuTs/XyonnR95cw46PRhOXgIEZrZre1TX97D5R/A9d2KE8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254151; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=EuaRc1ypLRY0OsqMixol/2IwWa91F3qluP81xjD7qzo=; b=gpv1GPNg1D6o0HRBrYiHdlrF4UxJ+UqfyDpB01rudfKrjvGLvsTdaB4LYvPGs1zUHI9j aiwI9gHt8RsaEG8L/iczPyYkY6CxrPIP2tUB6h50SvQOGCWaGzEJqRs2hLnAknZXR+pmH jT11Xxe+2rgs7RaDz/IwztXrbPEhmxAXAD44NpOF7MPdS/cjbZY2QZTEkv8QdY+1d1qd9 XjFVEXhODXt5pwtTrpepD8Afut7Lc+LUKJypn7pLaNcilSn6otYV4SpfbGZXMF7aFeAwQ tTyIbLn3ED0tV8sfbVH9v8eyQi9Eiok6nlBaEFQq1vgCsLKURt+Tval8/8DXcWKY//g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jISkaxIS; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93EF4606A320 for ; Sat, 21 Nov 2026 09:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jISkaxIS Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4F0A1F000C6; Sat, 21 Nov 2026 09:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254151; bh=EuaRc1ypLRY0OsqMixol/2IwWa91F3qluP81xjD7qzo=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=jISkaxISGsapRMLeXu2YwRKIubgW6PpyUE6Q+9NmhAYYx03rbFIlZ48OfdVFfbk5I Frv7/OhYJ7M0zwuyhDvIwhdvwpMufR1wlvdV9o76DZpyncO+a9csqxGqncwLJeVuML CGqgattHA4Pg4unINxlNjYNcSFsui0f3mlA2v1tnLd2IVl1o4+PElJB3KMjWsZD2Kf cBdk88GuJUU5zKRNo+qTU97cGmq8MJjfoDBO6Q3Fv//xa4WdsKCL+Nui+/Wi6JAkV2 WWAW+udqrBC/IfqhcBsZ1tk9uGO4118LyvhVKHLZABUvtipstMNPCwkuzAe+5FASx1 KvOp+yPQeB6iw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:11 +0100 Subject: [PATCH mptcp-net v2 13/62] mptcp: limit an orphan probing a zero window X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-13-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3223; i=matttbe@kernel.org; h=from:subject:message-id; bh=+/1gYyOmkXyss94GMp5AKiZxjk1halm7uRap7J6BSfs=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ04Mm25+OsbGWjnqUacawec2TeQctNeMFlS/HCKt+u hj++xpPRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwESYrzAyHI2fopYfMkdvh7UI r5bbIjvv2UJef7m9g5by8hqH7W9lZ2T4eeSv14ngieJ3pjAYFTf/ev+z/tnzXRqnSy/U594MTZn MDQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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 so= ck *sk) inet_csk(sk)->icsk_mtup.probe_timestamp + mptcp_close_timeout(sk)); } =20 +/* 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 =3D READ_ONCE(sock_net(ssk)->ipv4.sysctl_tcp_retries2); + struct inet_connection_sock *icsk =3D inet_csk(ssk); + const struct tcp_sock *tp =3D tcp_sk(ssk); + unsigned long limit; + bool slow, ret; + u64 when; + + slow =3D lock_sock_fast_nested(ssk); + limit =3D tcp_rto_max(ssk); + if (tp->packets_out) { + ret =3D !tp->snd_wnd && icsk->icsk_rto >=3D limit; + } else { + if (icsk->icsk_backoff < retries2) + limit *=3D 2; + /* a shift of 32 already exceeds the limit */ + when =3D (u64)icsk->icsk_rto << min_t(u8, icsk->icsk_backoff, 32); + ret =3D tcp_send_head(ssk) && when >=3D 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; } =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254152; b=a4FhNcJYzS6X7oUx3H+6Qhmj3Lh0te24pKjrf0hiMgQhQqjkimPDgnXbq4N+Ggcs3/Hf ZvKHLPXmsqSjMOWvv7tCyvOJyFioY/4p607pvdqaA4+NXnLvLbd3exK9TzpCRKG/Yt2d7 NYTDYBNGmuL6XjRDBbB47gIHW+pEepAvafFZHsckN+MI32YWEFPagyxAP0lvOVDZ3pmfU pmLzMJXGLDzhyqCjvaQzJ0iEjGCVqUf5qabT5tLxSclVMJXBvN7QTgtwPAaD4w1vqqK8b sI9drdN5biRSrkwXoC4inbGFm+L/Hc4EkXhc1VkFFBnZV1F8SNC6CAtMJirYastJWFg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254152; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=IIbOwuj4rGHM/BR2Frdp6Gimzs8ld81cK+L5nHKoPYo=; b=xSVY52Y9e8qqS2oESQRADwtnuNryxBJGiBPr0UtmXbY+0zoB8Uotw6N6KTInO+arHYib Eyq5BvrgT2LeopcDAKgOG7FVHPfHsodBi+roOiSJ068FCdBvXFDd9FUsRveWp1xuUIuOd WFi9KqkbFY5PHCl/lYl1PslB45ZTIEHDl4YVhsgjTeKpnZwXEAXsnxzDH+bbKu8nZlMWc qVqh7+CUR8CnHDI5sc9cjNZqRNWzaDjGx2Gpxos0pdztJw4Y/Eq0DSA7i+qZhhQ124p23 M4+0/oXbo0U+uVs9UEbOFvAXqQ1J8ydKziJMjE7fzNRnzUt9QRqFYTgkThELwjdzDig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HhdPmhtf; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CB15606A320 for ; Sat, 21 Nov 2026 09:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HhdPmhtf Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97E481F000C0; Sat, 21 Nov 2026 09:42:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254152; bh=IIbOwuj4rGHM/BR2Frdp6Gimzs8ld81cK+L5nHKoPYo=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=HhdPmhtf7TDcQlmv34fdhtQelwQBe7ukIreUzmeOVlwemieqjFUGjvB8PTxHNrjaW 21a/kipZvbfmRxpqBQrLDLqH/U+3FCBJlLEZArMmg7mZnnetIyJ3tgaHLbaH3jjKP8 w3mQYS9Bh6E1m1lBxuY9QkJ97jiiY90/META0LUspr044Wfw6x7ppLfAV5AgCfLvNz r31OjSNbd5VRhX0TgrDReVYoz0Sy1IZ/ByEtSS2H2N4cjwd5i5ZbuJVCsQEoMIHh9x C9VGW3YART3jnxvvzfq0j1pb/Vq+MEN+sqZmnya3+zNYyXBfpDbrCU9rmP00aJaalA XWwdNYavOV+RQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:12 +0100 Subject: [PATCH mptcp-net v2 14/62] mptcp: count orphans as TCP does X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-14-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3718; i=matttbe@kernel.org; h=from:subject:message-id; bh=emBLFU0vg8Th4Mld5vY6uJhcastLs9bUZKaFOurrIVU=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ04Nn751bOOslx+zf825f39VdysW64Lzgson8Nuf99 or9/aVb2lHKwiDGxSArpsgi3RaZP/N5FW+Jl58FzBxWJpAhDFycAjCRHU8YGc6czZKsi3Y6ttBu 8u5bH36dFFAsXiTTrWudfea/5jQ7/oWMDJ+98queiCWEmqaKh5vfvrBQaR33/ufdt5W7eu+bmOc e4QMA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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 soc= k *ssk) return ret; } =20 +/* 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); } =20 return false; @@ -3547,6 +3557,9 @@ static void __mptcp_destroy_sock(struct sock *sk) sk_stream_kill_queues(sk); xfrm_sk_free_policy(sk); =20 + if (test_and_clear_bit(MPTCP_ORPHAN_COUNTED, &msk->flags)) + tcp_orphan_count_dec(); + sock_put(sk); } =20 @@ -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 =3D=3D 0) + if (subflows_alive =3D=3D 0) { mptcp_set_state(sk, TCP_CLOSE); + } else if (sk->sk_state !=3D 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); + } =20 sock_hold(sk); pr_debug("msk=3D%p state=3D%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 =20 /* MPTCP socket release cb flags */ #define MPTCP_PUSH_PENDING 1 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254153; b=SDt223aZiSj5TvUz9j6lefFjdXTrR/Xez7C8Ez3U8697fTX2hVvtKjmUHqW6F+6AK2F+ bZjVYsBWV1xg3XcafywtiidVFvIGPpxCJ/wTlSpTXHsBU+sBOdnX8CJX61R4swlDjamz2 ALABYVB9XPv70OnlUMrfbFZQvOhTqWZLXSD0jZO9Qk4SLMJnFSKi9OsQRW37DeT/voSd/ 8EytEngTtLc542Dc9eiLqp6m7IihgZPg/h5mjF/Ulf1T5NGNZctBMLiuDWcm7YXw1IdR1 2wee/lqillIQDXNGkX0Wa6Fb0KptMW3Gmb5NnSQU61PtrkvJhufUslOHAi8Dd2MYNSg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254153; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=hTltZsKX2+e0IUaapsSlYtetlx2KXbWXf1TiCgLo29A=; b=FmAedNmsN3EHBuA5b9PQb6vJJVYZYVx6E/gWobhqrTSs+6JeHsR74eMD7L/qPuuvoalE bj0sYW1W+Keiyqxdd4b6x8TEvdIsTCRq4lq8w1xRQsHHh86hqOxiuFEyim7LmNCCyrbP1 VRKZFiU+EedTJvfykHpYFlap8T8rK8U63F+AYX5j+7aesyp86Q8zn8veuksit1Zcm9cE4 kizjT63dwWobVoI8F5V/+OyAUVx5XXKxfP6mljp83Ci3l9UPAlpZfaVTkUcbNK1pJOWRa 7GgWb0AztNr3T8W4soCsBK1AK1RcAzrENW+DDNjFH3BZhAfVllsj7isp2GRflEhd3XQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fGENgk7t; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 315CF606A320 for ; Sat, 21 Nov 2026 09:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fGENgk7t Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A7BF1F000E6; Sat, 21 Nov 2026 09:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254152; bh=hTltZsKX2+e0IUaapsSlYtetlx2KXbWXf1TiCgLo29A=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=fGENgk7txBtY5P8/NJps/v7OtxU36DHBkzRbn1di8mddWCc94X+/O5givHpiDZYBa 0RRF6HATtB1196vxWWOr8g0z1uX2TWYf3+wGCc2Hdvesnnb5x8i/PE83lpa/2ge6zX vqU9yyJvUrGDcOFU1T7aOM52ruxvbUGFBCsI6jHhrTPUiEcNUufMaIQfSaidTF6h8c kNWNxu8EG3Odcg8x2VMo09U/YGLuCR2tG3ETBMajY9zQE0tf3ssCmAKqVbhxx9u9vy 51+gdGacpA9sVYypgzzXne1amfUn0Osw0UVrKWkrnEBDRY6oauz10adQ/pjkEocUk2 nTFUx4Ua+M1nA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:13 +0100 Subject: [PATCH mptcp-net v2 15/62] mptcp: return EOF after a DATA_FIN, as TCP does X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-15-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3751; i=matttbe@kernel.org; h=from:subject:message-id; bh=OUhjCzgEfBwLroFI8sb8y0ubGvrKccVVHb0XMQQTs0U=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ04PNL/9/ZZ8WXGR09OtRZUbrUoX92ZzL2V61Jz2wD 3weVbW3o5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCLHVBgZOqYs+zHpfOEmzXtB qRMu3lJlOdZ6c/420wx/jULR9lN7YxkZFux2PpHZvofze7Vrqcn7o/Xq7e/OL1/34OmECx7LFv5 SZgUA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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: Expe= cted result 0 but got -1 with errno 32 (Broken pipe) v1_connect_tcpfallback_fin_reset.pkt:19: runtime error in read call: Expe= cted 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) --- 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); =20 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 */ =20 switch (sk->sk_state) { @@ -972,6 +976,9 @@ static bool __mptcp_subflow_error_report(struct sock *s= k, struct sock *ssk) * destroy the msk as needed. */ ssk_state =3D 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 =3D=3D 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 msgh= dr *msg, size_t len, !timeo) break; } else { + if (sock_flag(sk, SOCK_DONE)) + break; + copied =3D 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; =20 + /* 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); =20 mptcp_for_each_subflow_safe(msk, subflow, tmp) { @@ -3797,6 +3812,7 @@ static int mptcp_disconnect(struct sock *sk, int flag= s) atomic64_set(&msk->rcv_wnd_sent, 0); =20 WRITE_ONCE(sk->sk_shutdown, 0); + sock_reset_flag(sk, SOCK_DONE); sk_error_report(sk); return 0; } --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254153; b=K1vJrpMEu/lDib/p95uHcVYJEoVv0T4+FFvg8Q0Zglz5+S9HYZUhgqyOK++hU/OboxMP x4UrbfamVk2NXeBqghrE2YwrPtu8cHm7Xe0vvYA/iUcACnAnm1so8wORbOEseP+Sknl2/ HMNgo5fq00FZ18BWiNzlEENArLMntJbf8rdQ1MBczeg+N6Th0jJ+yIgdrCjJjMb01cxQi AQfYHV+he+z6LsNmvQ/mZRjRrt7u5c9FUNA4Iwae71BAqJwtJ4VYUsWx2bWyfqGVo4POQ 6ffXkFCn/8NzFFzCHRtemE58R3phvt67ZXht/QNql+7s7EBaAR/cS0oAFTSEEuFihpw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254153; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=g0TKJq6BW5yBDG2MyIB41N0o0cp95XArJtuOPCPLSps=; b=aiaB+6HV66cxgILD99vsYY9Z6jfm0aKY2Y1mxfyOJ8mFN6RZfB0m+rAC/tEkjckjeboZ wkrPohbu+JL8QUJGxb5KArPPr2afzpGWeOLHBzAmojvv8fkPeovYAW8kTcVK4HmTaV7th MZNG/s1OvzXbKoAqhx1cWneXitX9ftnTTPmb4yFBob/YJdw6BQmAzVR/DDxm7f24CZ/DG iHkeMeuL7HN4uT7OSF/PEAEzXzYKwycU+soti5rO/UaYRZ15dnBjjsfzSGKq2wUQiG57p GRtnsp4Cx+It+SNoHnmWIx8ZmVjSDy8mprVRS87Uos9lmi0o1T8UtMexW9FuhWc+vSQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=J6i1mOsV; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6C36606A320 for ; Sat, 21 Nov 2026 09:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=J6i1mOsV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E01D1F000CA; Sat, 21 Nov 2026 09:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254153; bh=g0TKJq6BW5yBDG2MyIB41N0o0cp95XArJtuOPCPLSps=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=J6i1mOsVyZSulgpCKSOUnhc+/9q9Hj2BDxFgkK22pDYAqv/i7c4+sU3lmQI2kBMES vl/wRTW5+oLY4xRObMdrD6lSi3m5BTl13JU++sHrbVxlKjwjHzHMwH5AD9jmooEfkD i3DV8sRdlQ/AgPALy1cUsn94ddW3BUL/Z66TBu7hkBdpPC/ePIyzkc7TtL4NpjVnOT Bd4mE9DEdhE3mpXYqmeOGUqJfZ0E0O+z6XmGXFmyFy03/8j1SGxwkpeojIVV5sb4eh kPHS5U+VtP7s93OhkEdrLscP6g2xp0yDy2oqyLHEfXVCo3T5+aJ+QoACJXgE9D/1sG GnmfTSOCMJenQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:14 +0100 Subject: [PATCH mptcp-net v2 16/62] mptcp: let TCP send orphan data after fallback X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-16-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2506; i=matttbe@kernel.org; h=from:subject:message-id; bh=Zd3W32f/HsMaH3x20KWRZPNpAaYlazEDcUgjI6lBvFg=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ00PyDgn61k701uQoNQsN+1f8ZAGTz6ZJnC8yeI8y7 dlT//JeRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwESYuBgZ3hrws9tcjJu/c59k KpfGJtcUpqvr3r9TztnbOf1HU4igISPDo5TFf/evT/J0qXthXNIaP/3QzA8rk89E7fcvYZrIsfs MJwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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; } =20 +/* 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 =3D mptcp_sk(sk); + + return sock_flag(sk, SOCK_DEAD) && __mptcp_check_fallback(msk) && + msk->snd_nxt =3D=3D 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); } =20 + /* 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; =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254154; b=KiKG+uuD0+8EJJ71adHG8n+MUX3Xl34Sf2/uFdI5AcM01oZzORbZExpRRBTlmNhBAsPL rs0jVpybz5lZICH6J8dXYcNFSueZcnlDttuT3JDtSnAgZGg0TDrtJtQYbBWqzmPmAk7Wy Yq/sZToW9Up4AP93FDTUqzVdD7k7nwuj7AoIdAZQIE8BkRnO63Bo54z1p6mquaEq2hImE CgzP9hFmqQ1OuLzTKuDN0GCt0uW5Yo26rpTgGY0v+eSxcr+WEqZxO8IEJoz9L1QunFdDl ekCCt4PJi+Gh5IT5ffnqGCZNxCT1+z+0cvUzLiaAUYB9DI8+tdp6TNp1XUuvmAAO9vA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254154; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=6qXs6K/0c2om8ks3+LZuoCm1mZz32FbP1xscDNAlqZ0=; b=K7OR0XRXpqJfVAZt9Iq9qPnuPaU/1o0uM12+ZQX/QMDg1F3AUvlILN5yMt7+vi7cXMCW mR4loKLVxdLeuIBkGkkJqhQ6CxD6qZNA4qMn6EwU5sVOcvQbyg6pHfWVgX/3GPqVh1Cfh /PEySm0ZBZeLSo0d1ULynvSZkpkgH5lwxhQhLtj/H5M5J/Wr0otLFm1vcPm6cer34Mgb3 KWeehGc1cTNhMq62DL2IeUUEmZyCNPUQXriSWgS8D8v1LiPjDxTbs21D8bcJy8j/ZaGHl 4jPY1mTGMEw3YfwDfnOT/Mz6KQCE/whe2aGnOwU5NgC5SBDokTu/8Xx6noavNX37OuQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CzQk7kHd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2D58606A320 for ; Sat, 21 Nov 2026 09:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CzQk7kHd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 105111F000C6; Sat, 21 Nov 2026 09:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254154; bh=6qXs6K/0c2om8ks3+LZuoCm1mZz32FbP1xscDNAlqZ0=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=CzQk7kHdnfLcKJ0MPv3bnRXMc/0LJywVvsKhzQYg3Iv5JExKvi7Tw54C+TSI30R92 kCewEZ+sLL46xgGsPXnAjVHeZ3zZidZCjagVbKXqWl1zzG6HTFwEIzx34dWPZfKClI ywd9xfZpZXXvYlKHA9FZ0IQhonNm64mnE0RMHx7OZEIg1sXKLvjpFapm6HDZ/mdlUb sE9kEMsRyB9Brsgf2OxRlOPcmZIoDJV/3fmm5rM24z+ewzG8V2DTFQ3LchPZI7fqjn 6yCwGteEA/2AF0TOhdVdgEsVVfNidYqn8Eo/LWueH0AqGVeiVKffQ2xltQBCTDwbRx 7chrv9GeJQjJQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:15 +0100 Subject: [PATCH mptcp-net v2 17/62] mptcp: reset the subflow on abort after fallback X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-17-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1990; i=matttbe@kernel.org; h=from:subject:message-id; bh=uwaAtsk/k6ZJsP6boV94Mf2V+eEhVKCU4Dlfa1D+rv4=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ00OTGfatXH1+l4Gk5Lff88OXX1C8sj8yRmTC/c6Li bceFdoLdJSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAEwkNJyR4XLtM/9/2su7tYuM pSYKiZW+WZyQ9P+u0NqWnoMpVruupzD8LxBiXeG2x/JwYFjLju2HWWSe9szxKIhi8knguBB8jUu CAwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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: l= ive 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) --- 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 =3D 1; =20 - /* 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 =3D mptcp_subflow_tcp_sock(subflow); =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254155; b=iGiCUW0lXlMeNW9+d7rHwBEAcVvaaNl3BLnK+V+LYO062NvTFKHqk4EsuPM56V8euSOn w/DFUtM2YonS7RgfKvepN49o72nxmkNpQXx3j8wHpW22KBhrkXUjvs0l316G1g+s2TLeD 5/9gJuzvHOJq4PgbwkfTYfhF68YOozFvkU1aYVWeFx3YxqIW+7QtztEMzCrNQ1X0637Qm uVxATINaUebm8igRntRRctMOX7SAiHW/SI0zyPLFFR2RuN76oswP+Gyb4J01GBaS6jmSS vCMrog0fYBXjsU1KnpIdLTOtunx3Ib+rj584EIZzF6z3sLR7pTiCRIMKNkVOpN4TJqA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254155; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=dtUNF7R/JZvAJATR0vh3jjl5HRWPOWIAHa7/Y+xlL+I=; b=j4cffRsJtnkwcovhS8RAkRDcoV+91NoPe2oq4qrfhEJMEEmQdboNTn4jiUwBKzWxg9vI AM2UXL6+/o4/75AvgWgHEoPAglskKBIbZx8tVBt31Ut7+CElrsk1tT3MBkbx5Npv7DanJ AxPayZHMcYBby2c9bpngQuWk6d0RKlma/OwvK5xBk2OkCOWhTjluLQ36e11CdHQZ4JHDf 14Zq/90Iy/N32CIu7GJr3o8GkyI4C9EjIY60KhWBxxHg55IwVAlvNbtI4h2zDuYQ3TaRs 3YVkklLONN0SYtKD1EUlfWAyg6NI6tnFOUXT6NEJKBjzSdpV1ylEXDzOLCjnmSZo8Xw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OypNrYrH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B03C606A320 for ; Sat, 21 Nov 2026 09:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OypNrYrH Received: by smtp.kernel.org (Postfix) with ESMTPSA id D65E41F000C4; Sat, 21 Nov 2026 09:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254155; bh=dtUNF7R/JZvAJATR0vh3jjl5HRWPOWIAHa7/Y+xlL+I=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=OypNrYrHczZVrmfjkKJYJchn8Qp8ulfU95VJrnPRku48Fd0KrkiKRV7ZBAkKMpqCs 3VC4i9UrUxP2J60yTdbXM8Z2b2AwguR9Rns6GPPOEmzlHYS6pjIbOaVi1U8VcvcPE5 U+ei+IUXUBAkTciyhyNFCMJgLd2Z7u4aFeoSzB6SVQYhfYv5zLr4H1ze8FVagiSoSy G1dM5K5oxM1Otygte7626Wl/LiuOGHjhipSqV6PvKvI61eENK7nh0bD59/tREE4nn5 rWqAKk1nKc+8opIlrp3BRrf4fFPEPg3ittJzvZdvZbvwOv1y5AChhYiTW9Xp61AKWC 1DurvjuPnZP0Q== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:16 +0100 Subject: [PATCH mptcp-net v2 18/62] mptcp: wake up blocked senders when no sf left X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-18-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2404; i=matttbe@kernel.org; h=from:subject:message-id; bh=3bqr5cktdwQRnklbcG7PaFogLt5S2kbO83/lAGFS9As=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ08OqE6bNqJi99uXqsKrQyKZZYt2NLx6cOqvKrpfZO DsndEZ8RykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwER2ljH8j6lcynTmQUxlrMOz heejquY3zNSZ+8hiR/hinblCfeufsDH8d2K/I/Z/+WLjmAjOBt8rC/+dfGnfx8R2P3HNqyKhg3/ YuQE= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 blockin= g system call is in progress close_wait_reset_blocked_send.pkt:25: runtime error: exiting while a bloc= king 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) --- 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 !=3D 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); } =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254156; b=rAvlKCBjRgZmvw1J/L7gA0BOVhcxACav0v3Mu3q9eeDdsZoVo5tliK7TqVMc4iX+zIFq Q5iY+GeR0Yxbh8gqIkRnI4ck8HbOxZC0maR0V5Cb8/6KHxWM+ObNCuOVBabLsYeg9FyAX h5SF9TOiLTYjUIBnJK9yAJ9X0aOKdaW2+8OuySLOueM+fU/Mn0+85RC1A/x/HVHAbIhHc xTac93kxYMeIisyQJxIGWsLcubRzBMoVZC6yFXzprwr3Nal/LUjqeWv8LZ3UNA9OuoHAM /cUAwJPUKPnFK77PhKm8ZeQ5l7+yoHXmkrb/ne8lXxp1/dUyiq7yP1ED0r4kMyblSVA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254156; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=snoG3KnRJLf5qvvPhvv06/c+TQwurTrWKBhvomICLfI=; b=ZI9XI5oNz/DnzjXGTCxDxWJX4ayEWi6ed2hOgGb5FJTamxwdWjvAfv0IhCAs3INYRhRh w3ud2atZsMC40Sl4iFY6ZNjYMaPKYDG8fmyLU0a+8Fcc4VAb5unF9C51cJhuy11rWfG8H d4UAXBh51bN6/QyjvB2HnGOFBWTBZs5WyRy93PRcqNZzxtA97gMuZGM+zcXW0jt3k636c AYifyuHAM20x1Dlv4fPEK9XXpp3smx5k5w5V/c7SWbrA4mda+NpEodTgYqiezhyviSG6j NtS7H+GhwCOGiqRdmT7xeWyxOgLl0xF2xavHbGvCdxsEEaql1ey2s1G+lwhCFz4TB0w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Oh2mvy+O; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 753CD606A320 for ; Sat, 21 Nov 2026 09:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Oh2mvy+O Received: by smtp.kernel.org (Postfix) with ESMTPSA id A84DB1F000C6; Sat, 21 Nov 2026 09:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254156; bh=snoG3KnRJLf5qvvPhvv06/c+TQwurTrWKBhvomICLfI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Oh2mvy+OD4vz66Kai1x5SZOP3OykjNivn4swoa3UCohz+xNWzbze9QN6CJbYNQz3V gjT4JADv96RArfs+2auneGw2jbQLRkDe7ywQng1b7yv9e39fIpYdA8/IzG6dQ+uzMM 2MK7BYURDCpTo+XdqmHeyboikHkzjEKWM1Ryh3D8F2mqYZB41+GYoIkTlsr6eiPDbG Yomt2VN29OPeNp4yC75qsMqdoWw8+PGvjipjpejWwgI+YYXtTZwSS+aMJb6/bBjYJs wQ3TNYy9CVToMPhvJJukMt+duomrESGX2ToJX5Ov/GykM2EyPZY1NhzcSTxte3Zn3r WfwYDaytirUtQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:17 +0100 Subject: [PATCH mptcp-net v2 19/62] mptcp: set SEND_SHUTDOWN on close by an sf error X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-19-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2101; i=matttbe@kernel.org; h=from:subject:message-id; bh=QwZcq8nED9ntzoh+9NXScrY0Nhk+R/dAfxZuPKIROAQ=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ08O4TK0co4JXnN9medE9/6Leyh/RG/ewrGeawlarb SEu9M2to5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCKz2Rn+Gf7iOLRng67ynYRZ F/YFN10Qfav9OHBzn1iAyaoYpsjfdYwMV6c872M6K3bYpOrBHmtJxoObeR7/Wav1oWrF7au1nh9 vsgIA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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 =3D=3D TCP_CLOSE && !sock_flag(sk, SOCK_DEAD)) - mptcp_set_state(sk, ssk_state); WRITE_ONCE(sk->sk_err, -err); + if (ssk_state =3D=3D 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 =3D true; propagated =3D true; =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254157; b=irDkRlmfCE89JZD4EWhRW7YfrW6s+1tad707JpA5DMgQA8Wn+HB9KB0fwrN4dugW620W r4R2enFjTSaXMRBxBclbPy+NnUT1dYzZYX6T6vqxt5I+y8SZjfC5OiofMqO+SE0mE4ntU uajSXc8DlayBWWLU1rNyy9ESE9btAkwxc/GDXf6TfVWY2R9clSE3rKDFD7iZyra5Z8vpa 97kE41l6sBXEi7jcJPnRj5T8ID+mhde/dNZm7BjLitdx2AfpAcMH/+1xOVZADhaC4IgzZ GBGmK4kZps5vUjvf+YsbG1D6GeH4TsH3zRsuYlyZ4SV6vEOOwiKwp9sB0zZrzSFJfbw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254157; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=J/3NH3snZpwpk6xMe7VoPuHIzeltTQrlc3xlx9g68M8=; b=fA6i+kUtFWRcw2qKn5hR/ne1MfOfq3W0YtGU0kdTtkeFLNj2tNWWoeuwWB8GyamrKSAw zG8LmjrQ1gBrrLGXrBObKosnofrsQPMLRNgzLRqwOgrMywuEEb1aMA5nIh39TbJvS312a uvBeuuFTUsBMB+KyEd5790/hCQ44gdEpjUcGowDQP+EAnkZ+jlYVLNHyfCEGO+71TcYN7 qevlVtBgmWhtW3qmpHZ0QnPnrStN/KVZipUuJB5WJHwsWm67RC84uT2/WvYhGr41z2WLT dJWDsY/s2IZQf/RQBpe++ESoiSnLOIy0xFedV/5Z3rO01PaMCpIQweb56k6s8zHrssg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aaYw6xhs; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E5E4606A320 for ; Sat, 21 Nov 2026 09:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aaYw6xhs Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A23C1F000C4; Sat, 21 Nov 2026 09:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254156; bh=J/3NH3snZpwpk6xMe7VoPuHIzeltTQrlc3xlx9g68M8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=aaYw6xhsU2+Un9GZuR2kh62DkDa2pQklbL399uOuFuqa/7ykbG/jVXYaqkNG8kzH9 tpOV9S9BfMSF9RzqBklj2NGvLy0Qrl8PxbVAidHpLXiWQ/eDfXXJuo1BGu1QSUXAAC Y5GcsqENFXZJRac35/oPevIwKv0QTmMMoU/dC+lKZ2M/m0bpNCVDMe/U01WJxdbBtf IeIEAUewJ8amqhomtZU2WilXHm2tsjIrFNXzcg7dSotYUsi0MiKjsRQ1UPLL7ysUS/ I1y3yoB1KO5DPhPmEm04AZZAH129cQAy4kYYLu3CN47eU2YQct3tZOod+20lJcZuQR 9LxSBOj6hg2Aw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:18 +0100 Subject: [PATCH mptcp-net v2 20/62] mptcp: start close timeout on initial sf shutdown X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-20-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2272; i=matttbe@kernel.org; h=from:subject:message-id; bh=H0N7IBphdSYQqEubQnXZHtnLBMZ0SLdiEKNyxI9Aiis=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ08N/a7j+K33guc/gPLe2c6eydKdz1PuiDmVNz8XCP /clJjp2lLIwiHExyIopski3RebPfF7FW+LlZwEzh5UJZAgDF6cATOTbP0aGBY+ENnS4iv3Rbf+m ntHdu3yOVpbHw0i55FUv9j39Y9THyfBXxE1QPZ33o/AmlUMCEflNYd/Fv60+4y/yLuz9QeWulzW MAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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, struc= t 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 !=3D 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); } } =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254158; b=NFDnZ0Itj6v21C7Orns0KRcvoibH1HXFtO62MvQXOqFOKLT0bxrG9suLScskljEmUmFK A3ZGHnuvpcYqVAYGHhGYwJ2jTss9FQvZKsK8Jp1363sdukIipStllWiylZ+XHlHwD5JZu tMQW43xUse1hHyG+eOkRImv3L33Gznye3iAKCB+c2FomZtaukxFk2AoYj73oXItCCERjP L8wWVxDLWhiLG33ArGWvjMQhXYlOBjLIJ8y9bMhR1A/pmU4syVBy6XasrgqPQ4FRqYQ/k OanLj73Ow2ZT5LdFybEXpxeJ2iM1xfmtFnnFvpGhG6ekrreSDPUB2L8SC4SIqkjMVsg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254158; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=MEbdcjjomg+4qLAt8AwpYGHvRdsNwybXR8Tvw5hhFE8=; b=fC5YGSs0GfjDWcKLKD1FII4MZvBhnX9hUmbmXQ/ntuTJlukuNw8GS69hUR+tdVE48r6v xUvrEeP+dTvVj95hdlQ6/EoizvpUklYf54OdXgg0b7nN4AFReBZQQ33DRjcavn9ISHzIf qsvE8TNY88GzDh1dODgoqD3zOxXPZFzhYkCRnCWZ08KTzh3jgoxb+N8/dm0kBougBDDiG F1nW5cOXdtkbaMUGJy6fgZYyUsO7xWk1sEPBl4hxHQpTkv44zVcTKnh6kV4V3Ke8FHHHt oTjpAyrhpVKbnVyuntrurz2HKjSec/ViXUlHHfzaA3n0lv0N8re1BnrO3Nt6qKeG6Kw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JlGiV0Gb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02B0C606A320 for ; Sat, 21 Nov 2026 09:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JlGiV0Gb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B8B11F000C4; Sat, 21 Nov 2026 09:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254157; bh=MEbdcjjomg+4qLAt8AwpYGHvRdsNwybXR8Tvw5hhFE8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=JlGiV0GbGpwE044T6y1Ow+urVraP3a5eDOcAayLT0whW6XxkQyoL61v4wz+vicfck OB5UojSxyOZuxrcAGmivb+fjB0+zLXldbe2m+3Ku3vEfMxdVhbzlbYseQLec5P875k yqh2MIj0SNP3REQQU2KAIkuo3RzQjFWX+iv2iouxpkv9USGGcthOcoGEJrXYTaSoqo PktcZfd7RO66MaFNocPHjpbqgrilZk2sRkiA1isxw6t3cwR/nS9AXgWiLHtjCsmIYP 9MdmsM950TlGq1FPTTgnc/Ia0YjYWIydaNKH72nqIu3gWIq5xFXaq0jLcMTzXZLTJ2 l/nnZUUPufjQQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:19 +0100 Subject: [PATCH mptcp-net v2 21/62] mptcp: process a DATA_FIN received with old data X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-21-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3770; i=matttbe@kernel.org; h=from:subject:message-id; bh=3A0z8CZt7qLjWDKGRv8CZTfNrzHK5eXN5+4lCLQd8tQ=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0yMmr6yLOHD12zw2mziFzI7WU3cCtm5d1K+otKV5/ udHDDLOHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABMpWs/wT/Pruj3tX9y31i0p WW0a86Tky5dwaZf+TfkqEuJdW04vu8TIcGqjQXzrgSjl942ZcxYKivbuWKuyS9px/bEEK5/r8W7 WrAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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:17234557033= 099169620 (...) 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 wa= iting for packet dss_fin_mid_old_mapping_server.pkt:22: error handling packet: Timed out w= aiting 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) --- 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 =3D mptcp_update_rcv_data_fin(msk, mpext->data_seq, mpext->dsn64); pr_debug("DATA_FIN with no payload seq=3D%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; } =20 - if (updated) - mptcp_schedule_work((struct sock *)msk); - return MAPPING_DATA_FIN; } =20 @@ -1242,7 +1243,9 @@ static enum mapping_status get_mapping_status(struct = sock *ssk, if (!mpext->dsn64) data_fin_seq &=3D GENMASK_ULL(31, 0); =20 - 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=3D%llu dsn64=3D%d\n", data_fin_seq, mpext->dsn64); =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254158; b=T778XOScFh1ai3XrszvBulkJq0RhrZoPhxWZhZKNIESZ3u293qAr93z8k++x020XoFST WNZFMO7dnz6hpzEW5oZY/H81+G9AnPxulHcPgvNnxcTyHpYRFhWgVZ0IoGodrGfcN36o+ YW5OUxSeuEiUrHrUBTbZJH9vpDfHnfjhiEZotIXcb+7KDjrB9HRPgcI2ZBe8bL1TDr601 C79tKoPy1lD61ETFk0hYwQC3+WnUJRa9BjDcSJeA6jCUYJ5pbXJyUYyraerdkI+1Etdbq cSlKa43fShySkMxq1r6Kp2VfxYq0PDqm7dLzLDbJf8NU+8LBpvGrQ+ZoTAsxjoyv+uQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254158; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=iCyOiyO3GX7stI6Af7iIjWz7YRxMhnfiAq1lpWIEsoA=; b=JeyJioQ9bFsV1Bo9HII7yCRUoFjBJ+v6OHj09zR3o5u+QcnFD0wpmxjD2QjpLYc77YNx 7edARzIS/iF1ZwRIEXACOqmuPE6KB2s5VJBv2Y4J2ptZ0Uudtug1N6nlzqH64iE2PT02c x2qcQcbuqUEouh9ebFLOfeBI+mPo42wIA8SJWmmkQdEgySmWQXppXbXk9Nv2EjN5k2Q+6 z45JApjmHZ4amxiyw6MKg3FpVwD1cyF9OHwoeJSIg+7k1y9WpoGCdUwraAI9Qd5A+ntld L9YCZVUZYn5wEj3TJuWWQHDu63gu2J0H+Neh3w8GEDF6yA0GYL3aCgsvkQIuzV0NWLA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VcnlpcEb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF1C2606A320 for ; Sat, 21 Nov 2026 09:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VcnlpcEb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E8631F000C0; Sat, 21 Nov 2026 09:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254158; bh=iCyOiyO3GX7stI6Af7iIjWz7YRxMhnfiAq1lpWIEsoA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=VcnlpcEb1oFBQsnK6zoR///zXgs3OF+NRdgM5j3NdVmMzV4E3fFBc9AjX/S2Pau3P uinofaD4zKuiWP64xvfcmagvbvusy1dWZis7YNCxAgTGSVQA1xP01Hijfp7aY5ZBt8 zS67S/ZU7QeezRr3Ave3/mf4OtvlTiX5MTqzHsxpNThXBr9ek9276WOE8biGfGpfXe 4Fq4CRPwXaHSfyf9kUAZFYN3jRjCwuj8dkBc8oNCrGPioO2xIy+fE3jcs68b1E0/cA dGJFdsMlW+n8levSxqq9fbnjlLknTbJmMc9CNQAufJqu/hpmG3rG6i6aAjiS+UBcuw 30iFAZCzJJY1g== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:20 +0100 Subject: [PATCH mptcp-net v2 22/62] mptcp: no sf left: process pending MP_FASTCLOSE X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-22-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2767; i=matttbe@kernel.org; h=from:subject:message-id; bh=tT+sGwXX7rmEe7G6HE9E63dv7+fcjmt6xZ/8UMl6q/k=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0yM4Xndr6N0u2bRKvmYbn0Lu3NKZTGpPi+dIfS3U4 Xsrq36lo5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCJ2txn+mSdLJ4Y9kYw4dXna g9uNjYofKvwlbYp+BzbOSGo90SQqxcjwTpb9hXKrvcLEK4JJx8I8+H/nKT6VmuG7+cT/ObEvhbb zAwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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]:4522= 0 (...) --> (...) 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=3D8 rcv_data_fin=3D0 rcv_fastclos= e=3D1 err=3D0 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) --- 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); } =20 +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 !=3D 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); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254159; b=bO4QDnbPXMJhML04Sxq6WhG3l9szvIXDG9nQWDafQRqScJuvOWRJGyS3MsZz8WbranrN mUf96Cbfvod1EMBOJ2QJPZUSH7m9pmXdUrZz2LGf1Hxt75OMmLCIoaE0hjkLV5he8/P8O vS9BeDXWHYqDCCLVX4se2BIpNHCYcvffJPRciD84xidNmFLqJbr3M1wQ4DbIvpEv0OSwf yuEa0uVH3KT5zpNTv5CnOCC/ZvG5HBSXEa/twVYDeDq9SGFGpmIuVwyEdNMu7eY6hOCk9 fAECYU1F7fouTs3hfUjHSmZI41xrsLtb1dBez0fkC1RmIVCRIk8kchxN7r6m/AqJgrA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254159; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=CtbWRyess2ATG6qwk5OdH0TNhgCsOg/N7yxVVkwRqmk=; b=ARHThXeNB71wTFrp3BMxj8UXGAKX9Qixsg6eFYSpsM7dzpVDPHysqY9L0D0qBvD3YT66 zDNuhAWbsGxRiynuPYMDdjm44rTlUrhhI2PVK49RHx45yhRSLcY75Hi9v0JGifi/LY6D6 OXh+p4oWMT/fhocc3E9Vnuy6yliJsx+gWsl5nLE2sw+N4Nl9X6sekzIvETUom0EOWxmw6 zsRKldEk1WUhgQdwxs455YbSHazL99qFnm3uogRqlylKytT3eyqrJkUjKUndCu8+mXvAy gWKJq+zEE2rtd3SYIqGx9CNTpjIdtJ7BtVpRCph3N79fAqNUNhAHRvpb8f7bpubbdZA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BAIFNPik; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78D9A606A320 for ; Sat, 21 Nov 2026 09:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BAIFNPik Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4A611F000C0; Sat, 21 Nov 2026 09:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254159; bh=CtbWRyess2ATG6qwk5OdH0TNhgCsOg/N7yxVVkwRqmk=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=BAIFNPikmoyoCWFExjHl2O+x0iDaYr9IZ2R02mW24i1QM97V+y1CvxXvqnhZHrP/p bMG8recajJa5DRLoxh3Sd3DlI9iX47zYE1B5QvtL1381ZsQPxVxpjBJHhVPxbpZz7s Q1zpJWFJaw8j2J1OPViep37SDlXCwgEPfHctU0FxPP/hs13p7KDJblH08SPCQB8WLc nN8VJo4kKkHX6J2XLDgPtNpR0GRk5Iu7GCphb7uanmmjE1+ORC8Fps6wt3jQSeENQc aDkJWBLx4Xu3wOUqH3m71IWp83R40QEOGsNcvNVLnl/SUTCJS0W86fzkXDibnxXhM/ vcFYjwiUuQrAQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:21 +0100 Subject: [PATCH mptcp-net v2 23/62] mptcp: no sf left: process pending DATA_FIN X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-23-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4223; i=matttbe@kernel.org; h=from:subject:message-id; bh=QRCW1lC8/L7YhV7EbzYVbBVtj1oJG9WFmH92ukOfyJg=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0yPv584IiZPROXZ5z4vFp5f1Wf2rrNoXtr1ZIeFSe Ky3GO/7jlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIlkLmP4K9kj2dH3wPTm7GsL J9+avb4mmJ9v9+vNR87vXn7tiKL35k6Gf+qXN1/I8/9/tvDBXiXWB4915s6eMlm98M+JkPsvgkQ kfjABAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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]:5= 1790 (...) mptcp UNCONN 0 0 [::ffff:10.0.1.1]:10123 [::ffff:10.0.1.2]:5= 1790 (...) (...) 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 o= ut (...) 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=3D5 ack_seq=3D117846435202134= 19601 data_fin_seq=3D11784643520213452397 backlog=3D35484 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) --- 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 *s= k, struct sock *ssk) =20 static void mptcp_check_fastclose(struct mptcp_sock *msk); =20 +/* 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 !=3D 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); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254160; b=pYNA04EmDAy/dbdoYP4NNx8rp3hRgnJB7tbGaAdLFASp2zfIfF8miWsVVsMClFgN+Vd7 aqZF0spdV/OyMGqwyuVdeLqoXeTsGOirAzRLL6FCS5/C2EOKhdCIDseM4DrHz7CChwD58 ZRgKflj6LjXjhxZYEcL5xwCKdvE/qCS3gmXKmLGtgn8MMeFn1gghSOM8lLGZIfgVMFaMN ZBWi75uGtlQBLQpNNsLHBOodL1g8WcTc1qpieVzBaC4W18WGpGfCQmhkOeWXevNkmpF9r Hn+1yu6FKn0LYqrgC4rb90eiAgxaQb08QQcFw01sKcpVTdsvUDRhRVwDnKJqubIrnxg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254160; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=1yzzdBxRNXwXwFRGHrVaGLBPDR7oDdyW2VC62tjTlZM=; b=TgW2pn4TfCH6jkyLl5Uz0NOfhplrktkoxT0oKrZdn5+Mt7f56Z3OpTlVi/E0EJb1/yoo P9mtPX1rGl7h84lke2j2HPk4yjzP81L4jnmRHViO9vrpJk0+6PvkGRIO2w45E7A1VJrIn k8dek5vKP1cBWaqUgkhRVoIWf/p4yeJkItxXu9pJ+BIX5CFTcrgNzX6wzbfdETN9lhoAY 79mh7hvnuPew8RUU2mxIox2xEJLh6Fe4LrsOkYWmrXg+BWeeqF2BMlYVdfvEQ/AocvkWL CbIrfUYR2PFrA16KPFrg4LQ/Yn2n0b2xsvRXo/j/HqPQMohVuqaGMd8WKVsTJBHcKsA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=d9IdP5Es; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49E53606A320 for ; Sat, 21 Nov 2026 09:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=d9IdP5Es Received: by smtp.kernel.org (Postfix) with ESMTPSA id B63231F000C0; Sat, 21 Nov 2026 09:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254160; bh=1yzzdBxRNXwXwFRGHrVaGLBPDR7oDdyW2VC62tjTlZM=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=d9IdP5Es5E/4J5/dE5kn4bI+RsFjMbDCDoEkAyRZSHb7gag9o2hDsz02BbXcjrfQ7 SuYy6d7Btv3AseBA/AGV/5xFuzoNjC7aQZ8T1HH+EhthlLl+WiItQcaKDrHtwa05EH 0D5Ei61hbVYBBL72yKLzTaNpvmWBoAizLJ6aoknbzuv/fcwDr5uhwRlNZyo+wqCRW6 E5o8bW4QmibdpcBy1xx7d5znTMhl5OiUKWddBvPKlLEg5A1p7Jp0hGCizUE4Uzyn/W iwGl6V5kZssMhaHTUs9mVknEskqqBmlzDrzXcbvfjzSkGVEeE6MCQDxVL9Bh0idore GTEJoTpElY/5Q== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:22 +0100 Subject: [PATCH mptcp-net v2 24/62] mptcp: process pending close events at accept() X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-24-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2432; i=matttbe@kernel.org; h=from:subject:message-id; bh=PXMzScb/ikkOHhotgT0uVp1mVlCO6ryzxXyKVDqp2tI=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ06M+X76wfEevEZ+QzhXLWxX3JZR+FOeeum+5o/zSt Zdl2Zd3dZSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAExkigEjwwf+hgdGfy4rCNhe TXm87pCc9YeSTYc2vDqZGG2b5L0lxYbhv19Lz6P0zRyqiaGsv2adrrxV4/bTNKh3+u2NW55/rQi v4gUA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 w= ith errno 107 (Transport endpoint is not connected) Without DATA_FIN: runtime error in read call: Expected errno 104 (Connect= ion 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) --- 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) =3D=3D 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)); } --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254161; b=vYMat2nS1n0BgzCOUecp45LV7EwHNADtVkr9Dr1R5a781cD4VvMZP6FSHrIDhwBDlHbv vOaN9IFYAqjejFVIePlZNi3BkqqNv81Zv5NTsrEFSjqS7Yjpxxnn3sbpkThO9XN8Mx+VG lf2iORC/5IGBbYIYs5dDrdPdN3GDImKb9Ou1VkNVNbXhmO9H1KsrosY668eq4OAvOUC6N kkZ+zocjD0IO+0lBO8KfPZCqveVQ2NpHG1S+N0HR/1xdpzZzJfOWbo/yWOOI8fBwiFqiv eYzoGqeTp7jJzuYdD3aPTxQAXajkrJkAvANv5aGGpuwrA9k6b5pyB64bT2pG9T00Zzg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254161; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=diPMj3YCrIOTW2Nh3saxSrDzK9Kwqprzsc9mQjIy0o8=; b=CFiokhv44yN1gNJ3HILbtTf0UuHDWACt+Zurnk1Dm4jkgfYOzMTMnxNtCsTvEnVWs7sQ 3AjCa9DbaEeOhd6gBg5BOWWGvXlaT/WHz91Jb/nuNq93y5N0GmiVefVo1XORySt2AI7Ru PfSEhnj5hluUAl5cPCb/gMq5LmoXTngxBEGd7QBWtKTdrAYo2IRkkjB5azi1mHiKv8Npn 5lKZ2/pg3WwqW4t3WXMXQplouRe+SrA8OjlTximJ2K6wrhipP4kz6E+MEjEDSa9+l5+Tn j2e73iOyJx3K6oQNejqT0I2YmCjL7Pmab2aDRraECDN4pvIv3iGkhyw50CeW5yPD+Iw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aEIMzbVt; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BCAE606A320 for ; Sat, 21 Nov 2026 09:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aEIMzbVt Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87CBF1F000C0; Sat, 21 Nov 2026 09:42:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254161; bh=diPMj3YCrIOTW2Nh3saxSrDzK9Kwqprzsc9mQjIy0o8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=aEIMzbVt9SMMbLOt93htAX3N9vSE8QRrzMsRkijHJgxZQ/q9bl91OtzvvVc/S+Wgs 4eJgkez905QskjrhNhhm0QluQijvXZIiA96/RrmP7N1jEORDVUvzJ91PTSlRsFeTka xUBziYLGQEuzPODyP1gimfZjmbp4Pq2V8eei2emE+uDCUswAGYyZXXJZ0S3gaH18ad F0c8i/zlMH6775NFiE0sBH3UMag2RTL7s+uId4rdb9AvMYmkQTroNJFDVlOr+liXPy Bq9V3IJtaRfuNsUOAvo5PlLRF4UpdS4cdkIVjeXQgSuSbojBqwrpmwNedfj4QB5zGq pdmAvdV3MZvfw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:23 +0100 Subject: [PATCH mptcp-net v2 25/62] mptcp: clear sk_err on connect(), as TCP does X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-25-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1425; i=matttbe@kernel.org; h=from:subject:message-id; bh=N3uB6wPzh5xVoUSi7P3stUX93lKm4vXC1l9psyDwGqg=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ06OConN4l78Jjmp/KHf6HdcObb13ThPXLQwWFzxo8 KDmR0pMRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwEQOHmX4p++cMEUuYPrMedOe ejnlCvIafLQS82LJOq3Ks+6Afa7gN0aGl25W26o67Wss91WafpqcatgnU5Ga0pOoWhDifJr9Izs bAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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 sock= addr_unsized *uaddr, if (err < 0) goto out; =20 + /* 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)); =20 out: --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254162; b=ZyXNTAxyMsO8y+QgGnlvvu5nLiTKxHO/pwnZLJvE6cA6GbyfI+fEH1IU+cay1YjlFmbO k8jmg0hu6elOM+IQr5/B1IX1v0EiaCCplCv4eFjKW3X+tQQXhNPGVF0jkpyDypt6gaMtm 5k7pB9R4cqgQP5+bQTKSHJ/g5G1qQSm4ubnMY4ciQPvvQpfVgqQcXycF4hAkysnwjfBDB P1fnIsHyKGQLwUBx+60oc70sGA7sm7vZWZge1aSUqqpJD/cjtRD2GcRfWcINnGipxMXmb cKDa3X/gm90DDKUe3T+UFGnow8QzuC9Lgf0ThCkAmGQXHHU20sw/fSrnRgk5cwZyr3g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254162; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=HB2OHBvvzYbf8EwS79YRZiqj6o7oXeyxYII93t5xl9U=; b=vutNjkdyyvzTAo11v+Ah0NC2zOBS58t7w1m07JV8PFjs1VK//KJscqvuuDWxERFNbb6s pfG/cFc9rWdVQrTJRF3Z28HHwyNP60tdGTSj0bAorBPHA96ZmkleVHnPUy2qUcZ8kShhG 65UW23RwGqcFac2ZEWsGUMWD6pg5McVXef3Zjzb/mCL+CG1ND36AUQaTRukQXJcMOHqL/ 2pcdO6CVMBXA7BYXoBYh106DoCzAZaLVhrX811IWAPNqa3hYyBvW1Yp9twQ9ebnoxayn+ T3BV6SOv3JCR2FHhdtYbLmDRTIZ2Uwh3Let/ZscK2YEQVzLrJx3b3LjzJw9aM9/Cphw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=biWPZuto; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CF10606A320 for ; Sat, 21 Nov 2026 09:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=biWPZuto Received: by smtp.kernel.org (Postfix) with ESMTPSA id 593F01F000C0; Sat, 21 Nov 2026 09:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254161; bh=HB2OHBvvzYbf8EwS79YRZiqj6o7oXeyxYII93t5xl9U=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=biWPZutoSIKgL5Woioc+s7DGgQBLZP5f8ojHXbnIRZC2SYLbOz6ZHM7QRsQYKKjHb mKU3vuzlZWnX+VvA+Oy/6jVnOaaiWTU+b4u+B9gzYDHAzdMdhd2SaE/fO984y4B9u0 MQeV9UmgA0MQNVHsKjl/2bI9ZKx01yOOjNRNLrk4Uw0tj2Y8I3nZmOr9YJJn+hUY3o F5oqFrPpDXQlfogKhKTb3uOn9Unq4w39obSj5bjUyXN+u45Lt1zseWJYwigKYOOQiI gK2C4V9U5LRB5XlOSJC/xpJ2ZB/+WjOsCR1PdPnjQmj2i7yCU3fwsTqNP64Dk7c2GT IwFATHVIowwiA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:24 +0100 Subject: [PATCH mptcp-net v2 26/62] mptcp: clear DEFER_CONNECT on disconnect X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-26-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1900; i=matttbe@kernel.org; h=from:subject:message-id; bh=BRYXGZR7H+Ax4fERPJpuwBYcNU1ND+UHh7AH2yQJ/+4=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ06PPirq+EdzA+/TlI+6g9QlfF3Fs+NEaNy1U7IRh6 ZS/31+7dZSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAEzkRwIjw4Pfl3y1LsyojW7f 5RK5KazAU0mpjK0nQlEv8ZdfXeqrNwx/ZXpYfkpF3HYTeKff1PlvQsES7wn9cjwvDZfZSFXJV7a wAQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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 flag= s) =20 mptcp_check_listen_stop(sk); mptcp_set_state(sk, TCP_CLOSE); + inet_clear_bit(DEFER_CONNECT, sk); =20 /* The later subflow close can not kick again the tout timer, * as the msk is already in closed status. --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254162; b=pQJ3EncwRWIc3GqGUNAnEEWmwnWzDtndHyxxHDzw61qKsFTpFhKhc9DfKGkWNznEZRMc k7I0TVF3o2gSOVJhlx3EaJD6e+kTh6bBbUAYg3zIIcoQyf1VkNJ0O89SnhfWEI9lcFZ/U djg0aP+IIw7F81uiEHnaBv5pOKv8p1fJ8CULT95zIpB/6hKL9pZ6/gLr0oroTxueEq+GB /DdA3Fz65AOmlcz4wgmQE5fryMBpPWyrE7rYOL5xQoBjofJSFhpySTFMR9q13uHwO+ni6 bzzByWv1L6fHPtN+WfJtm/Bo7yZZIcXdzpesnOoLNCVCpuMRvdajrAmh4SQzpFSzY9Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254162; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=O5MXK5gqtGPvuJ4JanXCfz5r1NYIEMzLW7eSPtGVvjY=; b=2/FQ2Sqf7fuf/hHzx2H+aEkHHD2uWrKn3RaOstgVRKWCKVO3auyfYQtTvPMS/ut9neZP jMsxmxekMOM8ra3QBGWHa18d0AjbQFVVT/geCfcPehBfPwrqPb1M32fdd32kLE22Ryc++ QLj5jtF1mq2Ira1BytPjVT9pCGq1ZGHtJVThbPDbVO7b8DdKekb9rF7vnmFJaDRapSQdv 7cEpmXgq9QZbzNc4BC/8hmbgGEG/Vo+WrJ7XtI+9bOFMQUiG/f7yyqknXjsjWOQUPxadD cWuhCenfDc5J/49ZGQnBRw1FQieorD2kE/jAHoGAdeNzjADsY066abCH2M5swoaasfQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eJAByYWb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5A6A606A320 for ; Sat, 21 Nov 2026 09:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eJAByYWb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2ADAF1F000D3; Sat, 21 Nov 2026 09:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254162; bh=O5MXK5gqtGPvuJ4JanXCfz5r1NYIEMzLW7eSPtGVvjY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=eJAByYWbzGKZCPoAJo17k+rRFWCMPoEP7bsyEhw3yY09oYWKgFduP77FxFAaVysIo p6xHiw16cm6T254uOaqbIvn+kbUWj9iLs7jBftoQB83TzwwahkQWZ/URWzVNDR/DVG V44eUg/SauTBNB/MXJFLf+/zl/zIq4jht+WkclQk4PWC/YkouMLfBAJQ2HGGq6KwqY k+XcRL3utYvY5OVxRFM/kHYK1EkZnrAFp1DYxxPn+vUJTxE+KRgvYKvjvTHrKkg8gV HqK8LChZ7qYGp5rwIkCdWOr6KD48OFv8nQJjGYq7zNL/6feYBtuCdRvr3MXdljxj80 LMABdigvBmMaA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:25 +0100 Subject: [PATCH mptcp-net v2 27/62] mptcp: report sf aborts during deferred connect X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-27-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4108; i=matttbe@kernel.org; h=from:subject:message-id; bh=lkiYLbXXCZrYjwN4i0qnri7ouiBQpgMzp/E1QZO2Nhs=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ02M+HfH4V5Ca93l9biAf+4k6/i33FnCXKrMyT1fXm z+fy7i6o5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCJRnxgZOqq3pZdYtd2a9Tjk 8bcD+sv/u5XsWnTaL5BhppmtjNPnGkaG31dbxU+7eSyLYp7lezcxf+/Oo1F3pFaatvKticpVbz3 NCgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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, st= ruct 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 =3D __mptcp_nmpc_sk(msk); @@ -1974,6 +1972,19 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, s= truct msghdr *msg, ssk =3D msk->first; =20 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 |=3D MSG_DONTWAIT; msk->fastopening =3D 1; ret =3D tcp_sendmsg_fastopen(ssk, msg, copied_syn, len, NULL); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254163; b=S09l9AYmdizLmDap0imccg2jZhfIjx76Vzzu2Y/GmbmxHRma4MyMn0JRTfyTt9pIxT6w SJO8fX/NBHxHbPpK7dlh5+6RPzeJFhm17f1UP1BtXcIumAL+QuiVzWPuaoNOPRlo0krmI sJ/JyVDqW7Qh6bO4pgBcMc8dGw0NFxqlfHhBfeYXl6lb8mNLGJQ4mzK8hxJJed0fOYYxF fKbP5/MnimFOgEBrdrxG5klJbH4h8KYPDYkr51UI6231XKFxndWwEvo06yRjfb5Ff0QvL ZPHXkIilR06eqHAc5r2YjAhL5xz7hiyv0ZotU+yInsfHYfo2jeFk1/hdcPxu1V6DU1w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254163; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=qLn60VggItfZS/qHjlR0QceU5k5uYtw7CkH153DR43A=; b=MxUd62l74M0vYotvOH7CDZkVYnB87tDrbxprnn105KBVqgar/Wm5EWlhoCQQseHxNz3u q4kz3qWhFXzi883bHNoDH2JTAvDKd7W4isXfIsWI7HZtlAvGLPqcw2AwP9GUb1yfw2u7R s6SrDHmzN9aSQnxa9X9O87KT4cVmmdiN/OAUBy20izMlcC7O+FC25P3Ye6ZnUWwxxvizd yEwhwSf5cq9lT0fPd8yxvpT7HQbLmkCHUC09uvQrzxuYSPo4e0r7t+ROSewpjjufNn/EW sXsCV9xZQPOg9oea7Mb9Zb9s5Saf6am3/7IFkT13V/4LfzCWcTsWB6P+8VLOIKcLvSw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lN0q3rrp; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D103A606A320 for ; Sat, 21 Nov 2026 09:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lN0q3rrp Received: by smtp.kernel.org (Postfix) with ESMTPSA id F15DA1F000EC; Sat, 21 Nov 2026 09:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254163; bh=qLn60VggItfZS/qHjlR0QceU5k5uYtw7CkH153DR43A=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=lN0q3rrp0E+FCnLfzpxmtHrheinhFeYvDX822Otwei/y05TwA60C1ysG9nZJzJCNM ElQJocraDbCX/TqYkkcIr4mdckJa9UOtWwDAIxXU9zZ/ndE5kimbmldKJs06ffoxB8 CvNbuklvbaTvfeCuyMlaBeUwHurocx4LrMHSNZDC2RXBVnJuTUKA/h4/WCqXLAzQ2D 8AVo74rM8kuXxqO7APtDQX854CN6ekymVdyeR2c6ADRaSNp7lh440wa8siuTYTnhG5 R3jPYqzd8W9IzNeG8xU1PtewWmMCIAN6L3oilKnK8h9xTsWrmssJipWkEl1rqlhDpd G6FbkhLJdZajg== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:26 +0100 Subject: [PATCH mptcp-net v2 28/62] mptcp: no fastclose reset from SYN_SENT subflows X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-28-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1888; i=matttbe@kernel.org; h=from:subject:message-id; bh=aIOAa1mnfFISJwtn/OsIRa79h/MYRISFL2QmeNPvhpQ=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ02PrCje9aM0zPhk7q5hh6Z8C+5mvs86bTe2+Zrnsb /x2o5OXO0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACYSvJLhf2H3DOdJ2aKJBQ4P ctYWfZf8e8wsMcXAqqZ32duVmrcOSzAyNGcfuTT9T0Biioa1XFP6soOzRUoE/s2zDbNzqeHycHn NBgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 i= pv4_total_length: expected: 40 (0x28) vs actual: 56 (0x38) Fixes: ae155060247b ("mptcp: fix duplicate reset on fastclose") Signed-off-by: Matthieu Baerts (NGI0) --- 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) =20 subflow->send_fastclose =3D 1; =20 + /* no reset in SYN_SENT, as TCP does */ + if (ssk->sk_state =3D=3D 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(). */ --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254164; b=uSAhyJiSUVo56iPvsUrEphBWTrff2dDyA3HhdQDTSoP5PEkJMlLHsiPAPRT6EQGIX8ay VPkYAj53EE6RBLU9a63Oc/SNpX3KEBqGcJomsJv0JSDQZBNHUrioq0Lk11FDUpyh+ZGCp MshbClYFwdIiBRbFEkubpw+LK8dnv891TcX9dk8i1rDtu1oW1eyP45Uvjela6gMWAfNoz wlmDINxOwij5V+Hm80qkHHJiL0xYyixps/x2huTZ/aVMXlqoll52wyW6UHHfXTVdUXvcf HJPam4WhLLHJ4IkUfZEoxBr/E88p1IhoDS4b//4HpVGSPeqJuvJLy4kqaiUQSBwopvA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254164; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=wN3nt6sNoe1nldDn32wakmoGrveqSpy35I6dQm6HgRA=; b=IBSWlmQz5UprTsE3jVNSemBENFvvecyGiiKvlq/Dh0i0w1JAcLY8ZIas0M1QN6FWayNa ObQH5UELieR5FZYFt1L/ZFcwTMt5kImvZ/HFxfcjZqFyMoAeVbYZ8ujj1ebHNYR1+2QCP p9ZBGx4uokpup3vQm/5MQ3WxexV/PJmGQCM30PJhoKFCCPsv/pWcU/cuF0zX6G3qZ1NDS 8qW6Hfn+IO0efKYL78d1RYPO15V4xXU1ac+shgBhIdgKwogpEHp0O8V4RLBiE4/1OhF4z 6k9cin4UZ/oN6lSZwM65jJpkQPRTFPasmjGu2W82mIT/5uVKFWnIFtZ/6pkbYL42uMQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AcQs86An; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76753606A320 for ; Sat, 21 Nov 2026 09:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AcQs86An Received: by smtp.kernel.org (Postfix) with ESMTPSA id C36411F000D0; Sat, 21 Nov 2026 09:42:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254164; bh=wN3nt6sNoe1nldDn32wakmoGrveqSpy35I6dQm6HgRA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=AcQs86An4LFahCsYvkBKTz0qWNrlMZOpGYqQ010L1vxkClk29M9kLFgU94GZ2xjzp 3tImixFLFJJZNErEYVUxwr2vDri9E+oLpDAqtOcXpQHZxnParEeUNbQfXkmQghpfvc oLe5kbpUEZvcW0aNppwRoqB55hFTF9ywEulkZZj+mcPma7KZeM9Y4z9vsm0Lpjwhbb fPHgSQRhtTTOnvZGKrSvccBuy/8ndudkSH5spXhG413CIHt2pkAfRi8wUGnVA4mjo3 jAz9qskufzSn6DA2yK5WcqNkcr8ygOXZBJDZCc08K40pd9CAGRFeUSSJDeRNstRqiL oCKJq+b53bb3g== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:27 +0100 Subject: [PATCH mptcp-net v2 29/62] mptcp: keep listening after MSG_FASTOPEN errors X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-29-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1886; i=matttbe@kernel.org; h=from:subject:message-id; bh=eIh3RdkWkGqKKaScoHEAm6QpB4rGvVfFOPB1nakjSP8=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ02O39ySquCYqXvu/96p75NeVW7sEK1dtEzrS/rfl3 rTW4LO9HaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABMxk2T4pzvz7PNHyQmVh/iD pvt+fnsie6nkqZM5JmLXiqQ4cr13RzAy7N5vGid15/lFlbY/RgrrdsxWvXQiJ7N1cdens7+3yx5 exwoA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 i= pv4_total_length: expected: 60 (0x3c) vs actual: 40 (0x28) Fixes: 7d803344fdc3 ("mptcp: fix deadlock in fastopen error path") Signed-off-by: Matthieu Baerts (NGI0) --- 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 !=3D -EINPROGRESS && ret !=3D -ERESTARTSYS && ret !=3D -E= INTR) *copied_syn =3D 0; - } else if (ret && ret !=3D -EINPROGRESS) { + } else if (ret && ret !=3D -EINPROGRESS && sk->sk_state !=3D 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++; --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254165; b=4dnyTmnHii59WdnlXnFdWk/oMEqXxl/rnGb+8//UcDJlRKGiqFn8UnSukBJdvHYNLCkZ VyK4nwqnCXLPQfopFOcsu9EmzjoM6qwrYQsUECHRGqiBCQQO8aMaZi17Y7Qs+Yr5c9Z0K boAEsOlUp+80rNFB+cG6Vi3TOP8nrA8bO0ZwWz4uDiH9/AfaCZcZycEmu4xY/CqfmK18d ulxZewgJONpA5BXBkyYUpLY4+IaWwsO+maUV9buxfJhr/CvM1mUhXO+Mc3rbu6svD+U/R tEDksc4ZksXdhpW80kYE+pwp1l/ThKeeUU61JcErl+DJbroPlPvVhBHBjUz4nsYWAZQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254165; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=YSq3s8h7EiepX7v1VY5tEQRVYyBZTAFvwoDMFzE3poA=; b=T2E+Gk3NgBvN4KOB1BJFNB2qT/0wYYVNUr4yynimNu8H9HH2zKh8qcli5x2TqHVz0zoD TGvS4tXLqfYQ3Rez3+9VOXh6YGW5KwWmmHFyg6vys6OocnOvbjbSoXgwUP/uQLPRbkghi FeFhejiTAA5LqlV99wb/02cyN5vrFrG0Iit1JEhXXp3rX2HwrkY2zr5IvNr870JYuaBvp qugSOGCrIFDRTcCRXCeMulFue11rSO4z87R/Wk40ubq0dqrGwakurU63iTDOOj+a6Ipb9 FhHJGccwR+EAOpE50Ng6frEtfshr1HoL5B+wN/Lv3Z1ysCBVy8u/VQ4QiJuUtxOsSEw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=J+C2peoN; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56C07606A320 for ; Sat, 21 Nov 2026 09:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=J+C2peoN Received: by smtp.kernel.org (Postfix) with ESMTPSA id 957CF1F000C4; Sat, 21 Nov 2026 09:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254165; bh=YSq3s8h7EiepX7v1VY5tEQRVYyBZTAFvwoDMFzE3poA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=J+C2peoN8ksVIQKKMDonyAMhGAGfnT52l6+gK2qu3cvl8fOqPWP1mlKaA+lHjSXJB E7AXyV3tfmcn+PhBPpRix+YYm/FhMCvXWHV0dQqNcbGYhWetgFJkrUVk8xY54flVCa /Ed39FWnBPxaJdPbJGkTXCqQPLeRozn01/dEMVRvhOT3kDDvm7EmSb0LVF/abmALgI resqceGqbVQ+jK8sxHQVFChBb5TFoz8Y5rRzsyDd86+Og2blxGK6Bo+RoccR7KVukx Fd+fECBX/Zqi4F/V+V5uWS42qtZNntYZMGvF22S3TvboO88fWG1mNGbh17QtF2FEBN Nb9b8xtlQxs1w== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:28 +0100 Subject: [PATCH mptcp-net v2 30/62] mptcp: don't inherit fastopening from a listener X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-30-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1683; i=matttbe@kernel.org; h=from:subject:message-id; bh=QfSSZ5fKPsAQRncm4BhP1Z0B2qhi/hLcWwvImWqqi/A=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0+NmezHkSWjNEkp/ytq9VGVp8pvzu/oaT1XwVh6pr H5fL7imo5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCKzkxgZFpZcWX3lmVD6gzO/ u/o+Wan8nR/J8UzSUKpvrVto+MPEc4wMJxMfJRedPDLJjjXZr6L59Ef27I2/MlZwPvnsV3Mxp/Q LJwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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 *s= k, WRITE_ONCE(msk->local_key, subflow_req->local_key); WRITE_ONCE(msk->token, subflow_req->token); msk->in_accept_queue =3D 1; + msk->fastopening =3D 0; WRITE_ONCE(msk->fully_established, false); if (mp_opt->suboptions & OPTION_MPTCP_CSUMREQD) WRITE_ONCE(msk->csum_enabled, true); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254166; b=PKBuH5UWqzX7PwZ5Bse/utoUonGFj/yzoxJDropR4c/jdEQRJqW6rKVOG4soHnJOoQ7/ ACAEj1dBvvD+fOsZWz4PBJojXa9KnyLBH7pgiMExnr3aDMsYsJ3nfLrzSF5Sz+sBLefdh /BmTYdUS2yqc9396ooeBOjfI1U6yPw6MKOqZU47PvRFQ2+R03PiJ9Yr06G86hkmNSl53o I1S3CIIEinU4rjhB2719PsZ/fS4JbmbsAsC4dzGP3WPe1DaheL27Ecz6c5+jrdGkUPagl 4lfS8PrgXmlGvgYyEN628XFRcxqZSkDfaki77YJb5g9/Ian+Z5O/Kq3yi3e1rm6ncBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254166; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=0y7f5/sxZjXJqgSd5XI2WbJo591UdVzTTtgmbftrFRg=; b=4JOOI205sbsu11QD12ZsMWIu39XgyM5myKzBoGz3Qh5U4Y6IJ5nnsS29oWXeI8IVrMW/ SiaJjv/8OP0MVLcLUJ1q/FiuRdOqcU6YEVzG8DGtsEFn7YqJVa6FjEjXY0Fq8uV7uGb4y XgMVxqrMGKiHLfNxI5sF+S6pe3MyQjJL85WMxZkTA9rqaKk7qE+tHD1Dqegfj5lPQOBV5 qlYwo84OXinwRsxzKMk0oqenIwFco6elLf2/FMZh+TQoMG8g7d4K5uY5XUn2Lbr44Pu1B QETAQGzLPJzeMGjOUT2oVE2Kclt1CRCmAlrKHAVbA2UVgCu6o2erp5U0D2Px4nii6mg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FrEAST3l; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23686606A320 for ; Sat, 21 Nov 2026 09:42:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FrEAST3l Received: by smtp.kernel.org (Postfix) with ESMTPSA id 690661F000C6; Sat, 21 Nov 2026 09:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254166; bh=0y7f5/sxZjXJqgSd5XI2WbJo591UdVzTTtgmbftrFRg=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=FrEAST3lLko0N6QPOWVC6DY4zsLy6Ggx+veojba8LCZsHVDfI+goArwIwKncu/E+p sWtL99uJ8jR2hJFs4qzv1jY4DWrXPV7TSHYLJs/X5VF9h7viw2pUIBqNX9ap4aQlHI DI1vpTmLuYxCuPAVF4a9Ew635Kkm0cgiXD25seNW/Kvm+1nXG4W0KF6KA8DqVsHGSq CrKa8SSTry7t5El6sdPuhVBk2kKnkjatKZYqAKLwhPX3rO5p9pku1eLk6AXXLBQi+p 5flpP+6gFpc7TVad9bkcGQyVdMwZ3sm0pktkOCeC4E29tuHPJTGelgUNvSNifCWqN+ ezJheS5bRK20A== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:29 +0100 Subject: [PATCH mptcp-net v2 31/62] mptcp: drop non-MP_JOIN cookie ACKs on PM listeners X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-31-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2846; i=matttbe@kernel.org; h=from:subject:message-id; bh=mvP9dPvMO9WcK5n0ED/hpdYpE2ahF96caseeY0WKWyY=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0+OPVkjO+furOqNBX9bC4La90W23l89df++Sivr+z nO5bsORjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIlwnWNk2Glu7bB0rtHpDKP9 /359f8MZ9KVmdZNy0U7pp29FL7jWvGL4pzxvbYPBvOTHurVLz05dtMdMjpH1w03GD05B8e86fr8 v4QcA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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 [ 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) --- 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, =20 opt_mp_capable =3D !!(mp_opt.suboptions & OPTION_MPTCP_MPC_ACK); opt_mp_join =3D !!(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 =3D=3D 0) return -EINVAL; --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254167; b=b34yrKPPTENaM5cwMOaCvaLtdl9896wduMHpyca4sGGSoo3z5/5/NqBh9Z/ElcBAppwP jpSO7S9nMrnHAOsLe9Z9C85EgLLJ6mOSEBAA+G5Scvr00Hmn/2B7dS2cPxawQruaC6Ss0 0+lzMaWjAlBvFitWImskdVBu1ZJoJXLi7TBxdeDYIRyOQs9uOrv3+KZZ4X6zIJj4cKGMX itlvdhtGpF9LL9+58S3dydWWc44V9pUUq1Zm0svy2RqJSscC9vcVAlK/lL2ppFCcELF7B sg69saEDivOeNjVgIuIDn2blgCd1gx1KBVJ0pvnHRLpveUKb4JMPMTjlT8Gl5VK4C8Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254167; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=kELscjjjenegsl0ivrV1O4RHg0+yzJhDByyvQsds5yk=; b=Y16DEyPTX+I+QKunKw6q2mm7xrZ0+zmmTMovLazPcTHz94d4CIARE8yibn3ZecLTH5wD bIrveHGsZ2Q0eQSWIyBndMKHWVJ6x7H8bspZBc3FbipCYxtuha/9Cv8DvdylIOuilrAaH px0tD3cXyT5dmD/3JXcrLabVRScX8q84Q3wo0k3wc31nRB7W54cuJsYqnnFhxW4WnVON/ QRIQKg8eAkl+35SD7H8RQ9Jt8zftqu88PKd6QF2HXSwB4ZQnXwGdhvrcj+Z5pNSoPVbG8 3/55wj8QpIcb1xX23STPZmx8gNStMazhNPo1sgx+NIomwMr2v05GZaJzFUUbeKZ/cfg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=abdlJqyA; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32696606A320 for ; Sat, 21 Nov 2026 09:42:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=abdlJqyA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 608C21F000D4; Sat, 21 Nov 2026 09:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254166; bh=kELscjjjenegsl0ivrV1O4RHg0+yzJhDByyvQsds5yk=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=abdlJqyAltEycsqWjty4TkKJLTDe10of7S3IQWzhXM8+UWy1IdwJOPcFR+2tAKalf qsCLvhZSoXRJwD/AERsbOWoP+Qgy9BECsfG/oJNV4dC3E+meXCmWYM02wErZGm2GH9 tkUUgAWu1PMgizp8IaaO9+f7tdttu37F6Aevzh7z52u0rkA+Lul4OyPecI4RFvZ9m4 AtOM36f656plEE05HpbiOlmFyYDmZMUTxo6SCB0864zAFEKg68K4z/XhHUrPvp30aG kM7xH5u9CClp4fftuPOP/jilUqoV8H0o5mmYwSJN5ujPHjHXrr+KIZnnAa5G1nTOmj s7WBGQ3fnl7rw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:30 +0100 Subject: [PATCH mptcp-net v2 32/62] net: add __sk_net_refcnt_upgrade() with a GFP mask X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-32-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2373; i=matttbe@kernel.org; h=from:subject:message-id; bh=2VIvHnRwU8IB+vMrv4KyFTHkq8/NNiY0Q/ImiNY1neY=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0+PZ93ybKWKwrfXmjVlrjpV+5lRlmyM6L7BkRX+Yy N8FNssYO0pYGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACZy4Q4jw4eiuOpNm1/P5es9 d+yESv/nLV+/dk0t98le4xQyjb3nsT7DN/W1vPY9t+ec22pz+ZtPWe29+da6vvlTBHdcnT3tuvs sJgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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 lo= ck); 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); } =20 -void sk_net_refcnt_upgrade(struct sock *sk) +void __sk_net_refcnt_upgrade(struct sock *sk, gfp_t gfp) { struct net *net =3D sock_net(sk); =20 @@ -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 =3D 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); =20 void sk_destruct(struct sock *sk) --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254168; b=wWh+s2jfYPHgq+I40aBqsS8NUAyDg3XnHUs7d1ywhpOK8KvLc4F3ZDqCSdexx2X+T0uB +pQ0DMGhdMqIdZ/cI9f0vAnnxbrG6b+Dy5wstmtNuUwWjH7HtV7OZVIC66AGHxAeAHBz9 +2+vvz1GrfCZ+M/oXY5223NqwxFpOqC/LYLp1aKUKMcqSm+GbxpBNbwTimOClUj67nFI6 Fn5KtJc8U3j/fYQkU6MeIQzMxKdqivIvNmmumvRrzLzHK/hAuK5yUlWbozvup+3diT8iP +e/zOapnndhgvijm8mTshMEZoZm5U4Degk1Rv0AGg5LBes2jT/PNAgUpbjAPoCm+wSA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254168; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=xwjNMh6i+YF8TulJrAnkm2qhBUAl92Y56moGun4RQ+8=; b=LZw+nUxIKEhBKKeIVaCWeVEC7W5bpm7z2UDf3ZMDniHawRsGJRhZEY2nKmXiT/eDP8eK KM9BpoBv34EmojPF77G1PKuzneqVbnYuFrsZE9de5yTkkTHDk0/MIIDr0UEp0WWXnFXug 7JY+qyF9zAHdMNP3YzuCiz6Iwi+gKEQCPTfztgnDt9enV396/7f7x70dB13/dAuHw4Skj dbalAwNdcOqtOG3m5kG0UxyAykLmeCe+5cRWa3XuUn5cj5k9Yp8jHQNgCwVSaDJ/zOqzF qPspt4UJSEa/2bNhklXectFvxfcNN5DWqrd+oMz5Ve2XrZMccUWPHUGx8TtiMNrploA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KkMDxj0B; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E072A606A320 for ; Sat, 21 Nov 2026 09:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KkMDxj0B Received: by smtp.kernel.org (Postfix) with ESMTPSA id 329921F000D1; Sat, 21 Nov 2026 09:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254167; bh=xwjNMh6i+YF8TulJrAnkm2qhBUAl92Y56moGun4RQ+8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=KkMDxj0BKcTZ5x3eob8Ud92XBVKJ4ETDoOgeEIwsVWuvvLwOVaG2u8IvpV9mZNfHC kuJOgoA0VPV2++zbB4UoCjBJMC1FkT6BXI7fkqsop0YGqzO2LP8ImGAStQNwgB4ue9 /gTRONG6sKKT/QxMOQpCT3lJlc/D7IB3jFlE/X5YoK75pstYwuLWMrS/8HxZrHegPe tEIcwbK4fI6mAJNPOy8ORWgGgPjq8/2JHvFreldj4V9yMhYk/+erGNUwxKQHrD3LIy pjVV4Ljv1XxuyfEQNRtSc0TzpHyHuqjeBDWlpM/raoX4E1rW5VD8uN+IV8lBd4hU+l H6BdX90IbZRgg== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:31 +0100 Subject: [PATCH mptcp-net v2 33/62] mptcp: pm: don't let listeners pin their netns X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-33-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Josef Bacik X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4426; i=matttbe@kernel.org; h=from:subject:message-id; bh=fbn+R/IWHgV7AsM7NBLw8bKORxWwKwmnmJDEYy+lbk8=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0xM0Nm+Qeue0KciyX13Gm6n1zB9Hj62FrL1dx+7fe P3uwE+tjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgInUMjD896wXmr26gtEnjGHN KcsLM++/CVY75dpR6Bnxjq9TorXMiOGf0YeK/X8/haYdfN5edSwu+gxj25RnFoFs7bOeHepmFmT iAwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Josef Bacik 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 =3D=3D 0. T= ake 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 [ 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) --- 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_so= ck *msk, WRITE_ONCE(msk->fully_established, true); } =20 +/* Children of a kernel listener need a netns ref for their timers */ +static bool subflow_child_get_net(struct sock *child) +{ + struct net *net =3D 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, =20 tcp_rsk(req)->drop_req =3D false; =20 + 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, uns= igned 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 =3D tcp_set_ulp(sf->sk, "mptcp"); if (err) goto err_free; --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254168; b=YuDMrSwii216iFgCRNkNIkMuDG7GMDNmhS3oSzPguUirjEObYqc8QKyANEV17lkMgBfj KwypqbkMpaJOuxx4j+sxYnCADfzdu2pfOthrx79qECdd7L6Dw5zvE1zVNlikLj+gFlRz2 xA939fzMk4FVoBERTjZx3GFSlLg8WQM/gUFY1Nie/Z6D57O65u8wDMSmxdJ+1HFAbjtY2 zWqqDw/V4lUaMwiE21+m/uXrUqRnX2pOVeAwbHSbYwobAGGC3UN98mF5tWDRL2PlFYi31 +s7FlGbp4MpO7uWm9NrA9aArVjmzIpSEZKAHNwu68DHW1brS1ZZ+/j4CzQY00VfQw2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254168; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=DKiOJLmt91Al6Fs+halFYbdfB7gKkP2q/ZnjT8wthyw=; b=va3dRbSPyLpgUjWgsUsttwQX+qDePt8BCWPWFKPZfU8CLgCl8dGjha3FoOzOYU9pskMu HsqO6YAnjMEPjRK0G9rSpTKJTXsJcFi2Q70NzszH9nMEKzMkHMn6Pn1nSeI15+0gV6pbl BM2rzi3USgoRtS1gNdR7X/PaTCyRSyVXRzpkhxE82SOR33GkysxJs+uEvd7rme+9q1H7o sK1EW3QC4HHkWUR5qt7ZvVxhUQyJXKNx/oqE6zpcIsASrAXlm186HRuLki3pPRWWgR9rx Itn/z9Y020Z0bcYSB5wghB6diWWDu4k4WPk0zjm3ylwlSx0Bl5lQeVb+6yE89jH/sXg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GLO6BaEg; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9552606A320 for ; Sat, 21 Nov 2026 09:42:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GLO6BaEg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A4D71F000C4; Sat, 21 Nov 2026 09:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254168; bh=DKiOJLmt91Al6Fs+halFYbdfB7gKkP2q/ZnjT8wthyw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=GLO6BaEgoV5O3B5Zucad2KyRqAj/oD4mBiussTPl/rr7+WbBIGxx+nHxAKO3hpMKH CDceL+D1sxjhiVDxzhaxGUriZCVuYhknaGCT3MXxCQrgE8h793DVOW6GcgJnrVFRSL zCXNChL/cG03dvy7MtI8/cIkipApfUFQ4/TGRFu+HZ7wdeL2xEamXGMM1xj2PvrhON ZlbT34fSAYQWVb8bJ0BVXd3uuUlnfx9m/iobTsZGA0J0wXjbvLo0P9RW1A0mPI0FT/ 0ivMrcrpw1S4z/Mkls/TOIZfZmbv55Z0r/7q/1f989TKlXnHO3pb/B/+Px2YP0lq+M YAJx0pJnZyvCA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:32 +0100 Subject: [PATCH mptcp-net v2 34/62] mptcp: close a subflow reset for a bad mapping X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-34-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2949; i=matttbe@kernel.org; h=from:subject:message-id; bh=vDSonjHJLvEYRw0B6TXnfiH/4XWAJbqSWPE+t3ePBJM=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0xPllVgmtgfMf738t+Jqm8MRkYdvbsjySJT6tbhly cvfPLdPdZSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAEyk7iLDP72od3/UotLz/Rmf rFyhzt2geNejnvfM3ljJ7QEZN3qSnjMyvFtnPfvaXPaSki8hGpqTuXZqT7BwVi7MfshuemfJuQf OPAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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 er= rno 107 (Transport endpoint is not connected) but got 11 (Resource temporar= ily unavailable) Fixes: 40947e13997a ("mptcp: schedule worker when subflow is closed") Signed-off-by: Chris Mason [ 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) --- 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) } =20 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 =3D 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; } } --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254169; b=Q2u3IDVFg4NSHgSpTqEsvEdhxw29NxKp6HCI+Q9VKBl4fIHatM+KD2qcampYjg4lGDJU +SEbMrsUcYRRa2jh5AuDHbK9191RtbPd6gUryD61yWfocy9+iILRdYGhJq8PluHdUO5de iQCe2IdMexHXhnx4Lb+JpKnrxIFJRHUr/UlY9gvnu/acckbAk7ITHQ6CnynX1cQAr2tmN R9311yiM4CD3UxkHXbD4+8uqPtsKOrPGRmBO42bKx+x1pGvbYNsL2HUISHEX3TgVPswjr QWfC4kG+pm6yiM0YaWH0f9yeR+yUd0NCOTrrNmugwH2/q9ASdFL30sagT7MBGIwVIPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254169; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=YzMafzGQVdLPcNdAXZXrUpb4Pu65JxH1ySuzu/OVBLE=; b=fQ1KUzE+/GDWTocxRgpMIDQRV2IVPYouFGwg7bzHVu3FXQs07hfi1DcpQ3RKbpTQWQCw BhS8EIhf1q45L3aUKhDd6OrWZv19FTk/lPX2m44w8AKwgnLieosVXn1WYW/ZRX2wTClim aHGnQ1EtTAQlpAVI3u1ZqQysp2UrrCxgqCJL3vcNoBcety+AjwW2KqCh3ywlyBsmpJvp4 eY2Tr0N93KkmicjNK0bvBrXwM6on320GshVYp0U7KefDFJXAwejFL1qSD4KNQ1crfqzbK oBBih8HPlVi+VB7xRNCP+LXuWjYDzRIkBUaFNCZCP3llKO6F1T6Bbb/4bjb8Gb1evlQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dHgsnHUj; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1548606A320 for ; Sat, 21 Nov 2026 09:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dHgsnHUj Received: by smtp.kernel.org (Postfix) with ESMTPSA id 232771F000C0; Sat, 21 Nov 2026 09:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254169; bh=YzMafzGQVdLPcNdAXZXrUpb4Pu65JxH1ySuzu/OVBLE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=dHgsnHUjeP00ODJ3EP60jLO66ZY4CBAZRFTirIDPFD7PCX0M253H2Z1BBx3bNd31S cnUQCLS6qyC2mYqy+ecGugdhnVtgSe7oPIaJmWh0VpRICas8QyG2oj0p5+o86Ae2EV 4Aljm6wk/08TF+0Mgg/vE08vsiHQgJIYrmrwdxK4MvzudYsTU6dbdo06MW/ejAHYuh FbiOIhskMFMRhFwjV+iPxROZ825S8aaaPIiV8PHG6XzBKRknV+RP+y3N5AyXnFXquY 43gddzw6dszMQYOXl6H/mYOvtU0JNJDYZGZdkTZH1ST3DhB8kiePBQbx/Vfp02rrSP qtKVw5nq3IlIw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:33 +0100 Subject: [PATCH mptcp-net v2 35/62] mptcp: initialize drop_req in subflow_init_req() X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-35-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2851; i=matttbe@kernel.org; h=from:subject:message-id; bh=oUA2Th1+YJiYsmBX1cCAbNltaqVXmh1ex6O+73pvrFc=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ05PqTSQ0pqU3S+zPkpTZI7ki2KRIREP+SarEGj5hO 6lHyzZ0lLIwiHExyIopski3RebPfF7FW+LlZwEzh5UJZAgDF6cATKT8B8P/9Fw257dbqrIfBx0x WPfCeL1WiWirJqPsobPcL67OF014xvDPKG5h9uopa+oeC635sHX2LbUbxZ1Hdwq/bby+d/Gx2wU 7GQE= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason With CONFIG_MPTCP and SO_REUSEPORT migration, which net.ipv4.tcp_migrate_req=3D1 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=3D1: 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. accep= t() 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 m= em 0 =3D=3D=3D exit code 0. The process and its namespaces are gone =3D=3D=3D 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 retransmitt= ing SYN+ACKs.") Signed-off-by: Chris Mason [ Shorter comment. Commit message: how the issue was found, and its symptoms. ] Signed-off-by: Matthieu Baerts (NGI0) --- 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 =3D mptcp_allow_join_id0(sock_net(sk_listener= )); subflow_req->msk =3D NULL; mptcp_token_init_request(req); + + /* read by tcp_check_req() even after migration to a TCP listener */ + tcp_rsk(req)->drop_req =3D false; } =20 static bool subflow_use_different_sport(struct mptcp_sock *msk, const stru= ct sock *sk) --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254170; b=rIBeTrPOirqQtc16TmD0K1BB3DIR7Gv0J91ZcAubafitd3kTJaNvp7e5Fx2rtMsOux2Z OKrqZIo+9mSL34V0CtN/voIrmJNiFLmJokSGjxCIIPosMQqng/IECGeD5wtcFL9m/QkZ5 +ZLO5g2FTPpWQ/3EkpaGnaLhxgglqSlZYT/q82WZAcRlDjcXVufH8zxiFZ98HujkK4gih qd1P8e2y5r0XiQZBXS/hNse3hjg5W8GXUuyL5n6gfnL/2fRAI1+x2zuP6j1TbYbl/sN2+ MAaNahZr9fo/iVT5OSR5npA9VeCgChH+VCHfPuWYzo1EmhxXwhzPtuSRDIXD1OOGALw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254170; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=CBbmcC3SquL/sUh0/0abO4UmG3Cbv//EVoTMLeRnei4=; b=LB32NziSiNVS4p6Tnw8SnUQO4ELR8ZqWn7V/m5EoozRbF2fAGrUQmFPTlXl2jYe1DkGZ iXJNJoUKEbT/5f+yQ/z/YeYvorbeJC6tnSCdkO6TeIXEhhAlg9fpihcbtNpUSO3yzUfVs OfvaSdJFANLLv/abNJSAXnuKyJloWTq2jXvF3SY4mYjZZ2aHxuAzS+y8w/dtOwRg0nEqp a8ALrlRwgBKrfZZwt6shaAtXmqnnHAMPOOa2WN1Eb3FhiFAfc9FiQemIQ+17j3wYPve7y PCEsKzejthK9Ohn3i1hwmIgtvf7bNpLWBv9pZ0srynhB8QumD4JsvNrZZN8epVjJgVg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mNqK26TI; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C80B6606A320 for ; Sat, 21 Nov 2026 09:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mNqK26TI Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A39C1F000C0; Sat, 21 Nov 2026 09:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254170; bh=CBbmcC3SquL/sUh0/0abO4UmG3Cbv//EVoTMLeRnei4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=mNqK26TI3hQVXeB3oUOWRlcoXSt1DV6ZI3PCnqjK3VYK10tqIMOVohOdYcazD0Oge 7VUMoAILBTNNkJ4WH6GJfMJ73vRtIdoVOAShJ1s/KOmpfufmNss/IJ8SpQIVDM2IcU o1ALz0kf0A6cTSKwFKeGmVcbrOpNPGU6d0uwkT9p8I2K2p2qmrObBetR9UTNCbT/y9 UB0jUm9y2I0wxkLq9tfJa3dcMR6FA0MEya/bSDcbDotnlalSlCaVFaM2GyOq/gUu9R KKFE2/IcCo4zO9CaFWdF5w6BZO264pwZ8ewSoHKdHxfiCwYAheva5kBPEzZr/pZF5g 1+h8AJaXhIKzA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:34 +0100 Subject: [PATCH mptcp-net v2 36/62] mptcp: pm: kernel: count endpoint listeners as sockets in use X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-36-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Kyuwon Cho X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3964; i=matttbe@kernel.org; h=from:subject:message-id; bh=OPRvotvx8HNkyVDGOs6cqb6T0ZZWlYYOMAuy5o5R+7w=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ05MvKrcd6dLM3mGlyCaa1Fq042rd58lTmyWe5Qbf3 qZUqMHZUcrCIMbFICumyCLdFpk/83kVb4mXnwXMHFYmkCEMXJwCMBGXIwz/TE3ZXh0LurFmlSFT eLJkv0PXkVcyX7hNOiztLSPldE+dYGRYlfoy9aPyg1O7NjfKdC6+9je105rvkM2tefbMoS7ahww ZAQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 += =3D $3 } END { print n }' /proc/net/protocols) -eq 2` command: non-zero sta= tus 1 inuse: endpoint 1 present: 0 (expected 1) [...] inuse: 3 user listeners: 0 (expected 3) Fixes: 57fc0f1ceaa4 ("mptcp: ensure listener is unhashed before updating th= e sk status") Reported-by: Kyuwon Cho Closes: https://lore.kernel.org/mptcp/179502042942.2742790.1788799442428253= 6144@gmail.com Signed-off-by: Matthieu Baerts (NGI0) --- 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 soc= k *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; } =20 static int mptcp_pm_kernel_get_local_id(struct mptcp_sock *msk, --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254171; b=g6y+/smIOZ3qwG9XncnMKpEAj7IhfKWiK3zhFiobsn7jDGrUX+CkY8ucEfRFwqmNE6e2 bOgWnFjY+NhOn1/og6vaC08VLm0+Nl5AhU2awKaa6L4CO0/eHI7nGo9Wb4KtYk5UqYbiX qZF23L2tVVtmWqd/kt9CczndxZchRGWPvo1Y6W8263AF3ei78rw1hQPTIyfk+0COVePe3 srQKHtW/Agmp+ZNkEdnqGZfrdsbZeidw949vaiAT9z44JpdOaA1sddjH8TjLNLS87D8om B/b1zBkdhXGtcDdX+r/U9m9fQ5N2Xu9n1T8ImtwEHDHcDq3hZc4EBRyXqRC+HLUxBnQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254171; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=DXNq2NBTnuP6KEZgPzVF9BPAHUhB0yg2Yu54Jzvl4Dc=; b=kfHEEkgtMNCHh0eSTgGuRhFin62BkNIrVIwNArE0Ms18bhckrwwGwnsApYcQpx9x+C/s cUqFAcZkqlh/Mfb6kN3Hf7R6dgaqBDY8pxRwKd+8Olr9OXhMQNkA/qRBSEY5Jp6oRt02B uF4B9+kAQljkIs6RgJ4f8u/aDaIOU69cVdbCHNCmF+JoQbjJZoJDTJYKMORInnhmO2S+n iD3c/jXTVQ9wmdrtgn5ZObq7SULxXXIF47tyLSRoeDzCzPVfJfyUdkeEwWQJWxay8NXkw WSQkphd3FvH2gTfr9YkOOhhtUh8KClLCRqNPwa9vpeZqCphjaPeGmIeYD6dw+QDeJCg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MWBDZYcS; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98D8C606A320 for ; Sat, 21 Nov 2026 09:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MWBDZYcS Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1117F1F000C0; Sat, 21 Nov 2026 09:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254171; bh=DXNq2NBTnuP6KEZgPzVF9BPAHUhB0yg2Yu54Jzvl4Dc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=MWBDZYcSI2tSDf9zNd0sE6ZQxPi9vxUB4Dq9gg+zAob1VQB6iQudlT0H3xuSmQI+l tL5k2LsI9Xkjx1GSsEXqsqP9EAAGC+ESJ6jx20BK1PzEMTcwKc4Rj+NrRDO1GuIcls jqYofdkbOXyCuj24QB7s+yDP9qAVEi7j3E8gL+RhhPTdCsKhcpOvd9dTRX26ns7e46 IA8IAZZLfne/IIiCFghmiZR9Jkm4ibAm685unrNzpqNbR1JdsjzvIaqyP6QP0gFN4P rwdgQJFD0NLRrFE6k3S9r9Z8eoio9/cn+w31Gb1RSvCQvW7Q8RVMxSWstCakeW/NSD J6GQ5vjYVtdHA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:35 +0100 Subject: [PATCH mptcp-net v2 37/62] mptcp: count a listener once when listen() is called again X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-37-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2837; i=matttbe@kernel.org; h=from:subject:message-id; bh=aAO3v21i2NZQBA5RaoNlk3u9ADhknoHelAikiRDnBDk=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ01Pm8bmyRz+ov/Hz6e6JDveW+n1K/yzWWrJ3wsKkL VrmdeISHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABN5V8HwP9h3I68A170+ewmz 7+whT4s0XXNTFt+7t7BPRT6W18z7AiPDSaPmi5vjglcF6h+Ysf/k9r1fC4rU6itFRTzSru+ZtVy KGwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 +=3D $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) --- 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 back= log) struct mptcp_sock *msk =3D mptcp_sk(sock->sk); struct sock *sk =3D sock->sk; struct sock *ssk; + bool listening; int err; =20 pr_debug("msk=3D%p\n", msk); @@ -4556,6 +4557,7 @@ static int mptcp_listen(struct socket *sock, int back= log) goto unlock; } =20 + listening =3D sk->sk_state =3D=3D 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 back= log) release_sock(ssk); mptcp_set_state(sk, inet_sk_state_load(ssk)); =20 - 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); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254172; b=EwBw8obdOqQtnxd8jMczZrAWEWP9SeqAkAYiz+EieKJixRTtxuzHSco9NgrjA36MOQRb 8CP55dQwY6FxfcmEZhmADtNYI14ubAas1jpUcrqs4cyr7rtZuz6v9tAhN2yZiA35DeHjh c5Hzj+W+bqRd99wX7FxHrAI3wvuQeegxIJuPqJLidUP0PQzAxA5uUuKrxgLHRGEqLjlkN 77Z/nGCrnYrxdXLF4jBDLc1+ETbHfgLuTzmSAGfhl6ZDtIETUQzuZv6EHzLfznf2/zIup McvSSUxJwGXtHMlglQI6FGhJfq3PZ070tPrwRUPwT8gUTlAsdSBsdL0HgKmFXBkhuFQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254172; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=IMWIfMLbTgOU68PETiIOO4Z0jSGD0f3GiD0SqFWMpb8=; b=AYP8mRDrwA20AAzw4Gv/+2BQGql0YJcWWzIKEFFbdeV2gUp4a2wjF/TN6tGiMh+XP14U cEJ+dcGW/hrpsGoEbRYSHmAsGrzOrC1vFVZUvxh5t30ZDTT5vbZcJMtfOd0rcLYMesMaf Q+UAbOGaphyYxrCX0PyHVWiUt5zhCEx0MdfUH8+DyryBi9PyPt/UKb/qcmEDbgzBOqHEF yXBnEJARXwUONUAadjkU0yhDKWYq8Qt0SfRkkLLgdjFrIL/RF7oBIqZIY5ZzsbT26wlHU yGP11PY1CpnZUr751W0Gy3oYVw+2kLLIEK1eKKwfWFkO3RNAsN80c7wf2kmJZDcuPdw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gyzl2GWS; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABED3606A320 for ; Sat, 21 Nov 2026 09:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gyzl2GWS Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6C181F000C4; Sat, 21 Nov 2026 09:42:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254172; bh=IMWIfMLbTgOU68PETiIOO4Z0jSGD0f3GiD0SqFWMpb8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=gyzl2GWSnEpgFzpG/ABBb5HJaJG/yanE/o4YJY6J0lg+7keiRUK7jzpZ5cFVsYWIU CpnoP3u6DsBUFUsUzZDcC2z/eEqL4Ykmc83BLAaYohWlJ75LhKM0EzznOFbZ3jRmNC 0MrX/DZQerY3hhrZ3tguj6KN82XWOwo8rduzZlben4aprUrLmKieIYUNTl1mNtwZmp FBl1GL/416spBO0crHu7lM2QnxssfKo7aiykVnyV3az6UG4Q4kot0T1wLemgKB2a5W b/z9KQvTeUeXll8vK54O9gWVLoADua4y3pvAJvjSqjm2diINOFux+2Wn8WnjAMBEm9 hMZXOuYGgpEkA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:36 +0100 Subject: [PATCH mptcp-net v2 38/62] mptcp: send the infinite map in a single segment X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-38-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3236; i=matttbe@kernel.org; h=from:subject:message-id; bh=rzBxndB8ksKv8c8dj3HUIdQOHI4xG2yif+Eg2PP5mLU=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ01MYbidG7t1x1d37n3kvn8VXX/Frl6cYt2xnmCkfe eiG1YTDHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhvCxSkAE5lzjuGvwOVvVn4MQvlvzx7d Y7Rw07ZPx6L3nIsy+Gb4VvZaTJz5VUaG474TJbK8eZqL96iHP8rMd0z60vkm9tDf+TIsdbvd3zg wAwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 fo= r 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) --- 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, struc= t sock *ssk, info->mss_now =3D tcp_send_mss(ssk, &info->size_goal, info->flags); copy =3D info->size_goal; =20 + /* 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 =3D info->mss_now; + skb =3D tcp_write_queue_tail(ssk); if (skb && copy > skb->len) { /* Limit the write to the size available in the --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254173; b=IjkUsDni6iUOMWY34OjIxAj91wgcB3Nt5w9Vv9hlzNN+8tWFmjEp03/lNCIvyKY0mG1d IWRTM8s3q8zO5551vpSXqHx8AnN2CwT0psc//nTDGSWWlBa+t4PxYFrbden5NyjTlpl/e +T3xcxHj+hUrqUqUhWDAUnSmZtwH+ihWYyrTjQ8QsKGD0snhnoxrlpoMjHKSspXd+FADX B5NOA/PAaYCiD8/fAuhos8NlEE3Axvjkk620VgrVnM23zviCU+b3/h/UHQ0afUK91nnGS GeKiftKMMC+uza0xmivS5BPmdeUMj4xzSQ9w2i5dnyC8e6R/yd31xocv3x5M9uSvYWQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254173; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=D4PNlodOsPzocv5muUm7GL4betBacQs9eIXnIBRmIaU=; b=0GTYeeQcWSfdjery3V39KNtcm9QJRiPqesEQCV9C5bszQ7q2/fknyFhbRBiNpYyAXDVs GZgiQkjtK9Lguko5gjhuSRn5iDoif32LwuZzipvBtFesHlth6WgUHG95wnO8/oGxo6jdP Ya6rx+FLGOmukXJrHa8O4TxrqfqV2JK20rbpaQ2lACDDab60HEgeVHzUTs7tmja5llRoN Yl4jK8C/czpU7Z0V4oMV+sO6FICbXI1lIuVwO3tZCtgyWTTNpoRBY3OI/ziQvIVGCJsvq hchtUHzPRXKydIMsI0E3NV2nlYIszi8TeFkZIWSiij75/EvYofZEn9KxWKHaamsQ6pQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=S0DTwwBH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E497606A320 for ; Sat, 21 Nov 2026 09:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=S0DTwwBH Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9F1B1F000CF; Sat, 21 Nov 2026 09:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254173; bh=D4PNlodOsPzocv5muUm7GL4betBacQs9eIXnIBRmIaU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=S0DTwwBHs5mOk2leQeWzypiS+CnMK7ibyK4Jj7D+YRALoRzomygouV3E+jw/r9vNX mYY0+oleN04gNqh7T5OT4JhqAS53nPU7v+28xMeL7Xoo5MjxyaHvDy8LMepEzxkycY RrfRRX6y8wVp9R0qDNoHjcpZ0FxzM9eJdLHMgt+ql293DQqZh4jKjqNeCs0huMGxB0 DfiO4nprNCf0rbZUsrPVEf+u9BhfXquqeZlpFMvOuTcTRHiokwMU9sS8yMfFzXykYi +exmYvYNVHHs0jZuHy7CXyeYks51OFeHicCIwnH2FSUy78ltU1I4ZZ7BWoCW7LobeU wKrfEzPsGEobQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:37 +0100 Subject: [PATCH mptcp-net v2 39/62] mptcp: keep room for infinite map after fallback X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-39-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1969; i=matttbe@kernel.org; h=from:subject:message-id; bh=KG3m0ePxfVDTguUKurT89h0c9KRYrnsKmepsItyeU0o=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ01NPBToc6WHYLnnsS1hyj/oKPY1jykEvamysVKWdP 3moa53tKGVhEONikBVTZJFui8yf+byKt8TLzwJmDisTyBAGLk4BmIiaOsM/w2mTbD6I5zk8vbVX xymh29fwLuu07u12qVHp13er7g7dwfA/b/LJ0GUbPu2OZt2+c8KEY0I//WN1hf0/GrsksK6buau PHwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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: Tim= ed out waiting for packet Fixes: 1e39e5a32ad7 ("mptcp: infinite mapping sending") Signed-off-by: Matthieu Baerts (NGI0) --- 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 =3D 0; =20 /* 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; =20 if (unlikely(skb && TCP_SKB_CB(skb)->tcp_flags & TCPHDR_RST)) { --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254174; b=nukeoEIJl8zh+rP2bth1W2/e+OmQNnb4HuHB/DkRdrXgdyXklecJJGRzuVWYTe2pkVki TYSPkm9SnUoJhrKjqYlVdI0789JnekuLJlmKel/b2ZPimmEWiq6b4+jGMXyv6uQqZwW3s FKIdbWXt2LVBUXYKhjBctN1CLvyBQV7fLsMB7MvchvxPpGBS3RoSw2be+WfC2Nw4MZZsm +vLzva8rvSCVzInRIH/1pnjBazgZ3Ss8gnLlreK1TxoABOYjuWSn/kMyRYtnYgXpnn1LX jBZLbNpMBZSa1mUBr2W+zyZuELjnyIX2S205lP7+B+3IuWahBBH00J6nPJhmtkB6JCg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254174; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=AdalFLr6xR+EZ/cdXO8VxkTwNlATyC1UfYxj/zLV3tw=; b=5iXy/EAhhEIIr7kK8wpxMQO15THAjkzbadBoIWMl2ev1h64ScAvXpYsREN+hLzrfdTwL 2cJKlZyPQYmPxFcZr8D3UjRhyuW6u21nJvua12jr+wmks1J5nCU6x0FeUBt/dSfYPg8dS 0+HGXw+ioG0d7homGJI3w+OmQOYBr0JYO5y9i8Cj2n+D943PiX7Tjk+NDaMzBUikXGS3z +D7bBkMsthTXaAHUC5fJM0OPmt395/1VuIsTeSpQqPKIj4LjtqB6moZiH9rDTXr03Zk7M CfIG5ZWsH6GmNu0chgCqbTJhp/V0XnAsr1b/pYkYtgLhP8kNEUzsxZCu6Uvp5oA/6Mg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jPywV9dj; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88C6C606A336 for ; Sat, 21 Nov 2026 09:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jPywV9dj Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C6981F000CF; Sat, 21 Nov 2026 09:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254174; bh=AdalFLr6xR+EZ/cdXO8VxkTwNlATyC1UfYxj/zLV3tw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=jPywV9djsRvX8Wf+osgUcdiHGArCVS1xf3xAzAevsBShohWEM4NprLWEE1VLvsNYy gJaTIg4cBuPk2Zb7Xl6GXd8YHlw+Eu0ddjH51Qc8pQniRrj8YbFDU83WnRu6f8qFu6 cLEDTpV7J4aAZULc93BRR/2Kkoa8bH9us4fir4ofbbSzEvx7Pkjd0T8XzaRxcQZZm3 P6R7Pds1h+NjnimvWu1PSVZpSRlWq2ccAMzzcRjxUkk3gOOqrND5/cx82NHKjqJ7yU VvIwZCvGALIAPvUewe0qepLzaXcaA5ZRN6rzjAtFpL9e69BxNJ73U7A3QAO5jRHkGY fvcv9nOTEof4w== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:38 +0100 Subject: [PATCH mptcp-net v2 40/62] mptcp: do not fallback while old data is in flight X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-40-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=9121; i=matttbe@kernel.org; h=from:subject:message-id; bh=lQH6tUwSeMmpXSVyJ9vX/76S/3BaAYetl1FRgVCFbJg=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ09MqP5cWLdzjtsju8btElwS3Z8v9Mmf98XyxUah+b VeK0M8fHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABNxSWFkOBT1L1uPTVo49PLW 8JgDf3nE3uk3pCVX+BZN+ps/oaf2HMP/ck3VN85nd+91+6rWdYedK9XrnMiPG33XGHKOH5B3WKH LAQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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 =3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D 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 8= 388608 missing 0 twice 1 [...] end: eof [...] receiver 8.611: READ-TOTAL outcome iii-repeat-or-gap bytes 26000 of 140= 00 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 [ 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) --- 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; } =20 + /* 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 =3D 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, struc= t 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 =3D info->mss_now; =20 + /* 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 =3D 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, struc= t sock *ssk, TCP_SKB_CB(skb)->end_seq +=3D copy; tcp_skb_pcount_set(skb, 0); =20 + /* 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 =3D tcp_sk(ssk)->write_seq; + mptcp_subflow_ctx(ssk)->old_data_pending =3D 1; + } + /* on skb reuse we just need to update the DSS len */ if (reuse_skb) { TCP_SKB_CB(skb)->tcp_flags &=3D ~TCPHDR_PSH; @@ -1599,7 +1612,10 @@ static int mptcp_sendmsg_frag(struct sock *sk, struc= t 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 +=3D 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 { */ =20 u32 subflow_id; + u32 old_data_end; /* TCP write_seq after the last old data */ =20 unsigned long fail_tout; =20 @@ -1346,6 +1348,11 @@ static inline bool mptcp_try_fallback(struct sock *s= sk, int fb_mib) struct mptcp_sock *msk; =20 msk =3D 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; =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254175; b=nJcj/Uv4vojv3RP9l4pmhWJnBZ78WQx9/EIp8/uHCSc0SonOmD8c29O1G4rRjBldvTgA gU2TRhiieJuMXDEiahU9nRmnAS3WRioIprr45wG4MDyG9VnRvfr7I8YBMKkD4ULg8GSkb Cgn0pcfHoIdN9h/sTGF+V30EBh8g2/DHd8kv1Sn0Z2S335DJAQEe7zklgcYqSnOMk5hhn rZZcO63vQLWlf9a+HnBQvMK0Sxvr3QYnvLkfjJd8Mp+6YvYMjAD8Xud6RDckqUT4jkGZE we3mzSib72icCM1HzLTY4X4gLuO9WI6dotIgPqRCbbWkYtKitG0SPimCpndxigtmcNg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254175; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=yRbhiilys0oSt9BKa7QHoKoIKuCcRWp7Gg11zfsm08E=; b=jJAJY779qs2U/ZCckZIXygoBZHLgkizLA2+FePMluBEPix++RQkgt+hchLwPUQ7TPSMU oAmhp0S7zxm6ox+kb1QSuMFO+pj+FRebdXicxhCH5ZlIooFZcUDNJR0LEDgD3g6f3xiQO w/iD/+x0Amfap6EEhYNr3VWV4fiwidrB83pNs+3tZB5ehrcsTkNU5PcEiDaXIQvOHJgvM TrWU9DOSNQvaMFoYb1UwO3mvGBN3ERpoJmlfHhMWWl/g+/LiCw3wwYabPvgvHi7F58pxm XdthtG5MG665r8yR2Ili+KhCPvdnsIFUdE9sxlGINuozVyVrL5/tIDwhQC3frHz8IYA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=d+DKiprI; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D56B606A336 for ; Sat, 21 Nov 2026 09:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=d+DKiprI Received: by smtp.kernel.org (Postfix) with ESMTPSA id 742721F000D2; Sat, 21 Nov 2026 09:42:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254175; bh=yRbhiilys0oSt9BKa7QHoKoIKuCcRWp7Gg11zfsm08E=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=d+DKiprIGgNDRqO3+mWlzpJhuODagjq82d4ui6syVxbUFxCc8rRq0MhXTKYSa3/TS W66R9KeAQFFQgtuOorCdiiB729GE5fOJwo9OKfdbpTKrTTlEQ4684Vo1PdJlacXmSA OZaR1G99FjPbInjIDZlKlKNNTjwtJnmjlhu8zHXOn9d6EFOgT8KqQWx4XgBJ8nI0wI HYdwcRD9rW0T9wW1eL8jR+qfQOCxhqeeVJihko6gkHg8Bo74OQV6OROZirEMka6kMH htmevowR6TLo7gQG0AylXCi+cisWOHTrnBsu4aZg7vH3M2XgyrjHg8/Y737Ew6WsWo csR2ipTQoVemw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:39 +0100 Subject: [PATCH mptcp-net v2 41/62] mptcp: stop resending data to a peer that fell back X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-41-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=9462; i=matttbe@kernel.org; h=from:subject:message-id; bh=8sWwY6sUY8nKBbcUHPWKI6SHrxHl0Algv14kpg7K4gY=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ09PFGj1nvZ0Zzcbz87Xm0aJqjqwgA2l5l9glu2Tcv r0v+nyzo5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCKLJRkZFuV5zvmn9HuxrHHP G9OC29YMR6arX7zwbO4Ltzfth/OmTmFkmHy6K6yua5b9b271aJ8Te7qXXTszbXc6f5PxFXHdU0d zOQE= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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 =3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D 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 [ 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) --- 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 !=3D TCP_CLOSE; =20 + /* 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 =3D 0; + if (unlikely(mp_opt.suboptions !=3D OPTION_MPTCP_DSS)) { if ((mp_opt.suboptions & OPTION_MPTCP_FASTCLOSE) && READ_ONCE(msk->local_key) =3D=3D mp_opt.fc_recv_key) { @@ -1333,12 +1339,6 @@ bool mptcp_incoming_options(struct sock *sk, struct = sk_buff *skb) return true; } =20 - /* 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 =3D 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; } =20 + /* the push from ack_update_msk() can reset the subflow */ + if (unlikely(sk->sk_state =3D=3D TCP_CLOSE)) + return false; + mpext =3D 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 =3D mptcp_subflow_ctx(ssk); u64 data_seq =3D dfrag->data_seq + info->sent; int offset =3D dfrag->offset + info->sent; struct mptcp_sock *msk =3D mptcp_sk(sk); @@ -1545,11 +1546,29 @@ static int mptcp_sendmsg_frag(struct sock *sk, stru= ct sock *ssk, return 0; } =20 + /* 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 =3D true; data_seq =3D snd_una - 1; copy =3D 1; } =20 + /* 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 =3D 0; + subflow->reset_reason =3D MPTCP_RST_EMIDDLEBOX; + mptcp_subflow_reset(ssk); + return -EAGAIN; + } + copy =3D min_t(size_t, copy, info->limit - info->sent); =20 /* 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 +=3D copy; tcp_skb_pcount_set(skb, 0); =20 - /* 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 =3D tcp_sk(ssk)->write_seq; mptcp_subflow_ctx(ssk)->old_data_pending =3D 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; --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254176; b=YjqZQefXFLJJvF6by1/iZwQLeDRS48EZIMCYOQtsZavZhfC2m4Mg69uevBws2HDZ4Bj6 SwuWJgkIHAwZjxTvI26bElH7+LlK/TWnJoSUETIWXdHwMVBwUKhrnN9Hca7Vh1lAPJURn vNGx+ubJWD2xg9gIk30Gpb5jr4KKBdXEUn9+9I7Wq05ZrPymfvGRfzJPXD9Ge2EiGTw5d munhmTkXkKRjPrwfVk8bsBHsOwiodZih0M6Ov8PfBSWwXnQ3EkOjZ0F4TqMVN3o0fA2Ks lfIrz4V7SuubQpZn2qMKaDRBiRcRMQYCqjnLrS6Kud9b05zysqnR3pcSzeWuLSccSsA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254176; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=Xdrt5w1R5LjP+KDKrix57OSRRqEUv4PvitUriQVLBuU=; b=H++6M3hW8hucWgepFPxUqa8SY2v1szW38NzWwpc7o2Axc493k2EUDh2hPEA5X1aZRVJW BNjrvxMh19Cauz4Hw3rxIdRYYk7GBc5T5qyx3lWMOB0z8BwrcmtLXi6IvRhXGyBd0qH/m Mzw9Td7mye+Fbyk0jjnRlO8Iim0FSb02kllQOhRGl6fmZROY2X/ns3T4yVELB4XQfINZ5 b3Xdd2GbSvwka93stdImn4Xsr1A8jK14NtbHd0Oe4V89d+fZbKUmh6Gg65emiG+fbrQjM YQi+mM5GArRcX+69AT/2/foIEMOLNWOo0QVe4o7D1Hl+7SQZY/ZywB1kQ6OwJN7wW/g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nwzSDAiJ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F347F606A325 for ; Sat, 21 Nov 2026 09:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nwzSDAiJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B78D1F000C6; Sat, 21 Nov 2026 09:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254175; bh=Xdrt5w1R5LjP+KDKrix57OSRRqEUv4PvitUriQVLBuU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=nwzSDAiJthWjHk0JAueF4wbEq5+M2Kcyr8QehF34eo7B+zfUMp1qGUT1Ca7gvSOv4 tK/2tCaa1EWKhOCQVeFoSMuSlPWtL4fcZtIb4jjfhy/IqUp3HT9ltvZASDvGJiaxBW rQUhZwWdj0ZWESqGcc+vRuuo3W8PVAtKCCUPy6Kp91JLMVX7pEEsgqd5g3Z/aWfKul qEhXmMj0mjqbXY/gZJcsKNE99Oo0LZVZxvud6CLL0eBk/8FQNfLy84rW5u6LMy+G9/ KzpagyYFlA9UACoPoZgUbwoC0PCy8EQLxqUfkDdMQon7XcbKsJhw6UjTC7BRTZC6Dj asC9Aw1f5bFGQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:40 +0100 Subject: [PATCH mptcp-net v2 42/62] mptcp: don't resend data acked without MPTCP opts X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-42-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=6292; i=matttbe@kernel.org; h=from:subject:message-id; bh=nsoQ9WbBTuzw4hzMhdIsx19IcJEBMKWOCXo6iCfMQhE=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ09PVN8yt3nuksfutSaDoHDGuuSLcxh+Znmy+Wnfr4 kZLuQPvO0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACaiGsrwv5Djs1L01L9evxYk Kmn9L3x9fboyq9xqwbvvUiyirmqub2b4py2rv/mSuv/TncY6sgyLNY8anFsj0v5LxHrXfq4/14L iWQE= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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: liv= e 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) --- 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_soc= k *msk, struct sock *ssk, WARN_ONCE(1, "bogus mpc option on established client sk"); =20 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); =20 @@ -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 !=3D TCP_CLOSE; =20 - /* 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 =3D 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 =3D TCP_SKB_CB(skb)->ack_seq; + + if (after(ack_seq, subflow->opt_ack_seq)) + subflow->opt_ack_seq =3D ack_seq; + if (unlikely(subflow->old_data_pending) && + !before(ack_seq, subflow->old_data_end)) + subflow->old_data_pending =3D 0; + } =20 if (unlikely(mp_opt.suboptions !=3D 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 *m= sk, struct sock *ssk) { mptcp_subflow_ctx(ssk)->map_seq =3D READ_ONCE(msk->ack_seq); msk->allow_infinite_fallback =3D 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); } =20 @@ -1557,10 +1560,12 @@ static int mptcp_sendmsg_frag(struct sock *sk, stru= ct sock *ssk, copy =3D 1; } =20 - /* 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 =3D 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 =20 /* 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 s= ndbuf, * protected by the msk socket lock */ + u32 opt_ack_seq; /* highest TCP ack_seq with MPTCP opts */ =20 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, con= st struct sk_buff *skb) =20 msk =3D mptcp_sk(parent); subflow->rel_write_seq =3D 1; + subflow->opt_ack_seq =3D tcp_sk(sk)->snd_una; subflow->conn_finished =3D 1; subflow->ssn_offset =3D TCP_SKB_CB(skb)->seq; pr_debug("subflow=3D%p synack seq=3D%x\n", subflow, subflow->ssn_offset); @@ -2161,6 +2162,7 @@ static void subflow_ulp_clone(const struct request_so= ck *req, new_ctx->tcp_state_change =3D old_ctx->tcp_state_change; new_ctx->tcp_error_report =3D old_ctx->tcp_error_report; new_ctx->rel_write_seq =3D 1; + new_ctx->opt_ack_seq =3D tcp_rsk(req)->snt_isn + 1; =20 if (subflow_req->mp_capable) { /* see comments in subflow_syn_recv_sock(), MPTCP connection --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254177; b=0vcbCabKVFrb/bTTkk5UajvP3Kpl9x/9BiehRxlB1ph98OEWLU6Ilp4IWD7GQqz6/eeu /mQjBCJqjQ0KTquGVx2H6W/BwSqBZ4GFU23GsAfegA0Cwkyquu75BBpvFR7s+A8fgs4/L gCa6r61dRcC+eHfvf3I5EHf9b9lzQALs/m6qSCxcsN1q/wkBVAk5dz8xjH3A2K2FnUHvL 9ZPraqE0zLRvnuaeLSHj8bO4g57ejdo+JbSPoxONCaPUR+33jTcE5Ezr0pFA9v9ZbvB/j 7TcpRVHl4sVHwsrw7OdF4SH7YUV7Cw6GNky2DlPB0UQevHtZ0+mTPzhcqx9cjVJaQcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254177; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=JGna/U+3lUN2A873tE+UyJObLaKT7mtIxa9mi776ucs=; b=f7GZw6JnxntEi21T/jXoQY/8GHkYM5UL3z/gxGW8netDaYlz6QFMIKBYvbQAtWM6ZLnC wkWm7eyPi7dB4hLDJfxMG1pK3G1/KUafh6wD40THaFxPFRXE8eK8GW5EAVG9QetF3SRfz hBvgyXmHxdhGWqEO+JYNGU7WmtGhdY0n3PvJfWBw6EfV0e08IDQ2oxfKAooEYshd3co/H 14ACnIcnaGqMIfBfcHeR8k1j/WXs8r7xKP+doTgFQOgXku/0cGMEjtfNF+e45r/GmLa8h F/Aer3ICMxVfd3zwAAq84JvtnUpmm9p6El/WToGQ6xoJe9Ju0anIjBwnjeNJephMe/A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cbIinB9D; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41FBC606A320 for ; Sat, 21 Nov 2026 09:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cbIinB9D Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D5EE1F000C6; Sat, 21 Nov 2026 09:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254176; bh=JGna/U+3lUN2A873tE+UyJObLaKT7mtIxa9mi776ucs=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=cbIinB9Duiz5QO4qARHgBW65Y2Cw0sYMzsYCgZqO5X8RTUMvOBLSdIBSLNz1O+LQ2 jewD/Ot48pNS+FSTGHFgzP9LMCxjwJ0ZEHGwcGBOQrXyAbG/G2+BFRWQFD16cJvNlc SsQQu1rZTkYxGXShNL/W//G8PBQpeYSc5R+8NyRMGr8kufMDHsr9dUUr5bgKenEXGe D7WamyLzlXzNY0Pakup8X1Kd1ILj2DvJIJca+UZadzFHc3tRTzR/XRsLVp/oGlLZeC GyeYQIMAlyjQluIRRZwWI/Ki4jOiFU+mj+ujetUKGdJN8Sc6Wif4pu1e+j6vM9hiUy Ex7ugqFXvRF3A== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:41 +0100 Subject: [PATCH mptcp-net v2 43/62] mptcp: pm: kernel: don't count signal+subflow ID 0 endp X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-43-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Josef Bacik X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3093; i=matttbe@kernel.org; h=from:subject:message-id; bh=5aj4X1VngcnbQopcabjUhJtSELjGQkg8VtpA8/I8OX4=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0zNmL5+vU/rIeOpHf701x/5JMCxzORIpftHiYWNvw LpHB/ZVdJSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAEykcQUjw0ftZ8JxXzpe+e/l /FezOjZPsNQgbsPjZdET3vztb7qcosrw38sxyVDnjcrGVQpyHK6XZst9l80+uZj1/DtGcZ6tv2a H8QIA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Josef Bacik 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 =3D=3D 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 expec= ted 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-crea= tions") Signed-off-by: Josef Bacik [ 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) --- 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(stru= ct mptcp_sock *msk) /* Special case for ID0: set the correct ID */ if (local.addr.id =3D=3D msk->mpc_endpoint_id) local.addr.id =3D 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++; =20 nr =3D fill_remote_addresses_vec(msk, &local.addr, fullmesh, @@ -432,7 +434,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(stru= ct 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 !=3D msk->mpc_endpoint_id) + if (signal_and_subflow && local.addr.id) msk->pm.local_addr_used++; =20 mptcp_pm_nl_check_work_pending(msk); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254177; b=F7JOEZN5KSJN+qoHbBEBsnUMxvFXKWQqxdl3YkbmLD4IZru7Tf9Bunzums0hayvlmQ7a ydnEma7O1e9izOAAawAzN+LbMRnReO/SXmpJdJ7eEFnOVwrqnkJF8AK0rnlq5Io5gyinl wrk9ANtrtbGL6ETttj8+9k134vY9Fi69bdGbCo5cgGb/ql3ED/Q/m3vSTlxFe8t9gJh4n SlZ2bgV8vSL9XsOfNbhsJtRoLeRiZaeZhhoUQZwoP5eiEpAIknAKqevzPZovTF2lRmGsE kxTFH1SAqql1Wf6AKuY70Ekv63b5sWdMPXwWAUU67N8QCbZC0cuUF7taYz8Sa5/PKkw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254177; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=wbAbnYLs2apZxN093TzfpkoYrML8/18qG1jS6EmpIZs=; b=lyzCBFJJS4sEtjcapRLDhWEW4xw/7nL34gAewLLDHKYjnMXmBA/Nl9GxS/zS7sZWF5q4 oQppUjcRWaz1hAIp2Dx3rKVg1JPm5Ort25BBzOnky3Gpa2l5rxwsXq59hOOdFY0bCLGXn 4iVwInTkL8nlw8BQLH+rX2rU8e2DZcBrJvl7uln52g4mPQG/CqSOm2BgufGHZRBFGA2ns Wj9rM5oP3t+2v/Ycz7rdCQbtGXTk8RHnkatbZOZsJKaqNgJ67VcAXZT9DQzfXIyvETkzO io9qcs3CeoDZMOjtQAZ30Onv9rVEuILitd1ECoigvkGa3mlBDZYo2AS4fscZmE1EuzA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IJQGBSRI; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE5A9606A320 for ; Sat, 21 Nov 2026 09:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IJQGBSRI Received: by smtp.kernel.org (Postfix) with ESMTPSA id 359DB1F000D2; Sat, 21 Nov 2026 09:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254177; bh=wbAbnYLs2apZxN093TzfpkoYrML8/18qG1jS6EmpIZs=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=IJQGBSRIqjwfiiQLzoptvzyab/B+Qpw/4g/IllIVHwK3Oc7AqoxNpO06u8o4V0QY/ 5BbCrsa8yLNRwsCXGScMurVr7sKpSdXT+fJylcuQ+WJYpe77YdtCjJmpluAL5MHBv7 x2ng5hTi2x4bBZDfaSId0uN/CkMTEaisEq4da8nzDzZ1U06bzgfvPLI+K1haS5ZGAY 8cddw4GI3I/v+tlTTYaWpPoli5kgM0tAaiWC0LKFeCP7hbk8A0dTk6PC/vobjouIXF bx1YUvX74HZxJmgmP3KzV1I2+qYGZ3O30avUaEVtNi5eoqCtmjCzPYyujZRVOyWq12 imRBkBv/AnRhQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:42 +0100 Subject: [PATCH mptcp-net v2 44/62] selftests: mptcp: join: check re-adding signal+subflow ID 0 endp X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-44-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2981; i=matttbe@kernel.org; h=from:subject:message-id; bh=gTxHTW3EiHcEbebTLKtci6ohXctGsjdpDOtO1WTEqRo=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0zNZlmfXzzxk/HHpg/KbEp+ftH55+f6Mx02H479yz 6melWtg6ChlYRDjYpAVU2SRbovMn/m8irfEy88CZg4rE8gQBi5OAZiI72RGhobNWz+bRPRcPu+e ocTG8lOHS2RnjMeyyTNeOh7hzZle3MrIsOnuByenw1oVD28flTqgsE7p8pasx2ouykrrT77R1Dr /kBkA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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-crea= tions") Signed-off-by: Matthieu Baerts (NGI0) --- 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/testin= g/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=3D0 - local i + # No ADD_ADDR to ns1: it could try to connect back to ns2's port + local i flags=3D"subflow" signal=3D"signal,subflow" + ip netns exec "${ns2}" sysctl -q net.mptcp.add_addr_timeout=3D0 + 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=3D"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 =20 - 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=3D"${signal}" # ID 0 not counted as used either done [ "${nft}" =3D 1 ] && ip netns exec "${ns2}" nft flush chain ip filter O= UTPUT =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254179; b=me/G5gL367BxPmnrPupcWnU7LcH3RhbKij8TuYyeZZ4cSpwkQHGnI99+ACxTq9+FN/GP cTXkOkXEJvX2pVPV5KWJWXuGfwIYo+5LKwJtYx5UIUQOgq6LXmGVu/vJlgZbkiDU5pS4t fDu5AxgxzE6VgNc7ftdTEHUUX93Bl8PPgDbtqdXlS0x22rTj+oxuEf61irj2XF273YyiM GIsBGi+LYnJlO9pNdX+FB0vM6t6KJ10AejrsOSBBZ1hJYhEnVFWvHFr3eWASBC9I5xgwv rCQxPGXDCLdC/S4Rms1qXb2Qhlf2/a7emJUp+nShOhbwSHUFYuHR5gv4EXlqGoivBHA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254179; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=pcGYtyAO23yCx1qQ7SYJ3TqxAJFut2PkCGt0Of2CmX8=; b=WciVxHIX1DlSDVhn8utK4kr4n+C+KuShRQQdIAgOlJ6AyT4iNmKk5uqQBcquWf/x27Rv KhMyo3+VTVRhnxa+kLBiHerpMpYr820Zhp5Up/3/1dKYdPySquXhet64z24Yxoy4GlmFI FrnzmWJhFZrMEFVgZ/gFpdfUSwqAmtW3gVicpbMnJpL1nsndarLV02F2pU0zfUoyRWgf8 JXKmbAf5+D28ABDX6uWYGez4ZpG6i4mUrm7OURzrKCB9TAnnnHzN+YqH5W5C6j5819V2U cqEka+phQO6hCBGuVF3tdMxQ3yaG3mFRQFGK8CfWmJoTfjt16wDKTEZI9WEEHR95vWA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mUXUKlsy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E34EE606A320 for ; Sat, 21 Nov 2026 09:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mUXUKlsy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 085061F000D3; Sat, 21 Nov 2026 09:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254178; bh=pcGYtyAO23yCx1qQ7SYJ3TqxAJFut2PkCGt0Of2CmX8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=mUXUKlsyb9R/LVnkO5LYl0xbfrk2GIAsfi/QY1mKiLde+1wnNxsDTcgM5ZE/qXe7R jEyK+N7FR7U9CWQx4diMRyUcQrAARxqYqCW59j7jtSz2NudZB3QMIhtGtWUZouaO18 ius1B9the/RiCzValYdhtvC4sG1wdl+w8u4EPlcheEq9kQuJwlhD4mC+c+4mic4XaZ xJ9tEuxMrbOHBB5s4yi5aSziTioZT2LEIr05gfATpOuvjRoFTWWljlSWxXbnzv+R8P YKapUdxDCqaSAkXCcYgMo27xMcBYG7L+Ta+SpVoFKLVIDbOSAu87Sz24Z9wWmp+WU0 joa82Bm2Rcl3w== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:43 +0100 Subject: [PATCH mptcp-net v2 45/62] tcp: do not pass a BPF reqsk to an MPTCP listener X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-45-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3160; i=matttbe@kernel.org; h=from:subject:message-id; bh=IvmeQ7gqSRSQdSaAIMgmjaWuhmb4ljyQU4wUOq4a0R4=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ07Pcc4qeaLRPkaztnVGaxnPs8KrW8043+w/W3Qm/x 6PY8L2yo5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCKcXgz/Qz+obnHc3rh76YoH /Z+7ngd8E9TgFTWc9XZxm1vIVt6d2xgZdq9aubE3znbWiZRqO2vbD3dDZkS/u7CenSPTZ2nLekk JbgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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(la= zy) RIP: 0010:tcp_syn_ack_timeout+0xd/0x30 Call Trace: 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 Kernel panic - not syncing: Fatal exception in interrupt Fixes: e472f88891ab ("bpf: tcp: Support arbitrary SYN Cookie.") Signed-off-by: Chris Mason [ Shorter comment. Commit message: how the issue was found, and its symptoms. ] Signed-off-by: Matthieu Baerts (NGI0) --- 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 =3D NULL; skb->destructor =3D NULL; =20 - 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 =3D NULL; } --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254179; b=sHiRVZTm6L5oMntl5RRirxz6NX5HYMBkK1qOiY7sfElFAo72Sdu29SYs2X9JypZ+4nEm xGF6B2pITCWgGUvwF6hshWW1rP2AyNWZCIWa0FXLpUGY+X3YDdLXZU39P5sV9tgMxXy5u +foVNL2rcT0z+qnVpac3HJUaWL3FR7mXydKUxLgd2sMBcbfrqrBBBjJu/wlv8ICyDL9yu LTjID2jv6tMKhavTNyvbI6vd5OmrCgu5O0ehSHGmRYHd0UjXFXjj4fZ2ZjaJGvU06p7nI Bf++rB8zN+69yO5Ktiea62e5Aot+F8oVhWl+s6bNuaI1FUKPmpOQEc/slHSoTwJkKEg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254179; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=3nozOWYPt0ZJfig0o0Xjewlw0ahJe0nGI2u2sVRmmdU=; b=rrfywwY9/Us0v1qtV6f/j+4nwf4gAgzar2juBsSGbYq6zoc504BEGbLOAm5OPorulIoi gybBez5OVXVqblexiaxvyMrhvZRfCd5Rgt8frLUm1a8dgWhOCpmLfcHBK3QoArT0Zy1+N xc0lP1HvAfy6YcjxmOTRGSku8LnMd7sFtpOOqoWG5qHCb/KusTqxY5foFX3/y7dfSCv+t apNcRblHJRnxqANcaPlOcXLHVYVimRB+fUd9b3aS20T55JyvH8pElKdhcgO7VPNFtsyIg qRHD1AudIID8M9tG5thIXIhrOxgsBkFu4UIpnPcIVVSczLVGRe2WX6AgMEU3L63K/Ag== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="c+Ytnq/z"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD714606A320 for ; Sat, 21 Nov 2026 09:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=c+Ytnq/z Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00CC31F000D2; Sat, 21 Nov 2026 09:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254179; bh=3nozOWYPt0ZJfig0o0Xjewlw0ahJe0nGI2u2sVRmmdU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=c+Ytnq/z79hx8HEZUvTHeiCo967zzfg+g3dv2y6z/PyesoP8CLd8f5I6IcARtYQbF TkAVkhlgblUQ1f0Z9G5DfLq8vPCH5GSSAXZLFb2/SDg0qr0PS2LN/E9yo92MiaMPh/ 9G7LdyQHSN4xads25HpqWZdpKUHQsj5D5THmzgRBjKuKy4B6ZWejkqaR3YcWjvsbSn Z8JpW3dePNqATyjjQGgiDIZka1nUkZbwfaUhlqkCqp9k/zbm++Exxov520CQAwzmyh irSnFp/tByoedspE6C8JGRlDbjeoxskOuV3ysdFkWnXer0c6k4jx4e+OkMKSjLTvwa xNcjx/JVwNG4A== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:44 +0100 Subject: [PATCH mptcp-net v2 46/62] mptcp: reclaim forward memory after coalescing skbs X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-46-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2957; i=matttbe@kernel.org; h=from:subject:message-id; bh=FmparkxhIMbiohGafjtjBYSkpw+HWVpI4C7QSx/bhV0=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ07OP7dgi5jP3ZgunYn30xSy1erXG73PMU/833/hxv uGDwuEVHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABOZLMrwz6h47qaw1ytUdkqq 3Za3drT/tHVFk+26ffXtPTcc31w+wcDI8CJg/+m6II4X8Z8nPf1xUZIp62RrcNdTjfzKDysDHT7 d4QIA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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=3Dstage1-1-connections tcp_mem_pages=3D7168 [...] msk_f=3D2944= 5248 [...] [...] OFOQueue=3D33000 OFOMerge=3D32862 [...] 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 [ 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) --- 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); =20 + /* release what is left of the borrowed 'from' truesize */ + sk_mem_reclaim(sk); + return true; } =20 @@ -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); } =20 static void mptcp_init_skb(struct sock *ssk, struct sk_buff *skb, int offs= et, --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254180; b=lFD5PTDCBKLP6knBJ+I9fUpO+B6bGD+gUf4hrWixvaixcPJGVE5pN3BSBCkwQBpcye+z mU6ELUYMUHGpmIG1I9y9TNlkcyb7zZQEn7cbQVXdw0lvCpVHF8XIOsirU7qtZCap/lQfh ossKnzg0suO2A04xEUzN2UHLuXCoTAOrE7yZGdu0LfuVO0PydDZ6r2N1w5kNV/UlP3OGE NMtUJ7cj32bSXMz/ip7tq0vmnXVfRV5w18pEsA3N6PF9HBAQn+TBX4+lLMIiL2zkvxHwk S494ODP4YUUCHmZZMWibQGW6COpI5NklEqkTEbi0+J7EiVWvuvVzKr//Chi68X2/AaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254180; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=7/HssDqYXm1u1Wsa6uTcQ5R6aXEkIN38D1UHL5H30uc=; b=ye7Swu1Zs8ch0SeDspaHHECE6U1wpbrMQHHQ6DL5VW2/1T593PvvMesP70vKr4bkFBx0 I48lXW+NfY0MDyicrv8SewurTuYBjUgbXk58CKRD9ihX7ZGehG9Wz7+ATcZ6bSZmdKu3D /hoFVQIMFRp40fW4QwK4ppuZq5Js9Bq/0jAAS9kS/w878NVRAH7E4sGr3ZhUMCc8jxTOI yRC4QCbW9LTjKAs47WX420zGebukIUOWsw53QMD6u04jdmo/NYmtWyGdzlJmnJBj6rYk7 dODAgEb+tmgrZ1xHUNJIMREWdJ6sg8SEmRPcYW1Ato3ULScp6E9hvME6kkzUV8oEowQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fB7nx8sO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA902606A320 for ; Sat, 21 Nov 2026 09:43:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fB7nx8sO Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECC381F000D2; Sat, 21 Nov 2026 09:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254180; bh=7/HssDqYXm1u1Wsa6uTcQ5R6aXEkIN38D1UHL5H30uc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=fB7nx8sOFFkbiUzSFFRnzFImG+fFhYse/JX/24JaXLiiK8nH9MH+sP/7TGagZgmd+ zZn+8L18hEmKYzts89JxnUZIgOfGDvkVgBeaEuP3+ehKtIxchmOwtuVR2j8V/BHHJF wEMHRZZDkkYzNebD8VDxUOgPQ7H7oZJeRlyg4Iaqsej633BC3bR/bsJEEPQymYR3VE ZNS0JgNKJmaRVztnhu6I0dnf4X0TmYF/9YWbN6b7cG/oIvrv5w07KMUyY0XaIPek0n WXPi7ilPAuCaYaiz/TKv6tPDQ6CqGpvJA+E8F/A270OSrT/vuWkjBaObFo1n/wbeBz bwdIqJSJ5R7Gg== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:45 +0100 Subject: [PATCH mptcp-net v2 47/62] mptcp: don't charge a shared page twice at accept() X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-47-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3722; i=matttbe@kernel.org; h=from:subject:message-id; bh=h52eSB0F+fnjFpvY/1FtzqfP4n1qIZI8hKG4iYA7i2w=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ03PYmG5O/PbMq8Glp/k02yRv45c3Hpy/vDva22dzB J9PrfyDjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIkkTWT4yTj9V5jhhxXPVotE xh25dmLmhxN99vKnxM6vddUXfSyzppeR4WtOlCLXvw2ljXyfshwufr6/TzZdw5LnMIuN+/cXWU6 /WAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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=3Dafter-1000 rounds=3D1000 sockets_left_in_srv=3D0 [...] c_soc= k=3D4096000 [...] SNAP label=3Dafter-5000 rounds=3D5000 sockets_left_in_srv=3D0 [...] c_soc= k=3D20480000 [...] 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 [ Shorter comment. Commit message: how the issue was found, and its symptoms. ] Signed-off-by: Matthieu Baerts (NGI0) --- 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 ba= cklog) return err; } =20 +/* 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 =3D mem + ssk->sk_forward_alloc + + atomic_read(&ssk->sk_rmem_alloc); + int amt =3D sk_mem_pages(new_mem) - sk_mem_pages(mem); + gfp_t gfp =3D 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 =3D mptcp_sk(sk); + int mem; =20 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); } =20 + /* What __inet_accept() just charged for the msk, before rounding up. */ + mem =3D sk->sk_forward_alloc + atomic_read(&sk->sk_rmem_alloc); + mptcp_for_each_subflow(msk, subflow) { struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); =20 @@ -4672,7 +4691,7 @@ static void mptcp_graft_subflows(struct sock *sk) goto unlock; =20 __mptcp_inherit_cgrp_data(sk, ssk); - __mptcp_inherit_memcg(sk, ssk, GFP_KERNEL); + mem =3D mptcp_charge_subflow(sk, ssk, mem); =20 unlock: release_sock(ssk); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254181; b=O35FNuzFBcNvLoqje078MIeBLqXzXRpNrHDeVpjVBl5dFRozPQYOGguLMGfC9Afz3vfV VqZSsCSMo9ugzFbEZ5YIVQpd+gJ8Cf8eSTizGRK9egJuWFx1UIiukafauf5okTKrJYlFO tbf6rJfWnXSpIO8jRH15OHCfTs4Ti/qO0V0yndLoF2mRUdfg+Uvsysx+meEMrDbmXI82I cLaXupA49FWDJjU/D1QFMwSHGzZnzJ5TNRLzn29ExVDX9UPw7ToMRTWSfRtNPq1TR3212 ECedAI02hdFJUq6LgfLPcWlbo2B1QDkLlJlUuiUAQe92LfhvCTBHDzo1BTYG9hqMAKA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254181; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=L1gvAJYNOqbRb4bvNcN6DGiZGp3u5no0S21usfmnpGk=; b=NAY4/g1HTKnGss0+vbfIR0XSCbKdjN/EAj8k69MEei2FV1FOwWfnSCBGWZ0kap4BaAYC 57zUG1qbB+OPN6uxCPY9NIHL6HCmfe/C6keytLcxpAPyonVpxn+WLKo8lXFuZeKWMe90Y RTY3mdBPPIjal4Z5Grpebs642u7Ue12TVmfHllTJLCo7gYneholavyIEnqoeMhs94A8Fl 8FVd2d7J4VG2aTsDn6Vp6X4GEtgdGW76WkdnEUiYt7PcVw7EocKHWisCtMUJMXm1DBFiV xWdqR0d48XfzmQnkdciTm5x9W9ad9JeVmiHvaoZ85DLYdJ31pya6VxCjJWa8uOmc2Sw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=izxvMkbs; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A334F606A320 for ; Sat, 21 Nov 2026 09:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=izxvMkbs Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8A6E1F000C4; Sat, 21 Nov 2026 09:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254181; bh=L1gvAJYNOqbRb4bvNcN6DGiZGp3u5no0S21usfmnpGk=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=izxvMkbswof5IgbyMZDgqqcmjbtq+8ltaAmgQpihEJolutEfctJvvVPMbpbVQ+vgs ZemfFOwBPkbvFiaNs/o2FBuulbC9tKzbuL0OjF1Z6btcdZn7rolqgKPHWt47Cjxn0N li3WmcHRGSeJT+HpfBiTNmbNHBOhK2/JWZJSj1cffAhcBLPE0JdKTWzTJ7t7nPje+M pTDtuuGML8QNxC2+RF43ulrSb65jwGcO29fV5HsbfIzQiaepueWKPvM75rvTytchR/ NcESFamFUxkm0/z2vFPBVgnsb9D1wQf04tit6S7dwa7fNoZNhWN0PnJkY64Z/heCEm W5+MLoDHuaEAA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:46 +0100 Subject: [PATCH mptcp-net v2 48/62] mptcp: don't charge the backlog twice at accept() X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-48-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5181; i=matttbe@kernel.org; h=from:subject:message-id; bh=Y6+xTjfUbeJYg+bBesSZxSAYvxzjy5tMgpZ5jslWtdg=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ03Mc0sUF5Nhq+jeHPRFazDjvesydy8dCfs6avKPr5 dw33/12dpSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAExk4SKGv1J//hS3cT9o5uKs mrZyxqUN5kdD5l6Z/N/Do7licYrvs5UM/6tXTJ+wW3rKvAJXjtTt299PmRZUmXPcQ79vQ5rMtFc vbfkA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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=3Dafter-100000 rounds=3D100000 sockets_left_in_srv=3D0 tcp_mem= _pages=3D0 [...] c_sock=3D63295488 [...] [...] SNAP label=3Dc-removed rounds=3D100000 sockets_left_in_srv=3D0 tcp_mem_pa= ges=3D0 c=3Dremoved [...] p_sock=3D63295488 [...] 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=3Dafter-50 rounds=3D50 sockets_left_in_srv=3D0 tcp_mem_pages= =3D256 [...] c_sock=3D12881920 [...] Fixes: 6228efe0cc01 ("mptcp: leverage the backlog for RX packet processing") Link: https://lore.kernel.org/all/20260924080219.1036588-4-caixinchen1@huaw= ei.com/ [1] Signed-off-by: Chris Mason [ 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) --- 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, =20 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 +=3D delta; } =20 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 =3D mptcp_sk(sk); =20 - /* 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; =20 @@ -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 =3D GFP_KERNEL | __GFP_NOFAIL; - int amt; - - /* Account the backlog memory; prior accept() is aware of - * fwd and rmem only. - */ - mptcp_data_lock(sk); - amt =3D 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 =3D 0; - mptcp_data_unlock(sk); - - if (amt) - mem_cgroup_sk_charge(sk, amt, gfp); - } } =20 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 { =20 struct list_head backlog_list; /* protected by the data lock */ u32 backlog_len; - u32 backlog_unaccounted; }; =20 #define mptcp_data_lock(sk) spin_lock_bh(&(sk)->sk_lock.slock) --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254182; b=aV4TP/xOOKNQ///fS00Y9y2xXwQSx3YEu3cnPnUFZ1MC922CoSj2ILf36STu3Zq2e0iJ KK1Bp6fpOVYELCqNZbtQF9VFw3MykgO1IisAWfVHrgkJs1Jm+/bxdimPWB/QvBmDH9aAp QHbfSElI24vdzmGSIjI+sPPgLSV4HKKKGfYkMQmaxu1TWHJrlkq31zoq6fL/lLuSxMFwM TBz9kX0j/Ti3xffVf7SvvtoCy7HVOsj71nbxcpMflr+osqLXkHw7qdUoE05h8+Oglz5bY 7b+dG1aRuQ/XFwSwM8SL6GtucnUjQfZ7hVO5mEWTwztB53m5N0G2oDaveFsjrqt0n5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254182; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=ia1DWgqWy0P2JKk9je9n1B4CFCgpK4MUxLPC6PKr19c=; b=4Nkt7iRS+B+BSPDo2VjsuDq0zV0k8YV1WWKTB7WImF5mT5ETTY5/8GT2vbCgk3/T4kZJ yTOJvPe9AEeyJHywistxTG9B9zWCQYf891eQmCMom+2ZTvC3i60mEJTJ+Hb/bz/+OeQ6g EVrfbaRcsxE8M5frtYYCJD+vyUpF1YDSpkowtTHG1LPuGZ6m2HYjmr1/j+y9GPPNtHzEb 7io6qCPrZR1ba2kZe/AdQkDO5uavsGXrJagW9HYlqXs3hUgDnjp2qwQz8X3u8W3FIESSy VLrdAqFIYBLFRnLOyegOuNZE7cbo9eifRSZ0renvHwo042k0xByWbQEG5BRjbzjewGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=X07U3eWG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76B93606A320 for ; Sat, 21 Nov 2026 09:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=X07U3eWG Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0C7C1F000C0; Sat, 21 Nov 2026 09:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254182; bh=ia1DWgqWy0P2JKk9je9n1B4CFCgpK4MUxLPC6PKr19c=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=X07U3eWGWV0svxA9Vjocz8Hx8wec2DS5UxX09140SRoOnoVvos/lW1SHNXeYYjNHv yyqxCIGXIXvYnW0dCqiWPfo0Pn9Cxu62xJyY1xyvaZCmbKfA5RRzueedTtcy2otZRS UP2auyMSfmkf5dsuLH5W6DFvnH0c9FbGyWw7SxvbUuVcaynPJf0gkloGF5ydTA07oA IsqvFdoEX88ZBELaj12U1/WW2i74Yk9sIPs4qs6oPSndf7ooeKoraR2/sT9mm1dvFP n7eNDyOuwa8q6EAsJUWqOIUDEGJUeGvuxpuAUAVxO/2tb+zqj2OU+XhODAj18ViUbf mkVUvLuMXoq1w== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:47 +0100 Subject: [PATCH mptcp-net v2 49/62] mptcp: don't charge a subflow twice when it joins during accept() X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-49-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3140; i=matttbe@kernel.org; h=from:subject:message-id; bh=5AP99MUQejesCJErjrK2RKdoKAWEdYHHwBLGL5uDdc8=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ03Mlwo4a2vP+PtqT1fHo6M7Q16v/MdkeXL92nf49g ahn5ZZWHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABOZ+YXhF/PRb1c9t804NTvn hVpOzo1nr5Vm6e08Pz1PTmpq89y2j88ZGe5+PbCwyKjfvvTRr+/TD9ne7bvaVzH3V++00mPx917 1qLMDAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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) =20 /* 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); =20 - 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; =20 __mptcp_inherit_cgrp_data(sk, ssk); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254183; b=E0JH5YFWGA+fIIIHXq0T1ayUJsHvlhclrD9V/0Jx/3cCkoPtQ05Gv7y8FGhbnNk0zF8c iF4fSsz1rC7aM1Wn/FZvIJoW7u508zFq9jKFOI2Jy/4B2bQMnhdEY+wiW24znlwha+aDA exDUkdpUklcy8T/nv4zhaVY+LDOY20WpDjaiE6BXb0KyTVobcAsLbtikcRDHyftbN2pRv Gi49eCKg45bMB4FuWRxoctaCXivk9+gsUmigSewKErbUEFbrao9fbBKyO/SM7Lz9+CxM+ WigCY2MwdX6gijZ7+KGauSWzEKLezaCcp9d7SS+AO15HE20FgmmntblNzJ6pcQ6onNg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254183; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=vAQGhJrCV5IG3lvwme56F6NxYM2qgvwa3eHcPNT3CQE=; b=Pbl7Lp/y5NgQjYIFV5+YBDS62NYEWcdQ76jRzhrDSgBBRdft8PzLfFFxkSoIuKvZyhCi eAJxBsZyg1rgNU2lB+RnwonwsV8hN2Eoj5gVB4eD+AZdCXWwKdjf31r9s94BEaLuiiNcx wT9+GOb/4sc90qLKC5k7okw6cNUW/50GDNL+1yFDasrUqeHUIW/8zwe5WK1W4p6M5klUX pf6aihiefSQk1Akm3ycASnN6qtU0nMZYWCB/MMx7bK4o0hrvlWuDN4gflllV0SNmJvGhe kR4XLfbDjl/VowYMvLUwQVsYNMDdS2kz4cnoCsAJO25OThl51i+hJKY36CGCZFy34jA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PnMH8LGd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B24B8606A320 for ; Sat, 21 Nov 2026 09:43:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PnMH8LGd Received: by smtp.kernel.org (Postfix) with ESMTPSA id B45541F000C0; Sat, 21 Nov 2026 09:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254183; bh=vAQGhJrCV5IG3lvwme56F6NxYM2qgvwa3eHcPNT3CQE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=PnMH8LGdCPRrapY48JGVHCAMu5lUjnTVwKUJt+txccqNiqBHm+C04tttqmoECQx92 1bv+g1UC+ZG7Myu0hHA0knOPMRZWdhL1PEjGgfSjDTUWrQ2G6tuwtl9AHrP1p6ILOl jVZsKZWDsOXbf+2SWIrZ3+UuRavZFffKWzQMZ22+4oIy9dUCXQY7RiabmOBxPUnIni XYblEI45VCFCppCwk2aGXCokEk7GT528buflR40Mn+UGZZdtDLQttPjjHNm3v2blwX c3IQfNmlSCRAfSNRwABCjrUKqPq2dwZMe6H7zxdkwH7Wcj03GBeZSUDKjAlREYUtcu qE2vBVOVVzitg== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:48 +0100 Subject: [PATCH mptcp-net v2 50/62] mptcp: continue the last mapping after a fallback X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-50-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=7426; i=matttbe@kernel.org; h=from:subject:message-id; bh=/U6+Z5USACg0YDqahTDOT7x5LuI+zo6AQQvC/eBvMaQ=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0/OUfaLLuJde3jJt1uvrux0fWjWuVL/NuSDvTs/xE ymvWu1VO0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACbiK8bwh/N8brzDg+QPs7SD iq2yFKf93xqw66nWMlOXF9dDw2wOVjH8FTk70Ws/c/BGkds8Pld3sm1eZdvAfmxjzbLrkuzHisr uMwIA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason 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 2= 670592 of 8388608 [...] [...] end: hang: no data and no end of file for 20 s RESULT [...] R: DssFallback=3D1 [...] OFOQueue=3D204 NoDSSInWindow=3D145 = [...] And with the Packetdrill test: dss_fallback_after_probe_server.pkt:25: runtime error in read call: Expec= ted result 2000 but got 1000 with errno 22 (Invalid argument) Fixes: 2834f8edd74d ("mptcp: cleanup fallback dummy mapping generation") Signed-off-by: Chris Mason [ 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) --- 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 *s= sk, int fb_mib) =20 msk =3D mptcp_sk(sk); =20 + /* 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 *m= sk, =20 /* for fallback's sake */ subflow->map_seq =3D subflow->iasn; + subflow->dsn_base =3D subflow->iasn; + subflow->dsn_end =3D subflow->iasn; =20 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 *ms= k, struct sock *ssk) return true; } =20 +/* 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 =3D subflow->map_seq + subflow->map_data_len; + + subflow->dsn_base =3D subflow->map_seq - subflow->map_subflow_seq + 1; + subflow->map_old =3D before(end, subflow->dsn_end); + if (!subflow->map_old) + subflow->dsn_end =3D end; +} + static bool subflow_check_data_avail(struct sock *ssk) { struct mptcp_subflow_context *subflow =3D 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; =20 + subflow_update_dsn_base(subflow); + old_ack =3D READ_ONCE(msk->ack_seq); ack_seq =3D mptcp_subflow_get_mapped_dsn(subflow); pr_debug("msk ack_seq=3D%llx subflow ack_seq=3D%llx\n", old_ack, @@ -1501,6 +1516,7 @@ static bool subflow_check_data_avail(struct sock *ssk) subflow->reset_reason =3D 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 =3D skb->len; subflow->map_subflow_seq =3D TCP_SKB_CB(skb)->seq - subflow->ssn_offset; subflow->map_seq =3D __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; } --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254184; b=T4OtO9pxas9ZuF1Bj+fFGAzEcML6AliZJw3WnD50zPvaOTCfL2PYUZNuaVG9vqS0N5ll 5WTn7RFp3lpVI6YO0lxqcKBrddkkOr479iYO60zNm1Z9RH/2W2oPr6jETyn0uL43DSSID gOtN8g/SBx2VHWQ38imZfarz9NQO7llHns0cILO+N3vLhbfJ+x4fKLVVGqfRn9hjqxucV 7vZS1uacDGzma3FF5OYjfioV686F5dzefEXjp3ZvCLyalGCami9q+S1sjl5lXo4j+JeM8 JrDtuplmzQ+4bx/kBzWvbY6KbeGSkytJltxye2OW6fkcfhSFiv1g/3MswTGIcOyXkpw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254184; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=LV8KRQP6HGlpp4MHS+udQcFpOfdFxrAxkEL4pL+12Zc=; b=T8Zo5NH06TxZ5ZztqPGeyG1FNanvHK14PWWjs15y+lDSFb+0pl/rKX1D3jc/Ki0xfuzb LNN7hH9rg8s6rv5bay6jWw/d31NMfq9EogQNS1p0HAVfIdWk6r310BddpKP46b83TF6zb TAVbqqZkqBxvjW5gk5dW0RYAPjZY0GroMTYg3IBYdWTbj5DbEC97i/JZXySp9YSdA/nBP BQL5jrmTZxCwhUBhU2lAQd0g8nmrZUtp0/nKoWl/GvMsdHB38WXW7nlS1u1B5P8/RXDoz GiFN236tHCAwUpn6unYPUOpx+cMrt2VZXB60gtgf2BDpMBE6RyitXaE+emPSBbF90mw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=W+is8cZl; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F56C606A320 for ; Sat, 21 Nov 2026 09:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=W+is8cZl Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABBB21F000C6; Sat, 21 Nov 2026 09:43:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254184; bh=LV8KRQP6HGlpp4MHS+udQcFpOfdFxrAxkEL4pL+12Zc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=W+is8cZlziFmWrt+/UZyIBrpGydJZLC528myMsmf26a4GwwJ9zCXaf+C1YPK7sDV7 sG746UrQqZ9JzSsI2bzr9Ac4+/ZP7MqVVFKvtryQ2Uw7JVRkoWJOxIoCe7jjveV2vm QQ+PjWNSHh9ClHUtHD3W+CTYDXR9Rl3t11jzkVDpj0s/v2l1ZuPa/WQNk+PgCLti60 GnZIbia8Oey31Uc8rUUZSxXVuNKKvmFyNkPa2H2rEqu97k455/0i0Z3GxK0KAZ5m0t IONhTrJURaEFbtFSY+O2o6pvWMnUiCFTwcyMXjB5dGRLbWUCIJKMn/oD++idV2LISI XJoNl3I/kbsDQ== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:49 +0100 Subject: [PATCH mptcp-net v2 51/62] mptcp: keep the first byte after a simult connect X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-51-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2577; i=matttbe@kernel.org; h=from:subject:message-id; bh=XX2gdrmjZ78yWy8Y5Iz+qk6/TDt3hK4TAf4G+2wKbhM=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0/PPrXF6ffKN8Gn/boP636dVU+7pnlAM/pp6Wzc4Z LvB6UNPOkpZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACbSdYnhf0DOa2H1eX5/nX6l 2KyPLd7vVRsRvWTK24/+j227j7w/8IyRYd489Q3+AsV7ew/+td+icO7i57nvtd9IeKr8ZJYLX6X wgx8A X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 1= 0 but got 9 with errno 115 (Operation now in progress) Fixes: 2834f8edd74d ("mptcp: cleanup fallback dummy mapping generation") Signed-off-by: Matthieu Baerts (NGI0) --- 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 s= k_buff *skb, * in mptcp_established_options_mp() */ subflow->snd_isn =3D TCP_SKB_CB(skb)->end_seq; + + /* simult connect: the peer's SYN-ACK will not set ssn_offset */ + if (unlikely(sk->sk_state =3D=3D TCP_SYN_RECV)) + subflow->ssn_offset =3D 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, con= st struct sk_buff *skb) subflow->rel_write_seq =3D 1; subflow->opt_ack_seq =3D tcp_sk(sk)->snd_una; subflow->conn_finished =3D 1; - subflow->ssn_offset =3D 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 =3D TCP_SKB_CB(skb)->seq; pr_debug("subflow=3D%p synack seq=3D%x\n", subflow, subflow->ssn_offset); =20 mptcp_get_options(skb, &mp_opt); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254185; b=R/UoM9fIA3o3fLPAmaUN8KSVz2U4xtlTYfh4JNXpCBnmVJUjVoFGw/gSv5MgVEMswpaZ 6lXhCcY6YlbJuc7SXcc5lruRufbRLu1A25yASOICYmseXN7xAQlEOE1q8dlVQhasIFzEj J8qhxt2vicpK2o5a79UrLk/rz6nPqMJa+rVMaQuI8AfaMvWqVxFoezjAIjq54r+cdn2WU Jdku/zDB+vTfpm9O+TnIUlkcAfyELpDmIHkkVd0vraHISI7CSBrS28a9p0BO/KhnAifxy 7OMcf/WkbdvK2GtbC6xRGeBN6UFAa/UTp+TJdyVXKGk4AWvW3Ydgf6tUiZ7eWuyFSHw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254185; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=zpWZlPBVCiZU4Klq+EK3McXXNHdBJVntksVc1z32c/I=; b=eAnNqVT4s1Gy8YW8yV4qyGioG+gmlmLStSBsfpkvs2bXcHOxIIMlcWJ/8JzmnJLWtT2S CvlbH3zPmeIUpaV1Pa/w2IrhpDl0w27j9JLRb1QiHGXr7zckt0kDrQ5zb/hcJ1ZYd6R8p TquhBxDQ51MMJYk6YakMPNoXKfw1dU5W13yO1UbFdC50urrfNwqDVHf1lYcsFYrwxXXV4 zG6o94Ab5msoAekff2brvZFpYIMtNwlrUey2HApJxs6haP+jcAeDAd5ONG84JefduttDs Ea70i3LTeKWhOPkmbMYcHCIYa29xeo6dnLnkolh1KosHv/OCy2dpCv6fcFK21z8aVzQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hcx3dbRy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12138606A320 for ; Sat, 21 Nov 2026 09:43:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hcx3dbRy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D4B11F000C0; Sat, 21 Nov 2026 09:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254184; bh=zpWZlPBVCiZU4Klq+EK3McXXNHdBJVntksVc1z32c/I=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=hcx3dbRySmkCLPqNTbAfZP8SeEcc+Ojdh/z1CMCabamOWrgDMDzHs/vKzYFfX69Z5 hTIeA0ez2tKk0DlI0MNK5/HdBRwuKUWQUrxkO9u5Z6/aeytXfsozVCZ+HQgPp+1rLw gXPcI4hn3Tknl8wzVjhKlxzUP2j70nw2EwMjhdMdtr7w6FHIWc90fP+q+rAALB3rvh jnh8gsmphHS8HsJD4qn1BrZZ0mteCP4rQ3Lb9Ci1zVLa+5bBoHmHwg3Nqn66v6GtlC r5okBSMNq3SyEJoRJgbZQrYy7Xg+xlcBlQFeB7wEtO0/WzW6fb5J5Tgvu12noHpBrg +GbvD0cK/Z6nA== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:50 +0100 Subject: [PATCH mptcp-net v2 52/62] mptcp: move to ESTABLISHED after a simult connect X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-52-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2019; i=matttbe@kernel.org; h=from:subject:message-id; bh=iusAQCSS1866tArMKq+LjT4eCh7/WIKvzRA5dM8TJuQ=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0/N/TBQsnhSi78i39/+Ci9Zs3xR2C6Yvf2RzpOyu2 9o9WVsFOkpZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACZixM3I8G5Bin1RIO+RLpNr ujO2VBpInjZ482VKqcHRINf560VCBRn+CqvalUfz7zh1jYOrZ1PXI8fQ71XR4Uo8jVnTVuRJ7t7 MDAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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) =20 __subflow_state_change(sk); =20 + /* simult connect: not finished by subflow_finish_connect() */ + if (unlikely(!subflow->conn_finished && + sk->sk_state =3D=3D TCP_ESTABLISHED && + inet_sk_state_load(parent) =3D=3D TCP_SYN_SENT && + mptcp_check_fallback(sk))) { + subflow->rel_write_seq =3D 1; + subflow->conn_finished =3D 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. --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254185; b=kzD6OHDyb+q3ROyJwynT+iNib9mYt1c7vL5EedQERyBYBpEAeHTXzPptena6Q8PvcSan B3ZDilczW+bJd1L38PezkWMctAro4z4LqNA2ij84/NAWZwJKlIBLpWdl0p07KS5GiyOOj djDr2n0Wn9nJZGXC6fDFWPFE8QlaDNaOow3c/HUYkufdQS6krPxXk8W7EzvAUJOtLdDHy W77Ui3WxJ9+1N2MY1oFuN2MIpWvI/qfkzAy7bETsWoKSq71U71/vHvTkrnJfOGiNNqKsR W989pmAXZ3iV4MbVTq2nAR0so0USovnrvtHQn9IqY9XbgU2aFbMqI65HYGiBdxy1RSw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254185; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=ICaS5+YxPgQV8dwy5z8oXcjW+VDvA+reJ8VlzvMMR0g=; b=Qf1xSW7ESvy1KfFBTEu8UT8T55SvHDnJn7tjt8R5kmjoFcvIZYNX70+iHOBGyj3uXU2/ scboD65PCR38/0cR4cmDcETp94y094sS4TACvFgU9bpKJqWoVk2Uan+uBUnLVq4gNBq+E +R+KPGaZ0pGi5xie2pnr22+G5wSRoZl6T+cNUXai8nnphhebfzlSvBdb3JGasCOmXl9sW OSXaGjgJ5cLiS5iUzq07ccF09RmMoeKhqFmxb4TU5xQwTqcMaxa5OlaVLSRYrRyBq8SJt PwIN7N4vbIE5hcGLwsBFEo/ZIctfXydmae7Y7hcuqxJQZQ5yziXvBABqOu6PxAZcZgQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="LghaA8Z/"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7B56606A320 for ; Sat, 21 Nov 2026 09:43:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LghaA8Z/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F38F1F000C0; Sat, 21 Nov 2026 09:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254185; bh=ICaS5+YxPgQV8dwy5z8oXcjW+VDvA+reJ8VlzvMMR0g=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=LghaA8Z/1BU1yBIz8ysD/Lc+Fe4oMboKoFtwOB4zqhUXMc6gH18pvEVQLuIyL0rhB DwVaaKUwBpPTjnOtfZ+ZroTTHOsA352VkxSCyBZpVCNCknEyYbCILOgLfv1Kwkd51D nH852oahUPc2omA/vpZMwrE03Gid1GGszxXfXFR0AtInlcUYVL/EOX4qNgpsj4BYv3 zikEdGrrmrvvZYoDAWs9FlREPFvxQK2yEG5lz5WkB/HblO+h39NGzFv/gCXfpk1JDB 2tZW9PBWGFIdnYppxoqZZhwrlhq2JgrAF6Ged/Bo3ZHcBQrAbHDPK4sHorIoeGX8TQ Iv8DnQXwh2OBg== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:51 +0100 Subject: [PATCH mptcp-net v2 53/62] mptcp: fix MSG_PEEK after a partly peeked skb X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-53-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2025; i=matttbe@kernel.org; h=from:subject:message-id; bh=DnNuMfA8Exbbkwg7ajpZlzt9BDKt/Wl7UevOR8rW70M=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0wtYO9mfPX37jc/vgG2bBeveX8rqbFm5N4+5rBQT/ bH6z1urjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIkwRTIyHHHZ9s64j7V/ttqu 3Ve//LO/EPnGTbFae+Xiyc8WvDgdN5Hhf9osp/br1zM0ts77xbrv0oxpq55usef/Mcntx/b2RX3 Jr9kA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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, stru= ct msghdr *msg, delta =3D copied_total - total_data_len; offset +=3D delta; data_len -=3D delta; + total_data_len +=3D delta; } =20 count =3D min_t(size_t, len - copied, data_len); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254186; b=CLyvQd3XO4QWW12SywaXCtHYmUkmjQk/C0k/wOIpQwroHnDxSFjzIqtMcvAS1xK74bbt MSJ9K7f/9kZuDmRtZcm7uf2OHsZvrnFfOHfsJYHRNWGkGD296EPD1Hi812Ta9pHOvn5vs kAeWvVaZireKcr0tMZwFGc3gjxSzh4AHvxHyj17jAfBD15eydHBQDS5N/gZeR+QrgNLWD OrsBc0Oe+UbwDjgapo/lxJ2kmgLhw3VvEUfkxJvIcm+22EtUvYqMB18GL/yKpu6o3uvHk B1GXmTSqPh5b6zIYoRqdcueJ2gvjTkyolwrDnaEBZj2dldDfhHP0Ad8bPkUY0Jc1OXA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254186; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=YeBVQTlULxZ+VysUsWpzZV8IcgJjGInxQK4cTxrei0k=; b=kSQFahjheBxOmlS/c1s9irOTwWiPMW8CsH0vgs7a8ULxrC1w8nxL37WS3zaYkhV/3XwU 3hPybCaK9G32G5qDunLmOiB+VlKkTYe3lLFAejdjrlCm4bjR7UTSlyYWOr+VzwEnPVyi3 cVM/xjv4XPESA1aFxA3fY4JUiRwcYGgH1wVnD7tlATFQeyUuMsuYObHlbz6Rl83G6V0d2 tW6E2CrNsM92sx5+EJi7190ekmhGkrLrxgTLiARg0Kf0gUKbFGrCes0nZ+QUH8q2MkH/L uX3OFu1A/xSD6sO6O56fngoY1Dm+/fCHNJbRirWiu0JCTjVreKwdAc10rKOW+fX3sYw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=o055SqLp; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA4D6606A320 for ; Sat, 21 Nov 2026 09:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=o055SqLp Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20DFA1F000C0; Sat, 21 Nov 2026 09:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254186; bh=YeBVQTlULxZ+VysUsWpzZV8IcgJjGInxQK4cTxrei0k=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=o055SqLp3lo0eEqp5+DU3nCWyVpZHBqjGP3rIUGjWRU9IuSXElfPx3KiKnjgLC6lB R36leGfdszSazEcjINCJslps+O+BJ1L+51WzOX9uiqUDBVYZ8sqXVml8/H25FQhA7v N1ddD9VQnjyMpV2mbucqU2p2Ez+gkeReghgOUXsp3S3TNu94yAn/yHEIC6xCrv+ab8 UiAB3//QoyJSpcH3dD670QTuAWLRfFKSBRwlY/Y25n+JUgOc8HoFK/XSCIxo1NXUa7 kLJc625ViKftfuFco5u/sRFQFbIJma2Fd2AOAxe0MGqhjXXso28K1s9KuJ7xw3B4zG t5OshqaDAsajw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:52 +0100 Subject: [PATCH mptcp-net v2 54/62] mptcp: send the DATA_ACK after moving the backlog X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-54-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3482; i=matttbe@kernel.org; h=from:subject:message-id; bh=AOaeVHbFI86p0bDj0vPuzhKg/u2uir41AnqgxAVQsro=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ0ws5uB9xPStTFYlKau8y6X5SuG+Z6qcn9bdOG+3YW tTDKO3cUcrCIMbFICumyCLdFpk/83kVb4mXnwXMHFYmkCEMXJwCMBGpVIb/0Z1XRZ6ypNwyTP50 b97LZNck/s+9+7Kr3W4Y64uYPMr7x/CLWfRVdOdDp/Zl7B1hd389OZfvP4tp7c3llWyL2n3WXjr DBgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 p= rotection") Signed-off-by: Matthieu Baerts (NGI0) --- 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_soc= k *msk, int copied) msk->rcvq_space.time =3D mstamp; } =20 +/* 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 =3D 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 =3D list_first_entry(skbs, struct sk_buff, list); struct mptcp_sock *msk =3D mptcp_sk(sk); + struct sock *ssk =3D NULL; bool moved =3D false; =20 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 +=3D skb->truesize; =20 + /* NULL if the subflow has been closed */ + if (skb->sk) + ssk =3D skb->sk; moved |=3D __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; =20 + 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); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254187; b=bGK3+OtrdWDTMJ8OLl3KZtNCqsP8iZGkyydFoFWEBH53Y8MElz7HoaKCj1Z2jDIOLez2 NIUoGGbX1uxiXUwAtPtVrw2Lgom8SxzfRzWvMv7UJg+ieb2nMYq+eCXpTcN3h5sht6SXo gUy5JAeRvrDZxc8xC5WpbtWFitSSt3eQwA1j9YHlRABdKqObPg85z1sPK+jitLMqYryX7 6lgPMh0/C1TMOg6yQmdob4rqY7BhkGzrkiyUbmKS1iwqjhQAVnwtGZtncoTG/5+zQBFZv psrn+xyCPUiSu7I9+OSEgI8Lr6BSt3HrUe/Rtv+PM563Oo6I/cPsBdAnSwHpJ8ge0rQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254187; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=0A0xyfSATAln0Q+Deiz0cCQvaovCf99nMyyZVnsqkw8=; b=NJMAY8LN75lGBtTaPMMqx1IW9TaXMiDuLNo78xPV7QtJ7d9D/fDvmUK81t+xEfuaZTYd wzDqTHTQWVgZrwrXk6YS7g0lfxN4UqkN1kFe/uYX4Pf4JNIW0tIX7PVs8f5BWoHhnX5o5 xdaIQ6Naf84O8jwTy3/pTbL2Fhqo1MPfhKie1wALNCna5GwpHjApRMb1uNglg59YLu4Yw j81WL0KBKv3EKFu+VYTNr8CADiSn0kBNIVVOpmIVo7rVSJ9KTN7YrgOy6dB4euOARMRQp jf0t5ouqwdEClRb1xjyDeOvYN06d1Zh0ZblhzaLwl7lSLMEnj3ROwQKL8MDG5QufeAA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hE5f4v5W; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B8EE606A320 for ; Sat, 21 Nov 2026 09:43:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hE5f4v5W Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6B891F000C0; Sat, 21 Nov 2026 09:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254187; bh=0A0xyfSATAln0Q+Deiz0cCQvaovCf99nMyyZVnsqkw8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=hE5f4v5WN2DsTyCM5sxmjiC2t5xI/Q9qa6S2ECiSOgOrVsfYIDgZlOHcW60gQi9I+ G/z03zfSfbw8dlNV1hg7IJ+SMrjVMhMXkzrfkvVUQsgHzYT4qAaqsFDC2ckaD37bJ1 YSaWXzg9mW8AUkLKtjHvXkut0eoCAVwulAPMN1B5CniQ3FHbDFHzSG8Mgz3YLOFP+w HW5+QRcu7cBly8l/7RVbxwF/fxnL8rakOb773LjQtuQhz6a90Pkm1yJLEgFMxvY3C3 4OHj14ec99PAhZCKb9bHm0mRJfI+vH8M1GZtWUa0LckEs1Suke2+Qt9D9GYctK7bur sTWBOPdrmGCjw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:53 +0100 Subject: [PATCH mptcp-net v2 55/62] selftests: mptcp: join: infinite map: no spurious rtx X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-55-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3144; i=matttbe@kernel.org; h=from:subject:message-id; bh=24pzTk9FT5cN/9FozCylpHkdx1ESVFmi0SmeT9jC2YU=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ04uu7PPZtpT7p82ZL4mqnTqB94t3P3DTny3UsFV3Y 0b/PwXOjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIkICTIyTOuuV1YSsur42OD+ 7NTTrCfNjouV2lz+1JyrL3y+9+ftFEaG38J/ffy3e1/sKyvbH13T4p7GuWc329MbTvk/EjirJ31 hAQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 115919130101= 1008422 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 1159191301011= 008422 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) --- 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/testin= g/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=3D1 + # 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=3D1000000 \ + 2>/dev/null || true + ip netns exec $ns2 sysctl -q net.ipv4.tcp_rto_min_us=3D1000000 \ + 2>/dev/null || true test_linkfail=3D128 \ run_tests $ns1 $ns2 10.0.1.1 join_csum_ns1=3D+1 join_csum_ns2=3D+0 \ --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254188; b=TRoQMs7kzuCQ7lx1FzbcNtrlTefGXFCTVbx/ClBMvQfaA8jufifju+N96TSjbwWM3tkI ef6TGZmgjccgQI2oyYm4egZvrxkPCyt9QWPXfPSMVGl3rF+q9h91qBUSXXOKgs53O7Q/r /6D/jTEmNyXgEXVWsrCDLhYqzFtbqNjfXZ3qQ68JD2/5C7pYZ4Jwsb4Qert3QTjvOAIcL uk1eNGLY8FqpQdBhUb3iJXnXJGp7AxVl7MbQmJ4nveaESZChlkGqVBcHDrdeInLsJomqc RcqViZIY4R5LXJBsPSWHWrKuvO7uOnQlZVxP/y1GAANJK+V4b22vMrQ/PakeiJTlFpA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254188; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=PEZwwhiUvCNmEuUcG+vzYmc9W2vxSlt/Vn/YGDhEMBY=; b=I3enKfPvYV4pXbi0jq7FNuNwvZQqysOXDWsn1oDTO9Q0a9ax2t4ry/KhRAC4skG2uDjP amjiddfzIDxpeoPHqrbKtJdYPfYnNNMkg26fXSucs6bDSqIxV5sPPM3yoPVM5sAVs2WBT WrcQYL+uT01fx8ghOy6IBpOpnw4i2G0uApl6sZuXpTyYqCMJaDluieXDrImPEEsrZSUMI /4F+LoFip78m1ZZyadtARyytnh+jWjuVNZC9MIXEzM7x+d3fl+0aDxQZYQOb89at6p7pm kdHgUk4Yw/EX1GBmdOMPp0mp7oaNSh4jV7aAxNiH8PM7Y8kHaezZaPwUIBI5rN4WC1A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TIT0qrfB; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D85F606A320 for ; Sat, 21 Nov 2026 09:43:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TIT0qrfB Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8A7A1F000C0; Sat, 21 Nov 2026 09:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254188; bh=PEZwwhiUvCNmEuUcG+vzYmc9W2vxSlt/Vn/YGDhEMBY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=TIT0qrfBzvF4uOUc/0ytRZ43eXJWZL9tVbLU+5N+rA+Tx+jwzRQhqfyqmakNog2yC PfK+h2HxFUX+4vHKQl3QS8eGksy9GOSF5/rsG1BL5Zu+2h4fQf4kfGnN5Al6gxzcaZ 3zzaLIuHcKncAa/W3sUV8RMDnLYIlvSKgPbUAmcqtlAKF+Ai3wqM+p1hgGbQCB9zLy BnnYPOsVMn7nc5587QnqYm9Fgr85a+xaev3gczF4cuMfb9lD5zRGveDJ24iqlZr97i 4qaSpuu5Pb15npJH+hjqDAQIE2nsRciwwYo99XOyeNdiTdVNyFp+VhM5gaeCFf7Pu4 TWNBzvatWJHXw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:54 +0100 Subject: [PATCH mptcp-net v2 56/62] selftests: mptcp: connect: trunc: wait for acks X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-56-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2970; i=matttbe@kernel.org; h=from:subject:message-id; bh=0RLcJEopSMRfxvOzmTtDqRvHPeGB9K5sSrOYzXnOaes=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ04sOBmqvYqjk/RxsNNnufjH/p6Sa+S5b+e+euLWjy q1Xrk6to5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCIl2xj+inzrkLj4Ler2Tu0+ w0dGEyeanFsx+RJX1fZVDBWeWVOLkxj+qbg2TdxcPl3T5IlIlIl/650d2p9yw07alD/r5ZHKn13 HBgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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-ca= ses") Signed-off-by: Matthieu Baerts (NGI0) --- 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/test= ing/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); } =20 +/* the data still queued would be dropped by a reset: wait for its ack */ +static void wait_for_ack(int fd) +{ + struct pollfd pfd =3D { .fd =3D fd }; + int i, queued; + + for (i =3D 0; poll_timeout < 0 || i < poll_timeout; i +=3D 10) { + if (quit || ioctl(fd, SIOCOUTQ, &queued) < 0 || queued <=3D 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 ou= tfd, } =20 if (cfg_truncate > 0 && total_wlen >=3D cfg_truncate && - total_rlen >=3D cfg_truncate) + total_rlen >=3D cfg_truncate) { + wait_for_ack(peerfd); break; + } } =20 /* leave some time for late join/announce */ --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254189; b=FpqEuRiBGIl8GdqBqD+PBG9+GHp86EoOaD7VYpxIiUOn8/pMrbkMiQaxCnjWMQfSIvQd cO+yTWJFftC5koPEIMtQmzbNHmaKgR+Sktd/Gr0rWHHNNO6w9rXmKzIOIU2m0cTOQtAHs Mkl6IYE3757hmARmwvJxKbfBLn0SBcIYUCi/2fzLUVS/Oaf7MQG5tc4Jy/P8AmCAmsQtf TKHlDS92Oophs/gA8U+5W9P9gaEatkLxPOt5bR7ktJRasAiHdwRr6QCCjj5y8CKYanMTO pzgTM4CjmU7yK5k+4kvoFsmb9daaH7IrM5nfwC27jR2w+LYtwTf6Bcs5QOdGZkDXt2A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254189; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=4UuzmxKgvHlfJkZ2GKl/zYApxcrbpPRELOpRuxCkj24=; b=IWy34ZquoNyYHIj9ngUY9TIWNqwMkb2bXFwl2/ZGVlyJfLb9Nx6/iG2JsLToo4wTzjF0 wNEjO7BSCV95yX/6ZqZLmxaMfzhwTTmWqL+FDiZF6+e0Ucj1goN8irbw9CWqP9W6RhTGO 5h7repImVaDiR8o3syHwYsmoneOstn5dTcnLvw0Ii5ZLWPw8tlbRo9yf0/jr+Obf2ueN4 E5cK11rLTUT03Qe/qB1FAk5AWpQNY3Dwbr+Nzu5RhjKtzhDwCs3TpjFnnNzim7qcLztfK l6r5cswIuQxa/cj/PN+aPUVu/yi+vSVT79eGFQ+dh9NWj+AZsDgyaRDPl+TwgocIRGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Le2vwXZs; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FF77606A320 for ; Sat, 21 Nov 2026 09:43:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Le2vwXZs Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C8F51F000C0; Sat, 21 Nov 2026 09:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254189; bh=4UuzmxKgvHlfJkZ2GKl/zYApxcrbpPRELOpRuxCkj24=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Le2vwXZslp7B/rU2Y9QBga1XlXyPM+3MZfVGwMJiTCVBftKiZ8cQ1adD1YuKQ4p+K PR0XsvKN7Yciy080gQJVm//Sv1dHgfnVxL6SVjaIVaf2B3g0dl+Y2XMosuOGWuli9q afpAgjDLtre8dwj8vM1lon7q/3TPoalD2VskLJrEczJvAFmhu+sPSQCepYqNpN70DP 7bqUm9UmC6gxVkORxmGTTQVaKr/nzaoqyvt2tSJEFF73GNrVce5BhELPREl6nv7sPL YUC5t/fSr3tNlNmhHzq5+22ydZrNTE76+6qe0XQ07ezalzJjiLW736zKMemG8y48QF v/Jl55BnBp/ag== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:55 +0100 Subject: [PATCH mptcp-net v2 57/62] mptcp: order write_seq and DATA_FIN flag for fallback X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-57-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2509; i=matttbe@kernel.org; h=from:subject:message-id; bh=KsR+SG+0NuEh7ICGPD7FwEJMBMvC5IXRHK5R/oWMyz8=; b=kA0DAAoWfCLwwvNHCpcByyZiAGsBZ3Oi0CW4h1JwhmsiNiBpxgQnf8DwVpT532pUnR8yGD/nw 4h1BAAWCgAdFiEEG4ZZb5nneg10Sk44fCLwwvNHCpcFAmsBZ3MACgkQfCLwwvNHCpcfYgD8DcDx aHJ7YMwkArS16f2FgYo1fSVLmIptoKPZhJKmUCUBAIzULFMDtIfVgu9MUg86a89LD07v7YH6+TY wxub5DaoH X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 fa= llback") Signed-off-by: Matthieu Baerts (NGI0) --- 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) =20 /* 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); =20 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 *s= sk, int fb_mib) if (!__mptcp_try_fallback(msk, fb_mib)) return false; =20 - /* 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 =3D ssk->sk_allocation; --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254190; b=cri3WaKaMtD0M+DuCoT0/IWi+lp2WrbcnQX4nqI/jmP3K4Wqmi6/BZyZAyLbBDT4KuRv rQMc67v9znPoimzpIIU3JjF+XKG6wlbjcU3VTuOOxpSKcO/QAYiLlPxb0Zfhe265qS/CJ g4IT08C2smt8t5uvJxxxHkb8v3LWll2OMA/ssL2ivfJjD17gQyEqoaPh48h4T2Sv5Wfxv yJc8qlFpevpVjyf9F/OkN723nOtEo57CGIfeXZuAya0xYccRsYCEZ6mWb9U6MXPkA2yHa RZTNAqbq9f/WP48am9rfzoH61OdRW2jDlzkMyNqvJVGGOkZIV9m9QFOAItgU7goWpRQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254190; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=UXcc8JwYt8zYKqhNDrcXR1cy3Cf1frwlR2EKSmzVSdQ=; b=vCaxgAkTIAFI417tyOPDyfAwMpMOOI9locH2KfYkMMo6BE8Vdoq7h7cyRgdz5Wgw6vne P2NdOKbhvby/KNV3WDZVw6pFk+pLCkIY2/deYpUE1oXpKLbqSX/ipv/bPGjTG5n0OqMAa m/5BnmgvLHMjrVvwmqjhRCir1rK7ei5v90ZjFsQ3FlahVJGIR6MK4zjn4Pdd1lPReBw9o GTegJdJkd8Dgu4WMmmKZt1nnXnK4sfRoJ7DEloMFbf818VJUF6S0mbUUBg1H1b6r59ZMG 1JduktU+SlEHR2crIxCxuAH3Oq2Q2hgGL47FSqi/3X5T4hKvzJECjagXTCqI9K5OO8A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VBXxVbSy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E771B606A320 for ; Sat, 21 Nov 2026 09:43:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VBXxVbSy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DC2F1F000C0; Sat, 21 Nov 2026 09:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254189; bh=UXcc8JwYt8zYKqhNDrcXR1cy3Cf1frwlR2EKSmzVSdQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=VBXxVbSy+ifEGDiDT0bAVlgpQSXdWLtqoEb5M7vfDKCjs+SgGJjGL8wUxiSKVjGPZ CBffZ6pgIzlY0E0I2k2fbTydvdXWFeUk5IDCakW6z1mW6OxGyxZwoIsEKW3UHMKzLC mrQ2yCLwT8jhDSllCrEtgawU4zoeDRXr9GFMGbXfLrCCtjl8a3MKMlPuTj10Q73LoK flXnEgCDyEslhaqDNyq6pcQ5wA8jUEj7J1wxT3vtpZlogyH1ioQGTkcl2/KsCnTOG8 iWPMC15XIgtzfEe6HbRRnNYIgdR2EV8bBgROXbd69p7mCKgACv2PFGvXrZ93y3Xkr8 7NaLxcaR6Fpkg== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:56 +0100 Subject: [PATCH mptcp-net v2 58/62] Squash to "bpf: Add mptcp packet scheduler struct_ops" X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-58-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2033; i=matttbe@kernel.org; h=from:subject:message-id; bh=h6gnjSCNm1Sd9n9hCte5uKiRUbXll74ViMDdH1viP3o=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ00u2+nw13HcjJuin+IItzUs/3G6TelIiqfSvatfJC 5bBou+SOkpZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACZy5hcjw9S19rl1/TdjZ3UF y3B0Pq659uh38qNHLLkXFgavSsmy+MPIcPr4y7cC8kb18mdEOMQPsm/xb7x5hm+31f6ES/bH7C/ PYgYA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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: 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) --- 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 =3D false; else copied +=3D ret; + } else { + /* a BPF scheduler might not pick any subflow */ + keep_pushing =3D false; } =20 mptcp_for_each_subflow(msk, subflow) { --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254190; b=eEJYSROqoghvDXO0uzSQO4jYymtoTnfvQMjAgARk/KmHox9Ehg4N4cMyr0uIic+TzqAM p4kIclAWvO0LNMTAHhGJCw55EuZvIye6whNnL6+oMisygGEcbasgNt3iKUNmkk9U3259L Nso0498c2P3Rqkieu8wTKDpX4q9qYcWykhuYN1vQ5NnsY76Pm4tpoaKRwJyufQBkh6yju hzt/80MFsIHtawJmnxLPaM1RqyK/mF6sT0bCq8qm7gBZN1Abp/RPdr/JfOoT23cM35fiX AWXYXOEs6vc9jVtNkSFTU67WDebKWH+bPc755eH4RKP9GEwRgdrtvMxejfS8+xVY23Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254190; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=CnyPPXu9xZXD65sCn/drhTNKznr0mI1PlU+C0MDNy6M=; b=s/1bUdUZdg4iPkPUwTnhoAHDLkWB5uRRqAjC3zsgcTZMxGBiK2bwsV5Lco2sSZYr9Eq3 kcIQwu8ZFXd22ZYwydzllmEZlnY/SXy+SZUU+JgCdZXO4/BIbnaN8VOqSh7JNP6/P++XN rgHrXm1ddhMz9gCjPaYJ6dUePTIV2t/7hRDVMJXad29VveGWteV3H+rimFEhr7Xo1ltjV JSm+TQDcAD/WL3JOBeCvWY3ft82wW4mPxFxhSvgF9fVpKGvV07tbGWD2fbnsWA2kHhiCA pVw+VyQ3fIwXwY1PyY5M0bs7rfYxQ9QlqKTeBVuZ01fWHMZvEU8cOW9ZCxn5vmQvX8g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=V6ls7BVG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B90DE606A320 for ; Sat, 21 Nov 2026 09:43:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=V6ls7BVG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30AEA1F000C4; Sat, 21 Nov 2026 09:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254190; bh=CnyPPXu9xZXD65sCn/drhTNKznr0mI1PlU+C0MDNy6M=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=V6ls7BVGyD+PkfuOaXcOg2+Em7QyQbAH+4MaYEArV7AR1qQV+MUM1b0ZQF8dpJJMK XlidQx5ggBlHennUmuS7Mlq2imsNbI979wqqiESgAI7F55o5rIjaiicpbvkG3ccGeQ cIOIT4jJi02WpFFgHUjTdIDNPG2nVosNwzzufcfFltjoFzvbZqRlQDlgp60Jo4UUe9 eLBKbUQlB7imDVX0lVmdEOAzGtpt2S/5cje75g0++rgMMi/uFSUsWp6duFCV85V6jC TanwsYlvhgoGf69w+KDxkn08wCtGVr4vpWSDD8Y8t7KH4ZUXVBvJYUS2y0eafmVj6M 2E/p0WZEZYUkw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:57 +0100 Subject: [PATCH mptcp-net v2 59/62] Squash to "bpf: Export mptcp packet scheduler helpers" X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-59-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1638; i=matttbe@kernel.org; h=from:subject:message-id; bh=gj0zTt3FypZWjoOtRiu7MrcG+V+Ru9RhyDxMBsC3xOk=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ00tvMh6PVtd5/cJUaGnyucS+P7nJkU1LC3csTl3sr Jjw4DVnRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwERytzL8FflVcrtO6G3t5TNK q3bLi3jkiV6oOODy6q+x68sbRXdPtjAyHD7D9vHf0vqX1tMjvuw790Ts5DRlluWR6v+X1ypVW4f MZwIA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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) =20 if (msk->sched =3D=3D &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); } =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254191; b=UaJY3oTs8yi0f7GnggMnqmg4bPiINYOduj4KcWMvaHhv/qTjnK12jxyLFAyLww6DhVa0 KaUXc+3G+HJ3GXtOhe2LJMzuAHPu6tfujqJL8IBWuWcjZhfGCtrA/F3d7ueKbxclXdKLX Dj0Dxa5c+4KJDLrCy2RmJdb2vNEq3eDzJZiqN+AuTurs/TuXyywJ4HrLcI51Ee2BwwdVK ejnhLgpw4eEiB1WHjCcNhBK6/xZz60x98wv2mQITBd971vTSXfyopZXbVwSwbJYuceQ7q F2GHcQs6zDLmACXVrWj05a/rJZVWcg3UEv16vD3BcqcfE+nfi8KH6xDqhoBNIUVacPQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254191; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=0DC+n+GdtOSa1Qfyp6uLmRibzbOuzYFIF0cIJvkRu+Y=; b=5KdgxTB6CYZkNmP/N3bPtiD/8NLt6EdezWkQ12W5R6OJhDKAYvrgvupcTtyk2zs5AdfF EkR4P3+gMsA1zzQ04AlblCZ3yLZABvdPg0eGvRcKwRro8+a9eRuYJnyibjBDpsyL6jOSP MWodk660ViMgaZu7z8v25Yjou7+X7sPUf8jNw6D6e/S4B0Ju18EEyYnkHXbp2NoSDF16o C3+o9Cdd128t9/mYIrdjLWYzsJwjIi6LoIJSFMtdogxbI/2YC35KbU8viNusLhldCEj3n tUMCotcMVBXAbLoaRgETv/bD0aQvfMp/HaGAHo/AbJiuDvIfYYgbhu1ZPTfTL0hj+fQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=W4cxm477; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B666606A320 for ; Sat, 21 Nov 2026 09:43:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=W4cxm477 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 024951F000C0; Sat, 21 Nov 2026 09:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254191; bh=0DC+n+GdtOSa1Qfyp6uLmRibzbOuzYFIF0cIJvkRu+Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=W4cxm477NDmBlH5EmNFgs9uhrJeqvOmzR1N1rm3PopUzWONdVyQ71zoyxcXf/5tcJ uW0QyZ74LHG2MMfA/+XcRcHIsxpncyjC9MpyYAbCzt1uLchpcXj4i/wCBl48Tq5scp q0G9GkBAAYm4TJRGOELdaj1TaijExjHNKNt2AT59gehF4wwcuKc9e5U5rwCHiyulSB LeZpdqOB571D99XDcEvswu8iI1cxkdJW8QlXgTflnZJrOmDqIjyeed79QRJwpCmumM kZIiDWh6AQjRgjRLH+Bc3MXIZzrgJsLDwp4acJKJopRVOSknwxL9cWinMzjo4VBf1l g90+Z7a3hQW8w== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:58 +0100 Subject: [PATCH mptcp-next mptcp-net v2 60/62] mptcp: push pending data after a fallback on reception X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-60-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2273; i=matttbe@kernel.org; h=from:subject:message-id; bh=fYsv+l0BDzFIvw20XUtVD6+gO/USyK2gCweGSGlkER4=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ08sSd3aelmXZLDut7OBZI0lhW9UpJ+/Fuc94xHhl5 el9D3p+dJSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAExkbRHDb9YQOz6pq2nhM1Id Vj93vFD4QFZacNOu41MXi6pzKZhO6mZk2M6yXqrB0779dtd1+6hVhpo7Whfl3m/b3rIu38OmTTG EDwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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 er= ror: 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) --- 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); } =20 --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254192; b=aGI9IJhFvCHqff++A18Fobhm/55nEyxbDqmPVqqlJCPJJt6HWgKZJrvWJHZYTivzxASb /kgV/I9xds0t+isY/nbdVYOp2YQ86VuFFdp3Bkjmfsm3kXuO7mjDAY7XpY2jnEt0WI9Q2 RQZyk2VDO5lDivxi9vHJy48EKbMLmttGP1Tk4/BmcNiFlKX9ytG9GNZL6ifW2zkt4iLnM 8WCBnS4fSTbrGHt0DIfs6NMlJDzLKXBwRMyEJnKmJB39Wsnekbmom1bMMFPOGYktnIry1 bkQ2j24wDL96SOspYFUhLzu/idJuo/EPZppNQY/fbYh/gKuV7QRWu4QSudU/uLny5NQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254192; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=54xhJkFHGtGlemyXpbyRqx5brrfPR1f1jBG4sqecGaw=; b=GJ8YrLr0eRhjZQvXZeqi9srf5s3/+QsqMBKnCgCwP9cVXY418eWycEXCPhJsJI6GOfLU b8k/r63WUS3Mjqr3dRnJJocKhksHEQ839sD58Ubu1NO7FkmBfpek1roEv7pmeJAakO6tI C7iSIE18NTvbGl89qM64Y5xWEfGmO2v2omupGmikd8xUPQoOoI8F9HBStM4AToEcnDiAe v5+mDLL6/eVOmcOdAo7EMUaUuz2H2iSi6g4/wMzdd9NXY2AgCsaaii8xEd1YJnKOUE6K9 T/LuJABJpZ5De74CzOybFCj4FtYehUrRThy7Z/ahJyZO8j9ZZGbfD+HtHl6xweRjbAA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=noyrW5nH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BBBC606A320 for ; Sat, 21 Nov 2026 09:43:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=noyrW5nH Received: by smtp.kernel.org (Postfix) with ESMTPSA id C81321F000C0; Sat, 21 Nov 2026 09:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254192; bh=54xhJkFHGtGlemyXpbyRqx5brrfPR1f1jBG4sqecGaw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=noyrW5nHbjtm2zbr5XeBkRnr9/galE1i/kHi0xexYubFMA/g3yUAypnq3QOh5MtLd UVqMC1eHcYoCHBdWHKcdx2Oi9syLJTK/w1OS0MuBYUb6Gg3hdY9Z57vDXA5s35/qLa RqQCjGXaeQnRCQ2SIUgg5rw8Lm/cO37yeM25UprEYCXYyZdLzjmUIaXNQEjyxUA09H +LItWry4s0dgGJcrnd54g/xKvABrYkd7O1g/1e0pfkmLhWhLm/kpah2eCgYFUInUMS 6a3V/gFHhNQUUEEHLStjiScKQIId2aGK5GuPG+weDyxmybRd1Ro3EE9k7gbojzPoX8 iwBwU3FXOv0Aw== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:41:59 +0100 Subject: [PATCH mptcp-next mptcp-net v2 61/62] mptcp: report errors as TCP does when closing X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-61-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=6592; i=matttbe@kernel.org; h=from:subject:message-id; bh=67Hf9HuE79t2ow0MFKaShzYh427AMAEyNzEMsORQTSA=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIZ08smntlrVr/sh/v23Q2yHDGvlfQa9pWx7FslYO7zv f3Zrj3xHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpADe5iuGvgPic81sEjeO/BUzO l536QUgubvb2H62N7z655exol7RbwvDf5wEzo6nR/q28mdIft72OmLfFWcU51Yy1OfXcdJ49dyP 5AA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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); } =20 +/* 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 =3D ECONNREFUSED; + break; + case TCP_CLOSE_WAIT: + err =3D EPIPE; + break; + default: + err =3D 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 =3D 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 =3D=3D 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 =3D true; @@ -2810,7 +2860,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct= sock *ssk, { struct mptcp_sock *msk =3D mptcp_sk(sk); bool dispose_it, need_push =3D false; - int fwd_remaining; + int fwd_remaining, ssk_err; =20 /* 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 =3D 1; + /* in case it is the last subflow: before its disconnect or dispose */ + ssk_err =3D READ_ONCE(ssk->sk_err); =20 if (flags & MPTCP_CF_PUSH) mptcp_cleanup_ssk_backlog(sk, ssk); @@ -2905,13 +2957,15 @@ static void __mptcp_close_ssk(struct sock *sk, stru= ct sock *ssk, mptcp_set_close_tout(sk, tcp_jiffies32 - (mptcp_close_timeout(sk) + 1)); mptcp_schedule_work(sk); + } else if (sk->sk_state =3D=3D TCP_CLOSE) { + mptcp_close_wake_up(sk); } else if (sk->sk_state !=3D 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 =3D=3D 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); } =20 - /* 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 =3D=3D TCP_CLOSE) return; - default: - WRITE_ONCE(sk->sk_err, ECONNRESET); - } =20 + 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); } =20 if (sock_flag(sk, SOCK_DEAD) && sk->sk_state =3D=3D 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) =3D=3D TCP_CLOSE)) { if (unlikely(list_is_singular(&msk->conn_list))) { + int err =3D READ_ONCE(msk->first->sk_err); + mptcp_check_rcv_close(newsk); - mptcp_set_state(newsk, TCP_CLOSE); + if (newsk->sk_state !=3D TCP_CLOSE) + mptcp_close_last_err(newsk, err); } mptcp_close_ssk(newsk, msk->first, mptcp_subflow_ctx(msk->first)); --=20 2.55.0 From nobody Mon Nov 23 20:27:01 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795254193; b=1ME55vAgSFs6OxdcB+63sxuneQWo7JfY8rO+TRocJ1vW6s9vvCWpWRjqkUNoy9yVJZcU FAE2S6kDJ0pmnDLQDyNZ8mUuTy3kv+qnapTfxHEnsOL1iYMCF/kEJ3TZtX5DCwGbyLBEn 9inSoFsiwtjqSUHlPSJ2NUwvVFY6a9L4x1cEQS6gBHRZ3iodJXr6aV/j6f5oJfZaagD09 +/zEhsPtjZRpTy+TOvj882ePDXS4216LTDmOmdZduZBY0Xri2YesKcj7Lv32jwkGlLibj XRaFoWK3V8wIQVtQcwcPhPTasfH0bnWaojsUUZ8L+vrfDgDwxknD7Nlobg0LImt8QTA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795254193; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=ENSKVcPqGzuSWPAKYp6yC5K80U42bHSo3RTecnzQUIA=; b=oWXn8NxZAleI60AJjgH/FAkpcDcu1e5218Ozl92CxoKSGVM1esIs6sjJuaNaE1oNjyYF afr5LyfZrRqHwP6Qa7ujcLemGsvtNQM7c7RYp9d4T+sYguagDh/kVDBdBNpsRYI1RJk7s wUL0iqgEJZDZhv5ZfFojpbP34lusIjC1fqBocrKJFmK1PTWqcCzRputA1M0Ur+Rhgkyi4 LwAcbwnqnOM/5pTSf9wekDvlNiC6oyEwyniCehABx2hAbMkkr4KlE2D/J8DymLJR9Jc3/ QbuL6AYcxM1ow4LAl4KQAEFQWhv6LF/vDzgzxHI0tXIy4d+9UsE4ReEoG+DKz8pushA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=o3iYIPa8; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DC4F606A320 for ; Sat, 21 Nov 2026 09:43:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=o3iYIPa8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99C2C1F000C0; Sat, 21 Nov 2026 09:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795254193; bh=ENSKVcPqGzuSWPAKYp6yC5K80U42bHSo3RTecnzQUIA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=o3iYIPa82PVS550Jji7IXBfa98uQArReK7Fj4L86Nu7T6Brx6yLhHu8Wg+EMwGUs7 ecTcgnyF9P/R8faUBtqe522+YZcMgxmnt8Nuly6CpP6sMamwk6HVOz3gNpthwwJtV9 MLv+F6vApgBh5ERiDksQuY9owR94OEjNslELInLgNlPv9FHgDdoGAhDESXg+/G1Dow 2aaq/IveLWEw/RQFusuyiSRjwEPZllm7qsuwlvb43Q047Zx93LCPn0Wda/LvNQIzVx Z2UFB10vtnRLC5gmuipQ2syE2ukNzJKD7y8J9tSQYakDqpPAnJZrthdRHCAQUfOEZo Oxrv/w50HYPtg== From: "Matthieu Baerts (NGI0)" Date: Sat, 21 Nov 2026 10:42:00 +0100 Subject: [PATCH RFC mptcp-next mptcp-net v2 62/62] mptcp: reset when the DSS disappears after a DATA_ACK X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261121-mptcp-cmason-fixes-v2-62-00327fd1de1f@kernel.org> References: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> In-Reply-To: <20261121-mptcp-cmason-fixes-v2-0-00327fd1de1f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=8736; i=matttbe@kernel.org; h=from:subject:message-id; bh=uVxd7KP5vm2zoaapmPspZW7xACOPgZWdcZBhBVTLY9c=; b=kA0DAAoWfCLwwvNHCpcByyZiAGsBZ3fIp0K/pImH8vWUcvDXDGq/8b1L0KmCgp8MxBfq4yeVj 4h1BAAWCgAdFiEEG4ZZb5nneg10Sk44fCLwwvNHCpcFAmsBZ3cACgkQfCLwwvNHCpdvywD/QefN KtT/MrgL8oQh4/Zp8eU14DuQkQHjV4NY7lz2M0kBAMxN8obHCW3yuYfTL3oQ15KC77RpFiwlPIS kkMiImRkN X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) --- 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, struc= t sock *ssk, subflow->rcv_wnd_sent =3D mptcp_rcv_wnd; } =20 -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 =3D ntohs(tcp_hdr(skb)->window); struct sock *sk =3D (struct sock *)msk; u64 snd_nxt; + bool acked; =20 mptcp_data_lock(sk); =20 @@ -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); =20 - if (after64(new_snd_una, old_snd_una)) { + acked =3D 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; } =20 bool mptcp_update_rcv_data_fin(struct mptcp_sock *msk, u64 data_fin_seq, b= ool use_64bit) @@ -1356,8 +1359,8 @@ bool mptcp_incoming_options(struct sock *sk, struct s= k_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 =3D 1; /* MPTCP opts pass both ways */ rwin_update(msk, sk, skb); =20 /* 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 }; =20 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 =3D=3D 0) { pr_debug("infinite mapping received\n"); MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_INFINITEMAPRX); - return MAPPING_INVALID; + return MAPPING_INFINITE; } =20 if (mpext->data_fin =3D=3D 1) { @@ -1453,6 +1454,22 @@ static void subflow_update_dsn_base(struct mptcp_sub= flow_context *subflow) subflow->dsn_end =3D end; } =20 +/* RFC 8684, 3.7: no fallback once a DATA_ACK acked our data, except MP_FA= IL */ +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 =3D 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 =3D mptcp_subflow_ctx(ssk); @@ -1473,7 +1490,9 @@ static bool subflow_check_data_avail(struct sock *ssk) status =3D get_mapping_status(ssk, msk); trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue)); if (unlikely(status =3D=3D MAPPING_INVALID || status =3D=3D MAPPING_DUMM= Y || - status =3D=3D MAPPING_BAD_CSUM || status =3D=3D MAPPING_NODSS)) + status =3D=3D MAPPING_BAD_CSUM || + status =3D=3D MAPPING_NODSS || + status =3D=3D MAPPING_INFINITE)) goto fallback; =20 if (status !=3D MAPPING_OK) @@ -1523,7 +1542,9 @@ static bool subflow_check_data_avail(struct sock *ssk) return true; } =20 - if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) { + if (((status =3D=3D MAPPING_NODSS || status =3D=3D 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 */ --=20 2.55.0