netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v1] mptcp: fix incorrect IPv4/IPv6 check
@ 2025-10-14 12:26 Jiayuan Chen
  2025-10-14 15:27 ` Matthieu Baerts
  0 siblings, 1 reply; 4+ messages in thread
From: Jiayuan Chen @ 2025-10-14 12:26 UTC (permalink / raw)
  To: mptcp, linux-kernel
  Cc: Jiayuan Chen, Matthieu Baerts, Mat Martineau, Geliang Tang,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Davide Caratti, netdev

When MPTCP falls back to normal TCP, it needs to reset proto_ops. However,
for sockmap and TLS, they have their own custom proto_ops, so simply
checking sk->sk_prot is insufficient.

For example, an IPv6 request might incorrectly follow the IPv4 code path,
leading to kernel panic.

Note that Golang has enabled MPTCP by default [1]

[1] https://go-review.googlesource.com/c/go/+/607715

Fixes: 8e2b8a9fa512 ("mptcp: don't overwrite sock_ops in mptcp_is_tcpsk()")
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
 net/mptcp/protocol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 0292162a14ee..efcdaeff91f8 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -62,10 +62,10 @@ static u64 mptcp_wnd_end(const struct mptcp_sock *msk)
 static const struct proto_ops *mptcp_fallback_tcp_ops(const struct sock *sk)
 {
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
-	if (sk->sk_prot == &tcpv6_prot)
+	if (sk->sk_family == AF_INET6)
 		return &inet6_stream_ops;
 #endif
-	WARN_ON_ONCE(sk->sk_prot != &tcp_prot);
+	WARN_ON(sk->sk_family != AF_INET);
 	return &inet_stream_ops;
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-23 14:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-14 12:26 [PATCH net-next v1] mptcp: fix incorrect IPv4/IPv6 check Jiayuan Chen
2025-10-14 15:27 ` Matthieu Baerts
2025-10-15 14:16   ` Jiayuan Chen
2025-10-23 14:00     ` Matthieu Baerts

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).