From: "Jiayuan Chen" <jiayuan.chen@linux.dev>
To: "Jakub Sitnicki" <jakub@cloudflare.com>
Cc: mptcp@lists.linux.dev, netdev@vger.kernel.org,
bpf@vger.kernel.org, "Eric Dumazet" <edumazet@google.com>,
"Kuniyuki Iwashima" <kuniyu@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Willem de Bruijn" <willemb@google.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Simon Horman" <horms@kernel.org>,
"Matthieu Baerts" <matttbe@kernel.org>,
"Mat Martineau" <martineau@kernel.org>,
"Geliang Tang" <geliang@kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
"Shuah Khan" <shuah@kernel.org>,
"Florian Westphal" <fw@strlen.de>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net v2 2/3] bpf,sockmap: disallow MPTCP sockets from sockmap updates
Date: Tue, 21 Oct 2025 12:16:33 +0000 [thread overview]
Message-ID: <f03db434053928c2bc19fe8ffbae06cd06425668@linux.dev> (raw)
In-Reply-To: <87cy6gwmvk.fsf@cloudflare.com>
October 21, 2025 at 18:49, "Jakub Sitnicki" <jakub@cloudflare.com mailto:jakub@cloudflare.com?to=%22Jakub%20Sitnicki%22%20%3Cjakub%40cloudflare.com%3E > wrote:
>
> On Mon, Oct 20, 2025 at 02:04 PM +08, Jiayuan Chen wrote:
>
> >
> > 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 <jiayuan.chen@linux.dev>
> > ---
> > 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 sock *sk)
> >
> > static bool sock_map_sk_is_suitable(const struct sock *sk)
> > {
> > + if ((sk_is_tcp(sk) && sk_is_mptcp(sk)) /* subflow */ ||
> > + (sk->sk_protocol == IPPROTO_MPTCP && sk->sk_state != 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;
> > }
> >
> You're checking sk_state without sk_lock held. That doesn't seem right.
> Take a look how we always call sock_map_sk_state_allowed() after
> grabbing the lock.
> Same might apply to sk_is_mptcp(). Please double check.
>
Thank you for the suggestion. It seems more appropriate to place this logic
inside sock_map_sk_state_allowed().
next prev parent reply other threads:[~2025-10-21 12:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 6:04 [PATCH net v2 0/3] mptcp: Fix conflicts between MPTCP and sockmap Jiayuan Chen
2025-10-20 6:04 ` [PATCH net v2 1/3] net,mptcp: fix incorrect IPv4/IPv6 fallback detection with BPF Sockmap Jiayuan Chen
2025-10-21 10:24 ` Jakub Sitnicki
2025-10-20 6:04 ` [PATCH net v2 2/3] bpf,sockmap: disallow MPTCP sockets from sockmap updates Jiayuan Chen
2025-10-21 10:49 ` Jakub Sitnicki
2025-10-21 12:16 ` Jiayuan Chen [this message]
2025-10-20 6:04 ` [PATCH net v2 3/3] selftests/bpf: Add mptcp test with sockmap Jiayuan Chen
2025-10-23 10:18 ` Jakub Sitnicki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f03db434053928c2bc19fe8ffbae06cd06425668@linux.dev \
--to=jiayuan.chen@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=geliang@kernel.org \
--cc=haoluo@google.com \
--cc=horms@kernel.org \
--cc=jakub@cloudflare.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=willemb@google.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).