Skip to content

Commit bda646b

Browse files
Florian Westphalgregkh
authored andcommitted
mptcp: dispose initial struct socket when its subflow is closed
[ Upstream commit 17aee05 ] 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: multipath-tcp/mptcp_net-next#157 Reported-by: Christoph Paasch <[email protected]> Suggested-by: Paolo Abeni <[email protected]> Acked-by: Paolo Abeni <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent a717175 commit bda646b

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

net/mptcp/protocol.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,6 +2100,14 @@ static struct sock *mptcp_subflow_get_retrans(const struct mptcp_sock *msk)
21002100
return backup;
21012101
}
21022102

2103+
static void mptcp_dispose_initial_subflow(struct mptcp_sock *msk)
2104+
{
2105+
if (msk->subflow) {
2106+
iput(SOCK_INODE(msk->subflow));
2107+
msk->subflow = NULL;
2108+
}
2109+
}
2110+
21032111
/* subflow sockets can be either outgoing (connect) or incoming
21042112
* (accept).
21052113
*
@@ -2144,6 +2152,9 @@ void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
21442152

21452153
if (ssk == msk->last_snd)
21462154
msk->last_snd = NULL;
2155+
2156+
if (msk->subflow && ssk == msk->subflow->sk)
2157+
mptcp_dispose_initial_subflow(msk);
21472158
}
21482159

21492160
static unsigned int mptcp_sync_mss(struct sock *sk, u32 pmtu)
@@ -2533,12 +2544,6 @@ static void __mptcp_destroy_sock(struct sock *sk)
25332544

25342545
might_sleep();
25352546

2536-
/* dispose the ancillatory tcp socket, if any */
2537-
if (msk->subflow) {
2538-
iput(SOCK_INODE(msk->subflow));
2539-
msk->subflow = NULL;
2540-
}
2541-
25422547
/* be sure to always acquire the join list lock, to sync vs
25432548
* mptcp_finish_join().
25442549
*/
@@ -2563,6 +2568,7 @@ static void __mptcp_destroy_sock(struct sock *sk)
25632568
sk_stream_kill_queues(sk);
25642569
xfrm_sk_free_policy(sk);
25652570
sk_refcnt_debug_release(sk);
2571+
mptcp_dispose_initial_subflow(msk);
25662572
sock_put(sk);
25672573
}
25682574

0 commit comments

Comments
 (0)