Skip to content

mptcp: fix disconnect races around the PM and cb flags

Tao Cui mptcp 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2mptcp: keep pending join list flush across disconnectnet/mptcp/protocol.c+7 -10 replies
2/2mptcp: pm: take pm->lock in mptcp_pm_data_reset()net/mptcp/pm.c+5 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH mptcp-next 0/2] mptcp: fix disconnect races around the PM and cb flags

From: Tao Cui <[email protected]>

Hi,

This is the follow-up series promised in reply to the Sashiko review of the extra_subflows fixes [1]: two pre-existing issues in the disconnect path that were reported there but left out of that series on purpose.

Patch 1 fixes a subflow socket leak: mptcp_disconnect() clears msk->cb_flags with a plain write and can drop a pending MPTCP_FLUSH_JOIN_LIST, so a subflow queued in the join list while the socket is being disconnected is never flushed by mptcp_release_cb(), and mptcp_destroy_common() only iterates conn_list. The flush flag is now preserved across the disconnect, and the masking is done under the data lock like the flag setter.

Patch 2 closes a data race reported on the same socket state:
mptcp_pm_data_reset() clears the PM data with a plain memset while the RX path accesses the same fields under pm->lock. The reset now takes pm->lock, with no lock inversion, as the callers hold the socket lock at most.

Both are independent of the extra_subflows series [2], which only made the accounting robust against the counter imbalance these races can leave behind. Paolo's recent "mptcp: prevent race between disconnect() and rtx" fixes a third race in the same window.

Validated with the virtme CI (mptcp selftests).

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Tao Cui (2):
mptcp: keep pending join list flush across disconnect
mptcp: pm: take pm->lock in mptcp_pm_data_reset()

 net/mptcp/pm.c       | 5 +++++
 net/mptcp/protocol.c | 8 +++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0