From nobody Fri Oct 31 23:15:44 2025 Received: from localhost.localdomain (unknown [147.136.157.2]) (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 4931F2BE639; Mon, 20 Oct 2025 06:05:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=147.136.157.2 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760940336; cv=none; b=BUMvIgn5LkE5C/IrYIGFkfnaCwLOgNk4ueYodlw2godPJrVtfrfxM9S+tkkpdxykTkJf92bWyqXVcBjuKf8ipqTAuf1veOQcncJ7cZaPCVU4Cn2foyopGFxqpWKvQDHz0gBi+YOlHaDqruyI6kbVjZMnPSliET3QN3kJUyCdUak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760940336; c=relaxed/simple; bh=1/HqfASDzN/dipcY4CxVwURrIOHCfdF++Wl28FlaoWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fSgO1dDgy9N+nZUY8Q+gOS8Sq0a+jIgZ1k9mT7lQ9j4PDvpbsvcQMowWlmBGOh0AQJvf5IIZPwk1k877kp7f8NR2I7UCpPuQr0ThKYDUQIQ09loShzTxxOC+hhG30sdV+9BYXUR414PE+qqhGPjkM5MlHs3hfXzTTrA9wzftZmA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev; spf=none smtp.mailfrom=localhost.localdomain; arc=none smtp.client-ip=147.136.157.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=localhost.localdomain Received: by localhost.localdomain (Postfix, from userid 1007) id 962B78B2A5B; Mon, 20 Oct 2025 14:05:33 +0800 (+08) From: Jiayuan Chen To: mptcp@lists.linux.dev, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: Jiayuan Chen , Eric Dumazet , Kuniyuki Iwashima , Paolo Abeni , Willem de Bruijn , John Fastabend , Jakub Sitnicki , "David S. Miller" , Jakub Kicinski , Simon Horman , Matthieu Baerts , Mat Martineau , Geliang Tang , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Florian Westphal , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH net v2 2/3] bpf,sockmap: disallow MPTCP sockets from sockmap updates Date: Mon, 20 Oct 2025 14:04:47 +0800 Message-ID: <20251020060503.325369-3-jiayuan.chen@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251020060503.325369-1-jiayuan.chen@linux.dev> References: <20251020060503.325369-1-jiayuan.chen@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" MPTCP creates subflows for data transmission, and these sockets should not be added to sockmap because MPTCP sets specialized data_ready handlers that would be overridden by sockmap. Additionally, for the parent socket of MPTCP subflows (plain TCP socket), MPTCP sk requires specific protocol handling that conflicts with sockmap's operation(mptcp_prot). This patch adds proper checks to reject MPTCP subflows and their parent sockets from being added to sockmap, while preserving compatibility with reuseport functionality for listening MPTCP sockets. Fixes: 0b4f33def7bb ("mptcp: fix tcp fallback crash") Signed-off-by: Jiayuan Chen --- net/core/sock_map.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/core/sock_map.c b/net/core/sock_map.c index 5947b38e4f8b..da21deb970b3 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -535,6 +535,15 @@ static bool sock_map_redirect_allowed(const struct soc= k *sk) =20 static bool sock_map_sk_is_suitable(const struct sock *sk) { + if ((sk_is_tcp(sk) && sk_is_mptcp(sk)) /* subflow */ || + (sk->sk_protocol =3D=3D IPPROTO_MPTCP && sk->sk_state !=3D TCP_LISTEN= )) { + /* Disallow MPTCP subflows and their parent socket. + * However, a TCP_LISTEN MPTCP socket is permitted because + * sockmap can also serve for reuseport socket selection. + */ + pr_err_once("sockmap: MPTCP sockets are not supported\n"); + return false; + } return !!sk->sk_prot->psock_update_sk_prot; } =20 --=20 2.43.0