Skip to content

Commit d3ab788

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: fix NULL ptr dereference on bad MPJ
If an msk listener receives an MPJ carrying an invalid token, it will zero the request socket msk entry. That should later cause fallback and subflow reset - as per RFC - at subflow_syn_recv_sock() time due to failing hmac validation. Since commit 4cf8b7e ("subflow: introduce and use mptcp_can_accept_new_subflow()"), we unconditionally dereference - in mptcp_can_accept_new_subflow - the subflow request msk before performing hmac validation. In the above scenario we hit a NULL ptr dereference. Address the issue doing the hmac validation earlier. Fixes: 4cf8b7e ("subflow: introduce and use mptcp_can_accept_new_subflow()") Tested-by: Davide Caratti <dcaratti@redhat.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net> Link: https://lore.kernel.org/r/03b2cfa3ac80d8fc18272edc6442a9ddf0b1e34e.1606400227.git.pabeni@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 69929d4 commit d3ab788

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

net/mptcp/subflow.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,8 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
543543
fallback = true;
544544
} else if (subflow_req->mp_join) {
545545
mptcp_get_options(skb, &mp_opt);
546-
if (!mp_opt.mp_join ||
547-
!mptcp_can_accept_new_subflow(subflow_req->msk) ||
548-
!subflow_hmac_valid(req, &mp_opt)) {
546+
if (!mp_opt.mp_join || !subflow_hmac_valid(req, &mp_opt) ||
547+
!mptcp_can_accept_new_subflow(subflow_req->msk)) {
549548
SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKMAC);
550549
fallback = true;
551550
}

0 commit comments

Comments
 (0)