Skip to content

Commit 3988460

Browse files
Paolo Abenidavem330
authored andcommitted
mptcp: fix NULL ptr dereference in MP_JOIN error path
When token lookup on MP_JOIN 3rd ack fails, the server socket closes with a reset the incoming child. Such socket has the 'is_mptcp' flag set, but no msk socket associated - due to the failed lookup. While crafting the reset packet mptcp_established_options_mp() will try to dereference the child's master socket, causing a NULL ptr dereference. This change addresses the issue with explicit fallback to TCP in such error path. Fixes: 729cd64 ("mptcp: cope better with MP_JOIN failure") Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b0c19ed commit 3988460

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

net/mptcp/subflow.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,20 @@ static void subflow_ulp_fallback(struct sock *sk,
413413
tcp_sk(sk)->is_mptcp = 0;
414414
}
415415

416+
static void subflow_drop_ctx(struct sock *ssk)
417+
{
418+
struct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);
419+
420+
if (!ctx)
421+
return;
422+
423+
subflow_ulp_fallback(ssk, ctx);
424+
if (ctx->conn)
425+
sock_put(ctx->conn);
426+
427+
kfree_rcu(ctx, rcu);
428+
}
429+
416430
static struct sock *subflow_syn_recv_sock(const struct sock *sk,
417431
struct sk_buff *skb,
418432
struct request_sock *req,
@@ -485,10 +499,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
485499
if (fallback_is_fatal)
486500
goto dispose_child;
487501

488-
if (ctx) {
489-
subflow_ulp_fallback(child, ctx);
490-
kfree_rcu(ctx, rcu);
491-
}
502+
subflow_drop_ctx(child);
492503
goto out;
493504
}
494505

@@ -537,6 +548,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
537548
return child;
538549

539550
dispose_child:
551+
subflow_drop_ctx(child);
540552
tcp_rsk(req)->drop_req = true;
541553
tcp_send_active_reset(child, GFP_ATOMIC);
542554
inet_csk_prepare_for_destroy_sock(child);

0 commit comments

Comments
 (0)