Skip to contentSkip to conversation

mptcp: reset 'first' and ack_hint on subflow close

PATCH Superseded Florian Westphal 2 participants 6 messages Feb 18, 2021 – Feb 22, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Florian Westphal

author
#0 lore raw

PATCH 1/1 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 as well.

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(a)redhat.com>
Signed-off-by Florian Westphal <fw(a)strlen.de>
---
 net/mptcp/protocol.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/mptcp/protocol.c +6 -0
index d811f60a867b..acbd2e554ede 100644
@@ -2161,6 +2161,12 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 	if (ssk == msk->last_snd)
 		msk->last_snd = NULL;
 
+	if (ssk == msk->ack_hint)
+		msk->ack_hint = NULL;
+
+	if (ssk == msk->first)
+		msk->first = NULL;
+
 	if (msk->subflow && ssk == msk->subflow->sk)
 		mptcp_dispose_initial_subflow(msk);
 }
Signature · 1 line
2.26.2
#1 lore raw
Quoted 8 lines · Florian Westphal

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 as well.

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.

There is a __mptcp_flush_join_list() before __mptcp_close_subflow(), could that matter? IIRC even the PM can move the subflow from join_list to conn_list to take some actions.

not 110% related, we have a couple of !msk->first in mptcp_update_rcv_data_fin() and mptcp_check_data_fin() which are likely obsoleted/to be removed.

Thanks!

Paolo

author
#2 lore raw
Quoted 10 lines · Paolo Abeni
Quoted 8 lines · Florian Westphal

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 as well.

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.

Quoted 7 lines

There is a __mptcp_flush_join_list() before __mptcp_close_subflow(), could that matter? IIRC even the PM can move the subflow from join_list to conn_list to take some actions.

not 110% related, we have a couple of !msk->first in mptcp_update_rcv_data_fin() and mptcp_check_data_fin() which are likely obsoleted/to be removed.

Hmm, if those are redunant, what exactly do we need msk->first for? Fallback mode could just fetch the subflow off conn_list.

Matthieu, please ignore this patch for now, I'd prefer to remove msk->first completely if possible.

#3 lore raw
Quoted 15 lines · Florian Westphal
Quoted 14 lines · Paolo Abeni
Quoted 8 lines · Florian Westphal

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 as well.

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.

There is a __mptcp_flush_join_list() before __mptcp_close_subflow(), could that matter? IIRC even the PM can move the subflow from join_list to conn_list to take some actions.

Quoted 6 lines
Quoted 3 lines

not 110% related, we have a couple of !msk->first in mptcp_update_rcv_data_fin() and mptcp_check_data_fin() which are likely obsoleted/to be removed.

Hmm, if those are redunant, what exactly do we need msk->first for? Fallback mode could just fetch the subflow off conn_list.

AFAICS it mostly avoids traversing the conn_list in some scenarios ;) IIRC I added that thing as early optimization (== root of all evil)

Quoted 3 lines

Matthieu, please ignore this patch for now, I'd prefer to remove msk->first completely if possible.

I would love this latter option!

(in the long term I think it would be nice also remote ->subflow)

Thanks!

Paolo

author
#4 lore raw
In reply to Paolo Abeni
Quoted 6 lines · Paolo Abeni
Quoted 5 lines · Florian Westphal

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 as well.

Quoted 7 lines
Quoted 3 lines

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.

There is a __mptcp_flush_join_list() before __mptcp_close_subflow(), could that matter? IIRC even the PM can move the subflow from join_list to conn_list to take some actions.

AFAICS msk->first gets set/used to avoid use of join_list. The latter is only used for incoming mp_join, not mp_capable.

I guess we can use the join_list but we whould have to stop splicing it to the conn_list unconditionally -- we would need to keep mp_capable one on the join_list until accept() time.

I think its better to apply this as-is at the moment, removing of ->first seems possible but the naive approach un-does several fixes you made to avoid exposure of the first subflow to the work queue.

Acked-by
#5 lore raw
Quoted 11 lines · Florian Westphal
Quoted 10 lines · Paolo Abeni
Quoted 8 lines · Florian Westphal

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 as well.

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.

Quoted 6 lines
Quoted 3 lines

There is a __mptcp_flush_join_list() before __mptcp_close_subflow(), could that matter? IIRC even the PM can move the subflow from join_list to conn_list to take some actions.

AFAICS msk->first gets set/used to avoid use of join_list. The latter is only used for incoming mp_join, not mp_capable.

Sharing here private conversation.

If msk->first is closed before accept, accept will still return an established msk socket, with msk->first still valid and pointing to the original subflow, in TCP_CLOSE status (and still with a valid refcnt [==1])

TL;DR: the patch looks safe, no need for a complex codying to remove msk->first field.

Acked-by Paolo Abeni <pabeni(a)redhat.com>