Skip to content

Commit c8fe62f

Browse files
Florian Westphaldavem330
authored andcommitted
mptcp: reset 'first' and ack_hint on subflow close
Just like with last_snd, we have to NULL 'first' on subflow close. ack_hint isn't strictly required (its never dereferenced), but better to clear this explicitly as well instead of making it an exception. msk->first is dereferenced unconditionally at accept time, but at that point the ssk is not on the conn_list yet -- this means worker can't see it when iterating the conn_list. Reported-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net> 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>
1 parent 17aee05 commit c8fe62f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

net/mptcp/protocol.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,6 +2169,12 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
21692169
if (ssk == msk->last_snd)
21702170
msk->last_snd = NULL;
21712171

2172+
if (ssk == msk->ack_hint)
2173+
msk->ack_hint = NULL;
2174+
2175+
if (ssk == msk->first)
2176+
msk->first = NULL;
2177+
21722178
if (msk->subflow && ssk == msk->subflow->sk)
21732179
mptcp_dispose_initial_subflow(msk);
21742180
}
@@ -3297,6 +3303,9 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,
32973303
/* PM/worker can now acquire the first subflow socket
32983304
* lock without racing with listener queue cleanup,
32993305
* we can notify it, if needed.
3306+
*
3307+
* Even if remote has reset the initial subflow by now
3308+
* the refcnt is still at least one.
33003309
*/
33013310
subflow = mptcp_subflow_ctx(msk->first);
33023311
list_add(&subflow->node, &msk->conn_list);

0 commit comments

Comments
 (0)