summaryrefslogtreecommitdiff
path: root/net/mptcp/syncookies.c
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2021-09-24 03:04:11 +0300
committerDavid S. Miller <davem@davemloft.net>2021-09-24 12:51:36 +0300
commitea1300b9df7c8e8b65695a08b8f6aaf4b25fec9c (patch)
treef43dbc42ad77111069190f44356c68ca7260f4ff /net/mptcp/syncookies.c
parentf7e745f8e94492a8ac0b0a26e25f2b19d342918f (diff)
downloadlinux-ea1300b9df7c8e8b65695a08b8f6aaf4b25fec9c.tar.xz
mptcp: don't return sockets in foreign netns
mptcp_token_get_sock() may return a mptcp socket that is in a different net namespace than the socket that received the token value. The mptcp syncookie code path had an explicit check for this, this moves the test into mptcp_token_get_sock() function. Eventually token.c should be converted to pernet storage, but such change is not suitable for net tree. Fixes: 2c5ebd001d4f0 ("mptcp: refactor token container") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mptcp/syncookies.c')
-rw-r--r--net/mptcp/syncookies.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/net/mptcp/syncookies.c b/net/mptcp/syncookies.c
index 37127781aee9..7f22526346a7 100644
--- a/net/mptcp/syncookies.c
+++ b/net/mptcp/syncookies.c
@@ -108,18 +108,12 @@ bool mptcp_token_join_cookie_init_state(struct mptcp_subflow_request_sock *subfl
e->valid = 0;
- msk = mptcp_token_get_sock(e->token);
+ msk = mptcp_token_get_sock(net, e->token);
if (!msk) {
spin_unlock_bh(&join_entry_locks[i]);
return false;
}
- /* If this fails, the token got re-used in the mean time by another
- * mptcp socket in a different netns, i.e. entry is outdated.
- */
- if (!net_eq(sock_net((struct sock *)msk), net))
- goto err_put;
-
subflow_req->remote_nonce = e->remote_nonce;
subflow_req->local_nonce = e->local_nonce;
subflow_req->backup = e->backup;
@@ -128,11 +122,6 @@ bool mptcp_token_join_cookie_init_state(struct mptcp_subflow_request_sock *subfl
subflow_req->msk = msk;
spin_unlock_bh(&join_entry_locks[i]);
return true;
-
-err_put:
- spin_unlock_bh(&join_entry_locks[i]);
- sock_put((struct sock *)msk);
- return false;
}
void __init mptcp_join_cookie_init(void)