From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5AC5727FB1E for ; Mon, 24 Nov 2025 15:18:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763997497; cv=none; b=SJ6SprDixYucHqiReBUMrmDYC2iwcuVSC8CUKnxglgsOM5X3yHxC4N8EyxpWVoCgS+eBBb3x4qw7dfb/2itQFyL+rSjv/OA57cZVNTZAspGn0hvhVaYNiJfuaulSsIe+MIYFh49v7cyOCbMSbv9sZPzqsuRhU0RtJu8i3KT3gyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763997497; c=relaxed/simple; bh=VnYpBaS1qm++v5FNPQCDvu/yoFuHcvHXNZAs+lMwdnM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qotPnf/5uVt2df7gKwdNw6fTJODlaUmYKZxFDbpTXaQ8by6EgOwafXB4pZEae5UXzu2OvqdZGKoMyYJHfSKhkCad5XR/esw84xBQAPyirAShRjRKr1g3r1bg/kJ56KEM6f2xSHrH4duUIB9z681x9/3dZGmGdMHnTk5UyYVPnMg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o6kFoVZD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o6kFoVZD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BBDAC4CEF1; Mon, 24 Nov 2025 15:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763997496; bh=VnYpBaS1qm++v5FNPQCDvu/yoFuHcvHXNZAs+lMwdnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o6kFoVZDgS6WB3Spa6BZkPnnWikzzuVpjNVsKavh7YjyLmyeMbKErIj0+OdnD2vmx S+0DqzKAURib5VKLZwKHpL8z08d4BZLWmXaSflcXgm1+0ONau6O853xG7E7BEeEDON iHkzWRmdpOzrq3sBArXXYxVpkM8lTnsq1zCBivQv+4mj6jTOER7n1zjJRZk4v4Xzeq kdmAoyiXzfh9NK3g/0erLyhxcNgIqC8BTw/vHfrTgyRjbAoPbFD6OaUOh53IviW5KP fv+MTp9Lol8N30Sjke7qXx/C8ct2ClQPUlvjof+62JmSxm9okGrkpq/11tlE8R99iY aKtH9ebSR1tQA== From: Sasha Levin To: stable@vger.kernel.org Cc: Jiayuan Chen , Martin KaFai Lau , "Matthieu Baerts (NGI0)" , Sasha Levin Subject: [PATCH 5.15.y] mptcp: Disallow MPTCP subflows from sockmap Date: Mon, 24 Nov 2025 10:18:14 -0500 Message-ID: <20251124151814.4126349-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2025112454-crib-recognize-8675@gregkh> References: <2025112454-crib-recognize-8675@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jiayuan Chen [ Upstream commit fbade4bd08ba52cbc74a71c4e86e736f059f99f7 ] The sockmap feature allows bpf syscall from userspace, or based on bpf sockops, replacing the sk_prot of sockets during protocol stack processing with sockmap's custom read/write interfaces. ''' tcp_rcv_state_process() subflow_syn_recv_sock() tcp_init_transfer(BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB) bpf_skops_established <== sockops bpf_sock_map_update(sk) <== call bpf helper tcp_bpf_update_proto() <== update sk_prot ''' Consider two scenarios: 1. When the server has MPTCP enabled and the client also requests MPTCP, the sk passed to the BPF program is a subflow sk. Since subflows only handle partial data, replacing their sk_prot is meaningless and will cause traffic disruption. 2. When the server has MPTCP enabled but the client sends a TCP SYN without MPTCP, subflow_syn_recv_sock() performs a fallback on the subflow, replacing the subflow sk's sk_prot with the native sk_prot. ''' subflow_ulp_fallback() subflow_drop_ctx() mptcp_subflow_ops_undo_override() ''' Subsequently, accept::mptcp_stream_accept::mptcp_fallback_tcp_ops() converts the subflow to plain TCP. For the first case, we should prevent it from being combined with sockmap by setting sk_prot->psock_update_sk_prot to NULL, which will be blocked by sockmap's own flow. For the second case, since subflow_syn_recv_sock() has already restored sk_prot to native tcp_prot/tcpv6_prot, no further action is needed. Fixes: cec37a6e41aa ("mptcp: Handle MP_CAPABLE options for outgoing connections") Signed-off-by: Jiayuan Chen Signed-off-by: Martin KaFai Lau Reviewed-by: Matthieu Baerts (NGI0) Cc: Link: https://patch.msgid.link/20251111060307.194196-2-jiayuan.chen@linux.dev [ Adjust context ] Signed-off-by: Sasha Levin --- net/mptcp/subflow.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index f67d8c98d58a5..941ef15cbc48a 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1854,6 +1854,10 @@ void __init mptcp_subflow_init(void) tcp_prot_override = tcp_prot; tcp_prot_override.release_cb = tcp_release_cb_override; +#ifdef CONFIG_BPF_SYSCALL + /* Disable sockmap processing for subflows */ + tcp_prot_override.psock_update_sk_prot = NULL; +#endif #if IS_ENABLED(CONFIG_MPTCP_IPV6) /* In struct mptcp_subflow_request_sock, we assume the TCP request sock @@ -1887,6 +1891,10 @@ void __init mptcp_subflow_init(void) tcpv6_prot_override = tcpv6_prot; tcpv6_prot_override.release_cb = tcp_release_cb_override; +#ifdef CONFIG_BPF_SYSCALL + /* Disable sockmap processing for subflows */ + tcpv6_prot_override.psock_update_sk_prot = NULL; +#endif #endif mptcp_diag_subflow_init(&subflow_ulp_ops); -- 2.51.0