From nobody Sat Aug 15 20:33:32 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5AA733FE33; Mon, 3 Aug 2026 16:17:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773822; cv=none; b=L321iChxsxKTpzYJ4+Pl73QpU3IGjcRDB5e4mRxChp0AzSbH8L884sQSub9t3UuGk1zptY1IxCgwFLQCY1vEqgolouapVDbO5DUhZrGLP0rR5+t6wgBO3vTNA7+w5V34LrbPR9f5xV12PICP2fOSBkK9+H7QlRL76OpKPhvmmss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773822; c=relaxed/simple; bh=lvmkn61vQQEGAHxKyJX6XZhY6CoTu18WnEURCPq786A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AgkvWU+mCNaWTwXO+3KBIjRqIhrK9VVue3Vh28GaOrO8vZDEUmH2k5wzOZMlCezye/BrBicDF5i21vfNwezCM1CKiKEZXuCV6jMGZ0t1sq7ZPdseIVSrB/KPqmh7aAD/pUD8+GvLXrf9YZBuRpq4zOtPLfUqWKI2/y8SKKz+/VU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bw9pcqpU; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bw9pcqpU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FE081F00A3A; Mon, 3 Aug 2026 16:16:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785773820; bh=BEcd7zqaFXXWz5985otFpOCYR4kc99cvg9uym3Vjsvc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Bw9pcqpUSekjhf0CErwZIK6L6/WVaubHnd95Nu3H+t4rUzx8O1mAUd0YAoUHRRZIo SUl78qJ3n/Tv3HzJNtXKuiH7OMG286LoYmU0dYgz2QIQujAfKfMhpha/UtafyChLNy ghtDBv3MP7QbiA4A5GMo8FBt/nuUC+Xxs+/Kk133M0VhDr2vb21xfiRWxGIWKlfJZI aF2nFLMwFszM2CMO1Af6zCAM8ZtLXuLZpKoqMWa/nTVjlMY4WMLwSjLaBb7OQ9d//P ZvjAEJH4dONxCEbiI46Umi+ddvkIaAhZ3eCSX/cHNlckE1aWGqh+JvELG2m27rBSa0 SQ3MUqy4iH//A== From: "Matthieu Baerts (NGI0)" Date: Mon, 03 Aug 2026 18:16:33 +0200 Subject: [PATCH net v2 1/8] mptcp: options: reset DSS fields in case of unexpected size Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-1-b8f496d71664@kernel.org> References: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> In-Reply-To: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> To: Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , stable@vger.kernel.org, Davide Caratti , Florian Westphal , Christoph Paasch X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1627; i=matttbe@kernel.org; h=from:subject:message-id; bh=lvmkn61vQQEGAHxKyJX6XZhY6CoTu18WnEURCPq786A=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIK9r39toNV6MPpvHXfBfaes2FyUrpto/P3VJSH3pX1D Ln+JrMWdZSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAEzkTijDH85DN8pecKypXMlm cnS9U0gl1/OFKbIG7YmlvG+kmJVnWTIybPZvitW7Ya58UeJJ/abje6N//3885coWr0CFhmNPrqx bxwkA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 A remote peer could send a malformed DSS with a wrong size, followed by another DSS or MPC + Data. In this case, the first suboption will be ignored, but leaving some fields written, which could lead to inconsistency or access uninitialized data. Explicitly reset the fields that could have been modified in case of unexpected size. Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260728-net-mptc= p-misc-fixes-7-2-rc6-v1-0-f7e2d229159d%40kernel.org?part=3D1 Fixes: 648ef4b88673 ("mptcp: Implement MPTCP receive path") Cc: stable@vger.kernel.org Signed-off-by: Matthieu Baerts (NGI0) --- Cc: Davide Caratti Cc: Florian Westphal Cc: Christoph Paasch Note: Peter Krystad's email address is no longer valid v2: New. (Clashiko) --- net/mptcp/options.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index c664023d37ba..038eca33c6b1 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -188,8 +188,14 @@ static void mptcp_parse_option(const struct sk_buff *s= kb, * RFC 8684 Section 3.3.0 checks later in subflow_data_ready */ if (opsize !=3D expected_opsize && - opsize !=3D expected_opsize + TCPOLEN_MPTCP_DSS_CHECKSUM) + opsize !=3D expected_opsize + TCPOLEN_MPTCP_DSS_CHECKSUM) { + mp_opt->dsn64 =3D 0; + mp_opt->use_map =3D 0; + mp_opt->ack64 =3D 0; + mp_opt->use_ack =3D 0; + mp_opt->data_fin =3D 0; break; + } =20 mp_opt->suboptions |=3D OPTION_MPTCP_DSS; if (mp_opt->use_ack) { --=20 2.53.0 From nobody Sat Aug 15 20:33:32 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C59E6372056; Mon, 3 Aug 2026 16:17:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773825; cv=none; b=BcFaXnnet3LxqrKSkZfn5Pw18WBjwA5FheIeOw0W95rDQkel+ey63CEYmITGErNRrrzRUNQaBBhwDU+4PldF0/gsqiXi1ZVlzAq8A+YcdjeFm9ZAibPXKNNnt3dqCNRAqxXW59L5Pt3zVgATEm5wGlriexBVYl6se52tmlz9Ti8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773825; c=relaxed/simple; bh=Y4nsdrSlWTeWv+d+tjFzp6/WoNZPPKLQ3HqPO/xk1K0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pVQylEWSXsiS8FPg0W2RSATWkodyhhIwZiY5DBsslSf29l5E33UdALzG0FQR5DGdFzIzYI2xQuKLXzaXJVID2+O3lipxOAXpR7h0RjvWvgPfWkQgYznj/usFOgLxBdTK32tKIfd6baMiU2NA/k9tofkQmK+cRETZnoqzdB75NTk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jxgGZ7iL; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jxgGZ7iL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E38D71F00A3E; Mon, 3 Aug 2026 16:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785773823; bh=dxo5OFWrD3WUiiE5O0IodUaNzWkfG5y0BXmVliVk7sc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=jxgGZ7iLi4NkOQEw5QiUkrCkb05LeNN4mReE8tdvsvpsmfBoHcoaehK8+1TmM+pKb 5lEvxsiqtF/iiTlW818Oc8YDquQL3XQkPeQ9Naq9wmC4B1gXQRwpswozT0m+fg7KYI 401Eq1oOwouetPDy6O2hvJcizCf2HBTpCph62s0ZlBzzG7PD1tktTGR+IJ9MzfXa2+ e5fX4LyP2umKy2MYRf1dyO7RDilFZ42yZtZTtRdfwHjggBUPaFTTAvUWNEy4XWsNJN hnt1LSyIKSis2Wg6xzO8l1jUDeQr9rAKxC5TcJWQ+XybLDlIhGo5HxJ0EwXh6Lv0L/ RT/zG/qJFbB3A== From: "Matthieu Baerts (NGI0)" Date: Mon, 03 Aug 2026 18:16:34 +0200 Subject: [PATCH net v2 2/8] mptcp: avoid combining some incoming suboptions Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-2-b8f496d71664@kernel.org> References: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> In-Reply-To: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> To: Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , stable@vger.kernel.org, Florian Westphal , Davide Caratti , Christoph Paasch X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8951; i=matttbe@kernel.org; h=from:subject:message-id; bh=Y4nsdrSlWTeWv+d+tjFzp6/WoNZPPKLQ3HqPO/xk1K0=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIK9r0Tinqf8k1hr5VN37X2R+3dacbnldxtS58eYH9l+ 9rvwjm7jlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIkoLWH47/LC5/6n5/ay+f4P L+lZdq57HWtwYH/M5qI/q+3ess5NvM3w37HkIa+M29EyK9tnefJni9Ztn5o3O/andlDyJ6XY4um HOQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Some MPTCP suboptions are mutually exclusive according to the RFC8684, but also because in different places, the code doesn't expect some combinations to be present. That's specially true for suboptions that would be present twice, but with different attributes. The new restrictions are the same as the ones applied on the output side, with mptcp_write_options. The same rules can be reused with a small fix: an MP_FASTCLOSE can be used with a DSS when the sender picks this option [1], which is not the case on Linux. Here are the rules: Which options can be used together? X: mutually exclusive O: often used together C: can be used together in some cases P: could be used together but we prefer not to (optimisations) | Opt: | MPC | MPJ | DSS | ADD | RM | PRIO | FAIL | FC | |------|------|------|------|------|------|------|------|------| | MPC |------|------|------|------|------|------|------|------| | MPJ | X |------|------|------|------|------|------|------| | DSS | X | X |------|------|------|------|------|------| | ADD | X | X | P |------|------|------|------|------| | RM | C | C | C | P |------|------|------|------| | PRIO | X | C | C | C | C |------|------|------| | FAIL | X | X | C | X | X | X |------|------| | FC | X | X | P | X | X | X | X |------| | RST | X | X | X | X | X | X | O | O | |------|------|------|------|------|------|------|------|------| The only difference is with the 'P': another stack could send and ADD_ADDR with other suboptions (DSS, RM_ADDR), and this should be allowed. A few points of attention: - In theory, an MP_CAPABLE could be used with a RM_ADDR, but there is no reason to add it with a SYN. Note that even with a 4th ACK, it doesn't seem to be useful, except when IDs are known in advance via another channel. Better not to break that. - Now, combining both an MP_CAPABLE and an MP_JOIN will no longer result to a reject of the two options, but only the second suboption is ignored. That seems OK to do that for this unexpected error. At least now all inconsistent combinations are handled the same way. This could change later in next. This also means the explicit checks for having both MPC + MPJ in subflow.c will now be unreachable. That's fine, they will be removed in a follow-up patch. - In case of conflicting combinations, the extra suboption(s) is/are ignored: having such combinations either means the remote peer is buggy, or is evil. The simplest action is then taken in this case: stop processing the current suboption. - In mp_opt->suboptions, there is also a bit reserved to the checksum, which can be used in an MP_CAPABLE and a DSS. Each time a DSS option can be used in parallel with another option, the checksum can be set, so the verification is combined into a new OPTIONS_MPTCP_DSS macro. - An MP_CAPABLE ACK can carry a Data-Level Length, and an optional Checksum: they are the same as the ones found in a DSS, because a DSS cannot be used in parallel to an MP_CAPABLE. Similarly, even if there is room, a DSS cannot be used with an MP_JOIN. Fixes: eda7acddf808 ("mptcp: Handle MPTCP TCP options") Cc: stable@vger.kernel.org Link: https://www.rfc-editor.org/rfc/rfc8684.html#section-3.5-5.1 [1] Signed-off-by: Matthieu Baerts (NGI0) --- Cc: Florian Westphal Cc: Davide Caratti Cc: Christoph Paasch Note: Peter Krystad's email address is no longer valid v2: - Handle MP_FASTCLOSE + DSS case. (Clashiko) - Updated commit message to reply to (hallucinated) AI reviews. --- net/mptcp/options.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++= +++- net/mptcp/protocol.h | 1 + 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 038eca33c6b1..1057d500577b 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -50,6 +50,14 @@ static void mptcp_parse_option(const struct sk_buff *skb, } } =20 + /* Only the MPC + ACK can be used with a RM_ADDR */ + if (subopt =3D=3D OPTION_MPTCP_MPC_ACK) { + if ((mp_opt->suboptions & ~OPTION_MPTCP_RM_ADDR) !=3D 0) + break; + } else if (mp_opt->suboptions !=3D 0) { + break; + } + /* Cfr RFC 8684 Section 3.3.0: * If a checksum is present but its use had * not been negotiated in the MP_CAPABLE handshake, the receiver MUST @@ -122,6 +130,11 @@ static void mptcp_parse_option(const struct sk_buff *s= kb, break; =20 case MPTCPOPT_MP_JOIN: + /* Can be used with a restricted number of other options */ + if ((mp_opt->suboptions & ~(OPTION_MPTCP_RM_ADDR | + OPTION_MPTCP_PRIO)) !=3D 0) + break; + if (opsize =3D=3D TCPOLEN_MPTCP_MPJ_SYN) { mp_opt->suboptions |=3D OPTION_MPTCP_MPJ_SYN; mp_opt->backup =3D *ptr++ & MPTCPOPT_BACKUP; @@ -153,6 +166,14 @@ static void mptcp_parse_option(const struct sk_buff *s= kb, break; =20 case MPTCPOPT_DSS: + /* Can be used with a restricted number of other options */ + if ((mp_opt->suboptions & ~(OPTION_MPTCP_ADD_ADDR | + OPTION_MPTCP_RM_ADDR | + OPTION_MPTCP_PRIO | + OPTION_MPTCP_FASTCLOSE | + OPTION_MPTCP_FAIL)) !=3D 0) + break; + pr_debug("DSS\n"); ptr++; =20 @@ -240,6 +261,12 @@ static void mptcp_parse_option(const struct sk_buff *s= kb, break; =20 case MPTCPOPT_ADD_ADDR: + /* Can be used with a restricted number of other options */ + if ((mp_opt->suboptions & ~(OPTIONS_MPTCP_DSS | + OPTION_MPTCP_RM_ADDR | + OPTION_MPTCP_PRIO)) !=3D 0) + break; + mp_opt->echo =3D (*ptr++) & MPTCP_ADDR_ECHO; if (!mp_opt->echo) { if (opsize =3D=3D TCPOLEN_MPTCP_ADD_ADDR || @@ -299,6 +326,14 @@ static void mptcp_parse_option(const struct sk_buff *s= kb, break; =20 case MPTCPOPT_RM_ADDR: + /* Can be used with a restricted number of other options */ + if ((mp_opt->suboptions & ~(OPTION_MPTCP_MPC_ACK | + OPTIONS_MPTCP_MPJ | + OPTIONS_MPTCP_DSS | + OPTION_MPTCP_ADD_ADDR | + OPTION_MPTCP_PRIO)) !=3D 0) + break; + if (opsize < TCPOLEN_MPTCP_RM_ADDR_BASE + 1 || opsize > TCPOLEN_MPTCP_RM_ADDR_BASE + MPTCP_RM_IDS_MAX) break; @@ -313,6 +348,13 @@ static void mptcp_parse_option(const struct sk_buff *s= kb, break; =20 case MPTCPOPT_MP_PRIO: + /* Can be used with a restricted number of other options */ + if ((mp_opt->suboptions & ~(OPTIONS_MPTCP_MPJ | + OPTIONS_MPTCP_DSS | + OPTION_MPTCP_ADD_ADDR | + OPTION_MPTCP_RM_ADDR)) !=3D 0) + break; + if (opsize !=3D TCPOLEN_MPTCP_PRIO) break; =20 @@ -322,6 +364,11 @@ static void mptcp_parse_option(const struct sk_buff *s= kb, break; =20 case MPTCPOPT_MP_FASTCLOSE: + /* Can be used with a restricted number of other options */ + if ((mp_opt->suboptions & ~(OPTIONS_MPTCP_DSS | + OPTION_MPTCP_RST)) !=3D 0) + break; + if (opsize !=3D TCPOLEN_MPTCP_FASTCLOSE) break; =20 @@ -333,6 +380,11 @@ static void mptcp_parse_option(const struct sk_buff *s= kb, break; =20 case MPTCPOPT_RST: + /* Can be used with a restricted number of other options */ + if ((mp_opt->suboptions & ~(OPTION_MPTCP_FAIL | + OPTION_MPTCP_FASTCLOSE)) !=3D 0) + break; + if (opsize !=3D TCPOLEN_MPTCP_RST) break; =20 @@ -348,6 +400,11 @@ static void mptcp_parse_option(const struct sk_buff *s= kb, break; =20 case MPTCPOPT_MP_FAIL: + /* Can be used with a restricted number of other options */ + if ((mp_opt->suboptions & ~(OPTIONS_MPTCP_DSS | + OPTION_MPTCP_RST)) !=3D 0) + break; + if (opsize !=3D TCPOLEN_MPTCP_FAIL) break; =20 @@ -1406,7 +1463,7 @@ void mptcp_write_options(struct tcphdr *th, __be32 *p= tr, struct tcp_sock *tp, * RM | C | C | C | P |------|------|------|------| * PRIO | X | C | C | C | C |------|------|------| * FAIL | X | X | C | X | X | X |------|------| - * FC | X | X | X | X | X | X | X |------| + * FC | X | X | P | X | X | X | X |------| * RST | X | X | X | X | X | X | O | O | * ------|------|------|------|------|------|------|------|------| * diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 4a2d40cd7b13..c13680d18994 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -37,6 +37,7 @@ OPTION_MPTCP_MPC_ACK) #define OPTIONS_MPTCP_MPJ (OPTION_MPTCP_MPJ_SYN | OPTION_MPTCP_MPJ_SYNACK = | \ OPTION_MPTCP_MPJ_ACK) +#define OPTIONS_MPTCP_DSS (OPTION_MPTCP_DSS | OPTION_MPTCP_CSUMREQD) =20 /* MPTCP option subtypes */ #define MPTCPOPT_MP_CAPABLE 0 --=20 2.53.0 From nobody Sat Aug 15 20:33:32 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06BD837F741; Mon, 3 Aug 2026 16:17:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773831; cv=none; b=hBoI6CWy4R8KdiEh+WfcdD6gXlMRHJZVipXg+zE5Yj2Ma7sP3wSDDego6jxKtR80AhEeUjdHqCBkuXWMks3U6AUQXSRlVZx59F/jAo8IGShB9NH0Oc344xdxnJd8YARFmvuUmajqHiyhghtPCR3ZgBBsRpsqWkyrrpjr+yGGg50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773831; c=relaxed/simple; bh=8+CGYSe3kZMMOTUEHKGE8EA7k+J0vsJn8cpqKxfGPQk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JlKmzxDcp1db5D2lhg4SrKCXPsIm6YO23B/gflwekA8LRE9NH6W0LoVC3CigtnVzoEQGkcGllwiprrXsIwXG/j2qCkHJzbrcB3AAWvQOsKhFgYRcLanEqgOGd39jnT2rI8TcMHPiSRbvK8TmpCl07YPdE9RHWnWjlTPCOA8NQS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SFIRdWce; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SFIRdWce" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C619B1F00A3F; Mon, 3 Aug 2026 16:17:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785773825; bh=qQORwAh6+QnbGy2AgPHZq0cX+JfqXclVLoVueu+7rGk=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=SFIRdWcea5ayXnPfl3fb3NaQr6Tz3wF0n23j20O5jsZD7QotKmjcGGthCYARaGU2G /8woH1Rz/6BVbKoGSLxYE728+a/bwATtr6YfM+9P/UMLDMe/UjMN3/HSResTtDHybi aXcbRGpAo946vcxnVOHvv+6mzURdrJR8TZNmKwEYs4/1aHgmnBbIEcV+HnsQLFYMst mZtn74z6IDc3o9k9ngHjzBcVdnJ6PAmDw1i6/XIfLfXU2VRnQt07+OzcGWl4K2Y4lN +BwVXAqivdK34eYYpcifQfB/GLTowrnbD1WASZpdvsrazad/4qcc8ZuvUfkLYT1MfT jYY+W22Ef6Zjg== From: "Matthieu Baerts (NGI0)" Date: Mon, 03 Aug 2026 18:16:35 +0200 Subject: [PATCH net v2 3/8] mptcp: remove MPC && MPJ check Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-3-b8f496d71664@kernel.org> References: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> In-Reply-To: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> To: Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1409; i=matttbe@kernel.org; h=from:subject:message-id; bh=8+CGYSe3kZMMOTUEHKGE8EA7k+J0vsJn8cpqKxfGPQk=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIK9r2fWlA5oVu2b9OSGZG9T5dkno+JUui7HXewcenL0 12GM4UsO0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACbSnsnIsC/Xx3SnWsex30cY +ry2+G5UXZ+g/ujozYZU8yt/jtTz8TIytBW77J79bW+V7r2pjGuy2TnCjZ90SjIotDS9tHsq/GU 7PwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After the parent commit ("mptcp: avoid combining some incoming suboptions"), the parsing step no longer allow to have both the MP_CAPABLE and MP_JOIN suboptions set together. These chunks are now unreachable, these checks can then be removed. Signed-off-by: Matthieu Baerts (NGI0) --- v2: New. Added here for consistency, and to reduce comments from AI reviews. This patch doesn't need to be backported, but it can if it helps backporting other patches. (Clashiko) --- net/mptcp/subflow.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 8e386899ceb9..e1f20ff8fdb4 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -174,8 +174,6 @@ static int subflow_check_req(struct request_sock *req, =20 if (unlikely(listener->pm_listener)) return subflow_reset_req_endp(req, skb); - if (opt_mp_join) - return 0; } else if (opt_mp_join) { SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINSYNRX); =20 @@ -277,9 +275,6 @@ 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); - if (opt_mp_capable && opt_mp_join) - return -EINVAL; - if (opt_mp_capable && listener->request_mptcp) { if (mp_opt.sndr_key =3D=3D 0) return -EINVAL; --=20 2.53.0 From nobody Sat Aug 15 20:33:32 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B7033812ED; Mon, 3 Aug 2026 16:17:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773829; cv=none; b=XPeihXi8dju68gr0XcM9lV6s01/ZKY3Qbf2OQ65onof7Myx3/4iixoKxX4ABSDi2nc2hoxcHc4VoChcwDjYVZPov+7PPlgpnSKCfc7yllwChNlQHxsFZHJMiXS4fQMnRzG+70zNoYJQiF3TnIW0w/lRkfpSNMHb5YvdxQCWco5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773829; c=relaxed/simple; bh=tR+bpbZaXHR7yYtUPL3piKutNWTjz7W9MI5kuSN5Yp0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oK2Lzd6OT3m+cBEnlavzv7DhyQFj5jgzn1AV8ZYKRVc363Bo3b1sC18t/twv6YLxMhy3LUyvwQOqiu+k6AGJoADY+lhVr20ho8qi/28ehItEMdOU8587l2hq2Cc5MdXRydvobl03Irnzx1qFE+pgwVznndQwlgjb40p4AeLLYsQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NaVSLzt+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NaVSLzt+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D20F1F000E9; Mon, 3 Aug 2026 16:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785773828; bh=sk6xlk6RotAQHIR+N71Qjs1WiPc1f3XKjXhaiZnzVAI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=NaVSLzt+5KqdJx5CaYoudXrv+UwKS73A4A0AFsc1s5xfOGxFAtLeFy1rci+f8+GfI TC/aSQtu2GdoKKpSxteVHM5Z5D7hHmgELLkLswwHv54dypFR966HJ/U8JzVSVg5Ceu SRUl40+762Kp3myenhKskDlQZrzlFBH7bWxTWwtGyMRks3bHrTG6Gz11yeEWFHX+YO hhHK4X4mLpJs1gWIQbJz/poTXI9Z4B2LQxGDE91WBfMsZXbEDlcwO8088rfmKyBqzt X+Cm7rJXkbvh0UBoU4/OwWQXNgafgV1osVHwXiuUwFbwZgKEFkSrn9IoP4ysFxwXSw tHLD69QpkJE6g== From: "Matthieu Baerts (NGI0)" Date: Mon, 03 Aug 2026 18:16:36 +0200 Subject: [PATCH net v2 4/8] mptcp: pm: fix data race in add_addr timer callback Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-4-b8f496d71664@kernel.org> References: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> In-Reply-To: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> To: Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Qing Luo , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1972; i=matttbe@kernel.org; h=from:subject:message-id; bh=yRPzTy5hKZEYeq+xcCHW0MQlumNe3rfsdEDdQlVhA5E=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIK9n2w7K7RfnrlTnqin+xM4TazpcJ9BYpVH15FPGxMl XnywW9aRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwEQOsjD8957o7jxxT2FPTo3G g9NBW1M19reF9Ez/VWSvxMyRlPdIg5GhTTHVT3bDwUcHW1fFHSxdeshxmyWvgKeHR3DXohv8Oq8 YAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Qing Luo The timer callback reads entry->retrans_times outside pm.lock to decide whether to call mptcp_pm_subflow_established(). Since mptcp_pm_announced_del_timer() can concurrently set retrans_times =3D ADD_ADDR_RETRANS_MAX under pm.lock, a race condition exists. I discovered this issue while studying the code. AI tools helped me to verify the issue can potentially happen under race conditions. Use a local 'retransmit' flag set inside pm.lock to capture whether retransmission is still possible when the lock is taken. This allows to call mptcp_pm_subflow_established() accordingly, and not depending on the situation that can be different when checked outside the pm.lock. Fixes: 348d5c1dec60 ("mptcp: move to next addr when timeout") Cc: stable@vger.kernel.org Signed-off-by: Qing Luo Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- v2: clarify commit message to avoid possible confusion. (Clashiko) --- net/mptcp/pm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 6afd39aea110..c71dcf887683 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -380,6 +380,7 @@ static void mptcp_pm_add_addr_timer(struct timer_list *= timer) struct mptcp_sock *msk =3D entry->sock; struct sock *sk =3D (struct sock *)msk; unsigned int timeout =3D 0; + bool retransmit; =20 pr_debug("msk=3D%p\n", msk); =20 @@ -412,14 +413,15 @@ static void mptcp_pm_add_addr_timer(struct timer_list= *timer) entry->retrans_times++; } =20 - if (entry->retrans_times < ADD_ADDR_RETRANS_MAX) + retransmit =3D entry->retrans_times < ADD_ADDR_RETRANS_MAX; + if (retransmit) timeout <<=3D entry->retrans_times; else timeout =3D 0; =20 spin_unlock_bh(&msk->pm.lock); =20 - if (entry->retrans_times =3D=3D ADD_ADDR_RETRANS_MAX) + if (!retransmit) mptcp_pm_subflow_established(msk); =20 out: --=20 2.53.0 From nobody Sat Aug 15 20:33:32 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7546838837C; Mon, 3 Aug 2026 16:17:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773832; cv=none; b=OtSobTJJU9plcr4k+LqmC9GB3uVAUdAEjG+pbBq/kEDdWATHRqieA8zB8Iof4AZV69a5/N0bcajSrFiyUz8I8cXNbS48ZEROaHxuCAmRoO5DBc0qR5OAokqTAA5RNh9TJcNjazcY3sxcfkM2oHuD4maG+IgIWvaLnOiqFi/0Oz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773832; c=relaxed/simple; bh=m4x0bxSy6TxsUPrJI6w5irHD5JNUjCHFJQxz6MDrmzA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N1TBj0QQDx7g2LmvaZd9tb+FlY3u0fxUKzSo7/UE87RQWss1RSbUxaVWqYkmqXOFA5DWPbzs2TEIl4p3vCOfGyL+UVu9LpsEtO11IFt2aWVtb3U0+gq55NyKpISO3JZMLhtUUgroiJlPH0NvEgCzQAAKkD8SU4x7ZGr3SyvbgJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ETX0ARW+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ETX0ARW+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 946421F00A3A; Mon, 3 Aug 2026 16:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785773831; bh=mFgngIcB30lySgR+387wwGE2NX/cftkfr18bbdf5vD0=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=ETX0ARW+Jn/ys6uDSy+TVJMDUfgQwAuVIKKHV80gsAlNGTS0TJxFdl6TW+Rts3pPB W5DoijpGogKrrz9x369A/7bw+etoa2ezB18RJsjtp0hFn4Ek+M0Ba1bscAJTJaqab2 ROTBtOu39hksKwhwC1NIPH7QT11wEiEYeF+1nU0Y33w6nYs5/caH33ZD29UmSukp4X pGIeAgr7Yr7C4mJH77mjOSZJiju/AjfR8M/KYIdvZwmQJAcqrFQUDT6YfxVNzGB1To m+7+THVNg03uCSYL3LlvLZdyyLpP+8Pvv/v18enEiZbIyeWRY6FZA+PS0qSpyjYFGJ Pw76SiEGwHrIw== From: "Matthieu Baerts (NGI0)" Date: Mon, 03 Aug 2026 18:16:37 +0200 Subject: [PATCH net v2 5/8] selftests: mptcp: join: mark tests with data corruption as failed Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-5-b8f496d71664@kernel.org> References: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> In-Reply-To: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> To: Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Gang Yan , stable@vger.kernel.org, Shuah Khan , linux-kselftest@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1789; i=matttbe@kernel.org; h=from:subject:message-id; bh=OVf+JQzy7NpD1xgEnXRFt97nQ/5etoH6bLJALYeGoSQ=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIK9n00O5i3f97XW+op7pwB1z7vPFp2f7vV3BuaGw9ks s42WO9l3lHKwiDGxSArpsgi3RaZP/N5FW+Jl58FzBxWJpAhDFycAjARH3+Gf9pPtvT+evKs/d41 qVtFEw2/fd395jbbvv64DOcVif2ZulqMDGeDbZ5W7T93/u13H/sau0kTDm67svGv8IMLiTcOhj/ M3c0GAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Gang Yan check_transfer() compares the input and output files byte-by-byte using `cmp -l "$in" "$out" | while read ...`. Because the while-loop body runs in a subshell (the script sets neither lastpipe nor pipefail), the fail_test call inside it -- which sets the global ret/last_test_failed -- and the `return 1` both act on the subshell, not on check_transfer(). check_transfer() thus always falls through to `return 0`, and any data corruption affecting only the payload (leaving the subflow/PM counters untouched) is silently reported as PASS. Fixes: 8117dac3e7c3 ("selftests: mptcp: add invert check in check_transfer") Cc: stable@vger.kernel.org Assisted-by: Codex:GLM-5.2 Signed-off-by: Gang Yan Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 4 ++-- 1 file changed, 2 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 c0aeffd5cb71..7dc91fac4917 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -584,7 +584,7 @@ check_transfer() mv "$tmpfile" "$out" tmpfile=3D"" fi - cmp -l "$in" "$out" | while read -r i a b; do + while read -r i a b; do local sum=3D$((0${a} + 0${b})) if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then fail_test "$what does not match (in, out):" @@ -595,7 +595,7 @@ check_transfer() else print_info "$what has inverted byte at ${i}" fi - done + done < <(cmp -l "$in" "$out") =20 return 0 } --=20 2.53.0 From nobody Sat Aug 15 20:33:32 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38654392C48; Mon, 3 Aug 2026 16:17:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773835; cv=none; b=ID6sQ1P0VJ9ULOOb0kTJPRPFg5+wxWaRo8DS+mqM/CAvTFb0o2zsig8lVuMAef/YVqrwWjR+VC31K7Sju3jhXFSItQnblrxkim8vCPuZ+uoDC1C2LQNh0+ToKEQqrGX6YTY5k/GU+WYPyp4Pq7j3AiSXwI8OayucS1NMXdfI8Wc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773835; c=relaxed/simple; bh=xnqFISoqTLMCerUD5c4zSjTlfN+SKMko6NaQaLus8dk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NOuNXR4itO1uJYsoa1H4qeebb0LQ7BZ048fCkKvB3qlN9d61MrfB8EJwdPl+YJtOExRvphdDQM+tzpU5zJ66LGdOAG3gHcLNiN21Z/F5+NJkACHKhkrfcF84kQRTP3fo+dAL5hK9UG/lcYtrwYN7zIV+iQ9ASDs6y7T2AEOnzbo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NyHYZb8S; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NyHYZb8S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 748551F000E9; Mon, 3 Aug 2026 16:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785773833; bh=j4Eph3k7INwhaL5Gv4jnG9wsbDawQ3A4kZn6N6ISjdc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=NyHYZb8SvWK3YIZFKUCqRZjaTsIrlePTuMXayKGAo2k5FOYmCO/vbsIvElTEXuk+5 m5hpZdV57Q+sjEcSXbgfxTYMnPIVYeqPQDedEo43s0PKGr2sTiMUFToixMb+gi7Nza r4fwSdfQqlcBv0lPZc5Kdluq3Yyjq75ofWfmZlz4GNDRIIIky1U8VbayQzGEwN0k00 S/rCCoQA5GW5qSBFvUJl18ii1Skz5P2x0NZKhfHrYCTtazN4sUjhOsQrbwoCuBUGqp b9/7CKLIjS60Ocmax4z0epsR7yYym7Hbzw2Fyhk39gQuSoZadNCBsV6ae+GVIotB0F 9LEzMcVRgKTdg== From: "Matthieu Baerts (NGI0)" Date: Mon, 03 Aug 2026 18:16:38 +0200 Subject: [PATCH net v2 6/8] mptcp: pm: fix memory leak from alloc-during-teardown race Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-6-b8f496d71664@kernel.org> References: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> In-Reply-To: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> To: Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Shardul Bankar , stable@vger.kernel.org, Kishen Maloor X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4572; i=matttbe@kernel.org; h=from:subject:message-id; bh=HhsABg2acSkM/Qyo/cPU//Pg2lIC3VAwQp0iPEbLdOk=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIK9n2aOj/85pGZdX8M5N42T9TIVdloHVWpkdnPbaXBG //18ZWLHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABNZHszI8PrHNJs56seVs+4s +2Bvy7dF3LvlX5RPkuWJtWzNR9iS2Rn+cLvZL31eOi2pL/qLcGem6U4j9oPbt0WItX5cUG/i8E2 ZFQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Shardul Bankar mptcp_pm_destroy() empties msk->pm.anno_list and msk->pm.userspace_pm_local_addr_list under msk->pm.lock during socket teardown, dropping the lock between the two. A concurrent userspace PM genl ANNOUNCE on the same msk holds a sock reference via mptcp_token_get_sock() and, in mptcp_pm_nl_announce_doit(), calls mptcp_userspace_pm_append_new_local_addr() and mptcp_pm_announced_alloc(). Both take msk->pm.lock briefly to add to their respective lists. Because the genl handler holds a sock reference, mptcp_pm_destroy() may run on the same msk via mptcp_disconnect(), which invokes mptcp_destroy_common() without dropping the sock refcount, before the handler completes. If the lock acquisitions interleave such that mptcp_pm_destroy() empties a list first, the later alloc adds its entry to a list head that nothing else iterates for this msk, and the entry leaks. kmemleak reports both mptcp_pm_add_addr objects (from mptcp_pm_announced_alloc()) and mptcp_pm_addr_entry objects (from mptcp_userspace_pm_append_new_local_addr()) under sustained concurrent ANNOUNCE + close load against the userspace PM. Add an MPTCP_PM_DESTROYING bit in msk->pm.status, set by mptcp_pm_destroy() under pm.lock before the lists are emptied and checked under pm.lock by the alloc paths. Either the alloc takes pm.lock first, in which case its entry is on the list when mptcp_pm_destroy() frees it; or mptcp_pm_destroy() takes pm.lock first, in which case the later alloc observes the bit and refuses. Found by an MPTCP protocol-flow harness extending BRF (arXiv:2305.08782). Fixes: 9ab4807c84a4 ("mptcp: netlink: Add MPTCP_PM_CMD_ANNOUNCE") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Shardul Bankar Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- Cc: Kishen Maloor v2: New. --- net/mptcp/pm.c | 13 +++++++++++-- net/mptcp/pm_userspace.c | 4 ++++ net/mptcp/protocol.h | 7 ++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index c71dcf887683..64a1236aabee 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -443,6 +443,9 @@ bool mptcp_pm_announced_alloc(struct mptcp_sock *msk, =20 lockdep_assert_held(&msk->pm.lock); =20 + if (msk->pm.status & BIT(MPTCP_PM_DESTROYING)) + return false; + add_entry =3D mptcp_pm_announced_lookup(msk, addr); if (add_entry) { if (WARN_ON_ONCE(mptcp_pm_is_kernel(msk))) @@ -1145,10 +1148,16 @@ void mptcp_pm_worker(struct mptcp_sock *msk) =20 void mptcp_pm_destroy(struct mptcp_sock *msk) { + spin_lock_bh(&msk->pm.lock); + msk->pm.status |=3D BIT(MPTCP_PM_DESTROYING); + spin_unlock_bh(&msk->pm.lock); + mptcp_pm_free_announced_list(msk); =20 - if (mptcp_pm_is_userspace(msk)) - mptcp_userspace_pm_free_local_addr_list(msk); + /* Free the userspace local address list unconditionally: the socket + * can be reused (mptcp_disconnect()) and re-selected to a different PM + */ + mptcp_userspace_pm_free_local_addr_list(msk); } =20 void mptcp_pm_data_reset(struct mptcp_sock *msk) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 945aa5afc2dd..2203cc2d2748 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -54,6 +54,10 @@ static int mptcp_userspace_pm_append_new_local_addr(stru= ct mptcp_sock *msk, bitmap_zero(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); =20 spin_lock_bh(&msk->pm.lock); + if (msk->pm.status & BIT(MPTCP_PM_DESTROYING)) { + ret =3D -EINVAL; + goto append_err; + } mptcp_for_each_userspace_pm_addr(msk, e) { addr_match =3D mptcp_addresses_equal(&e->addr, &entry->addr, true); if (addr_match && entry->addr.id =3D=3D 0 && needs_id) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index c13680d18994..1b80f2d6ec5a 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -190,9 +190,10 @@ enum mptcp_pm_status { MPTCP_PM_ESTABLISHED, MPTCP_PM_SUBFLOW_ESTABLISHED, MPTCP_PM_ALREADY_ESTABLISHED, /* persistent status, set after ESTABLISHED= event */ - MPTCP_PM_MPC_ENDPOINT_ACCOUNTED /* persistent status, set after MPC local= address is - * accounted int id_avail_bitmap - */ + MPTCP_PM_MPC_ENDPOINT_ACCOUNTED, /* persistent status, set after MPC loca= l address is + * accounted int id_avail_bitmap + */ + MPTCP_PM_DESTROYING, /* To fence out PM list allocs */ }; =20 enum mptcp_pm_type { --=20 2.53.0 From nobody Sat Aug 15 20:33:32 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8BD03E5A38; Mon, 3 Aug 2026 16:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773839; cv=none; b=Nj7OpcyEhbzdjnbFZ4dyyGsuPRCjmxdMzeKE+eQS3SbvPchiJhHyqay1PIYfEimAm5byRfLlPcNcmG2QPargn5Piq7j3J1+kJNaUsRlFWOMIYISQwDJqhEwFFqc2ZwEDxTJkKONCiSW4TW9eeJ633rOKAmggjcKsUK1zKjW+8XU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773839; c=relaxed/simple; bh=a50rDkuPZo2+Ajw0lTnGCH+IgCJD/gdXH5g/0VvRJ24=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=n3ojUYmaof5+n1mxTc4kX/nmd9K9C5lquJPmLWcsBWwokTzAK7IevAI1iLAocAsgXGXxFGpS08pY2Qz3cq4gbZSvVA775ZzwWN/U3L5LYEW7u45TOO7UZjwmuopswavEFa0WI+Zn1/GDSu8UBoiJGw7ZD0uiFeU2qqpiBVF55Gg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LtcfDLrP; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LtcfDLrP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EA8E1F00A3A; Mon, 3 Aug 2026 16:17:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785773837; bh=MFsCO3HIEA7tvcBR0h/SaDgADYrMrUwYc79JJ2kD76w=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=LtcfDLrPTfb8aMCeNf3qxn8Dxt9gtkybaz4wIexP7zshbyh0E17KhdWOPOmC9FGLL Af97eDj7/orDNhzdNnZWb3BLfY+Y+f6QuNlCL/tQGGhm9KjRuaEKhXgb7ZJuontnSz Y2iDbBKOcfgrBBge9iVD9sD0beL88nE9EYhFx3Je9S9vZHCLUUX6h0D8VNjnrUYH2b 7gt/w88FucoW8/a7/sfyaeIaQE8qJzqrfQk0jE/7K9aqZK4d0P9ktbvzJtECSD8OAQ RfWZxJMkjLiMAevPtlxsi+mqvc+wBt1gK8x/MSPIIpnAtiYErO5WNkBvvsqizbTG84 pHJxA68jN8ifQ== From: "Matthieu Baerts (NGI0)" Date: Mon, 03 Aug 2026 18:16:39 +0200 Subject: [PATCH net v2 7/8] mptcp: fastopen: only mark MPTFO subflows with SYN data Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-7-b8f496d71664@kernel.org> References: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> In-Reply-To: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> To: Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Wyatt Feng , stable@vger.kernel.org, Yuan Tan , Yifan Wu , Juefei Pu , Zhengchuan Liang , Xin Liu , Ren Wei , Dmytro Shytyi X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2405; i=matttbe@kernel.org; h=from:subject:message-id; bh=m4h2VvVXoQsxyUp0cTHCmA7BgFqI3pJF+c4g9B5voAg=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIK9n2eG6h5sbvhZbqGAPehXylbrhjz6CU9Xsh02Zerp +Vv54ztHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABMxmsfwP92sf5ZR1PTKav6K L+wMsdPjLaqA/Or779tfGgZMUedi+Gd7P+3dvvy1yf+Tn85TEfx4RnVf8JLJnQeNM0wW1V68s5w VAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Wyatt Feng Passive TCP Fast Open accepts a valid-cookie SYN even when it carries no data. In that case the child socket's receive queue is intentionally left empty. mptcp_fastopen_subflow_synack_set_params() set is_mptfo before checking for queued SYN data. That made data-less TFO SYNs hit a WARN and, if the warning was non-fatal, left stale MPTFO state behind. The stale flag could later trigger a state-confusion bug in check_fully_established(). Only mark the subflow as MPTFO after confirming that an SKB was queued. Return quietly when the receive queue is empty. Note that mptcp_subflow_context's is_mptfo field is now not just about subflows where the TFO was present, but about MPTFO subflow that consumed SYN data. Only having a valid cookie but not carrying data is not really "doing TFO". Fixes: 36b122baf6a8 ("mptcp: add subflow_v(4,6)_send_synack()") Cc: stable@vger.kernel.org Reported-by: Yuan Tan Reported-by: Yifan Wu Reported-by: Juefei Pu Reported-by: Zhengchuan Liang Reported-by: Xin Liu Assisted-by: Codex:GPT-5.4 Signed-off-by: Wyatt Feng Signed-off-by: Ren Wei Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- Cc: Dmytro Shytyi Note: a v1 has already been shared alone on the netdev ML: https://patch.msgid.link/81f26b8fddd59ebb6cecc417fb138d9ff5214e08.1780458= 440.git.bronzed_45_vested@icloud.com v2: update commit message to reply to AI reviews. (Clashiko) --- net/mptcp/fastopen.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c index 082c46c0f50e..f717750906ff 100644 --- a/net/mptcp/fastopen.c +++ b/net/mptcp/fastopen.c @@ -24,12 +24,13 @@ void mptcp_fastopen_subflow_synack_set_params(struct mp= tcp_subflow_context *subf sk =3D subflow->conn; tp =3D tcp_sk(ssk); =20 - subflow->is_mptfo =3D 1; - + /* A valid TFO cookie does not guarantee SYN data. */ skb =3D skb_peek(&ssk->sk_receive_queue); - if (WARN_ON_ONCE(!skb)) + if (!skb) return; =20 + subflow->is_mptfo =3D 1; + /* dequeue the skb from sk receive queue */ __skb_unlink(skb, &ssk->sk_receive_queue); skb_ext_reset(skb); --=20 2.53.0 From nobody Sat Aug 15 20:33:32 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45395411FA3; Mon, 3 Aug 2026 16:17:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773841; cv=none; b=m/mTwQVvc87kGAZa+vl+j1q+mEBu4/ub1StOoyPVBRcxUXSsDUFlf3d44stcPjmVPDm2fgqAX7sXqGo6tnbzJ+vZ13p+iwZPQtXPNZr5cUyWwPF9KvTmPoODMtZ3ggi22iH8ngDQEcGXnojjY5HTiBdlavNys6bSXq3zyiEKWaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785773841; c=relaxed/simple; bh=2LCtQYaFHMYShjE0L774cau909DKU6IxvzHD3daSzt8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BjeVjHgNKbQuGIvYls2TrHLXbkMdjNaawEmO9vxyrAm7T03dSu+Fn5JfQiCv2m/QNKqheA73e5pQJxFiWXJjQa9RBTT4pvRSk80P41nkXKC7UwMoypYsyjfvFJ7mo5R2/Nv2e0h6FjkkgggG/fSv+UjOHFtmQYBaXAk1rEoDlAY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZXb5lbk3; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZXb5lbk3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC3F31F000E9; Mon, 3 Aug 2026 16:17:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785773839; bh=CHz7hPGcuGQaXXaAvcxIgvtwBW6pE1qWtUMNAIp/Hpw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=ZXb5lbk3U2Cm5cd/gEH44ystsRNdr1zre2oUmXbG8QEnqE77841Z857R3YWC3pDg7 B0tAEJeDTt5/7fBYcPRUdixNKbpkdYDPURnHy4di3jGnJFEUKn76O9+7TMWW4HEuZb CIdAjNFxYNcRfshGef/LJhbDJYjGABYPxxyNYwRZ46hkUd6mmX0NumNP+ao8AfP1zB m22e0F1SYV/dNPL9HBtAZjJSs/h82zlSJqvsNxs7iIEpZ+ivHNBUKxt38Q0EGPAyCr LIyGuSxC04oEveYZQYSuGPLe9JWR9NWGvtzhc0DitPGwlvwuJRApcFoXHy3U+8AzCi RmVVELdv/zbJw== From: "Matthieu Baerts (NGI0)" Date: Mon, 03 Aug 2026 18:16:40 +0200 Subject: [PATCH net v2 8/8] mptcp: reclaim forward-allocated memory on RX path errors Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-8-b8f496d71664@kernel.org> References: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> In-Reply-To: <20260803-net-mptcp-misc-fixes-7-2-rc6-v2-0-b8f496d71664@kernel.org> To: Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1341; i=matttbe@kernel.org; h=from:subject:message-id; bh=13ycqCYB6Icqk3NK7EG0GaWaP44YW7kNbjVu5JUlTgc=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIK9n2RaFxZbX1qsdwdSfa7ps8W371q1Kye9mfeCt+mS 1+299cs7yhlYRDjYpAVU2SRbovMn/m8irfEy88CZg4rE8gQBi5OAZiI1WZGhm7LDVtfKlxxmz6x 9lJHaMlmfjXmK4s5LMvtero0TnH/cGb4X7v3tuWJ640GO56uZIqtPfd0cvjh3ws3bpE/oraoYfb 0r9wA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni After commit 9db5b3cec4ec ("mptcp: borrow forward memory from subflow"), errors in the receive path prior to queueing skbs into the receive queue do not trigger forward-allocated memory reclaiming. Prevent forward memory from growing unboundedly in pathological drop scenarios by explicitly reclaiming memory when skbs are dropped. Fixes: 9db5b3cec4ec ("mptcp: borrow forward memory from subflow") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- v2: Start comment on the same line as the opening /*, like in most places in the code. (Clashiko) --- net/mptcp/protocol.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index ca644ec53eed..7c8180d8d5ef 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -149,6 +149,12 @@ struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk) =20 static void mptcp_drop(struct sock *sk, struct sk_buff *skb) { + /* The skb forward memory was already transferred to sk by + * mptcp_borrow_fwdmem(), even before setting the destructor. + */ + if (!skb->destructor) + sk_mem_reclaim(sk); + sk_drops_skbadd(sk, skb); __kfree_skb(skb); } --=20 2.53.0