Skip to content

Commit d6692b3

Browse files
Florian Westphalkuba-moo
authored andcommitted
mptcp: clear 'kern' flag from fallback sockets
The mptcp ULP extension relies on sk->sk_sock_kern being set correctly: It prevents setsockopt(fd, IPPROTO_TCP, TCP_ULP, "mptcp", 6); from working for plain tcp sockets (any userspace-exposed socket). But in case of fallback, accept() can return a plain tcp sk. In such case, sk is still tagged as 'kernel' and setsockopt will work. This will crash the kernel, The subflow extension has a NULL ctx->conn mptcp socket: BUG: KASAN: null-ptr-deref in subflow_data_ready+0x181/0x2b0 Call Trace: tcp_data_ready+0xf8/0x370 [..] Fixes: cf7da0d ("mptcp: Create SUBFLOW socket for incoming connections") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 404cd9a commit d6692b3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/mptcp/protocol.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2879,7 +2879,7 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,
28792879
*/
28802880
if (WARN_ON_ONCE(!new_mptcp_sock)) {
28812881
tcp_sk(newsk)->is_mptcp = 0;
2882-
return newsk;
2882+
goto out;
28832883
}
28842884

28852885
/* acquire the 2nd reference for the owning socket */
@@ -2891,6 +2891,8 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,
28912891
MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK);
28922892
}
28932893

2894+
out:
2895+
newsk->sk_kern_sock = kern;
28942896
return newsk;
28952897
}
28962898

0 commit comments

Comments
 (0)