Skip to content

Commit

Permalink
mptcp: dispose initial struct socket when its subflow is closed
Browse files Browse the repository at this point in the history
Christoph Paasch reported following crash:
dst_release underflow
WARNING: CPU: 0 PID: 1319 at net/core/dst.c:175 dst_release+0xc1/0xd0 net/core/dst.c:175
CPU: 0 PID: 1319 Comm: syz-executor217 Not tainted 5.11.0-rc6af8e85128b4d0d24083c5cac646e891227052e0c #70
Call Trace:
 rt_cache_route+0x12e/0x140 net/ipv4/route.c:1503
 rt_set_nexthop.constprop.0+0x1fc/0x590 net/ipv4/route.c:1612
 __mkroute_output net/ipv4/route.c:2484 [inline]
...

The worker leaves msk->subflow alone even when it
happened to close the subflow ssk associated with it.

Fixes: 866f26f ("mptcp: always graft subflow socket to parent")
Closes: #157
Reported-by: Christoph Paasch <cpaasch@apple.com>
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
  • Loading branch information
Florian Westphal authored and jenkins-tessares committed Feb 12, 2021
1 parent 47be15b commit 42c231e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,14 @@ static struct sock *mptcp_subflow_get_retrans(const struct mptcp_sock *msk)
return backup;
}

static void mptcp_dispose_initial_subflow(struct mptcp_sock *msk)
{
if (msk->subflow) {
iput(SOCK_INODE(msk->subflow));
msk->subflow = NULL;
}
}

/* subflow sockets can be either outgoing (connect) or incoming
* (accept).
*
Expand Down Expand Up @@ -2150,6 +2158,9 @@ void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,

if (ssk == msk->last_snd)
msk->last_snd = NULL;

if (msk->subflow && ssk == msk->subflow->sk)
mptcp_dispose_initial_subflow(msk);
}

static unsigned int mptcp_sync_mss(struct sock *sk, u32 pmtu)
Expand Down Expand Up @@ -2538,12 +2549,6 @@ static void __mptcp_destroy_sock(struct sock *sk)

might_sleep();

/* dispose the ancillatory tcp socket, if any */
if (msk->subflow) {
iput(SOCK_INODE(msk->subflow));
msk->subflow = NULL;
}

/* be sure to always acquire the join list lock, to sync vs
* mptcp_finish_join().
*/
Expand All @@ -2568,6 +2573,7 @@ static void __mptcp_destroy_sock(struct sock *sk)
sk_stream_kill_queues(sk);
xfrm_sk_free_policy(sk);
sk_refcnt_debug_release(sk);
mptcp_dispose_initial_subflow(msk);
sock_put(sk);
}

Expand Down

0 comments on commit 42c231e

Please sign in to comment.