MPTCP Linux Development
 help / color / mirror / Atom feed
From: Tao Cui <cui.tao@linux.dev>
To: mptcp@lists.linux.dev
Cc: matttbe@kernel.org, geliang@kernel.org, pabeni@redhat.com,
	cuitao@kylinos.cn, cui.tao@linux.dev
Subject: [PATCH mptcp-next 1/2] mptcp: keep pending join list flush across disconnect
Date: Fri,  4 Sep 2026 15:33:10 +0800	[thread overview]
Message-ID: <20260904073311.1285024-2-cui.tao@linux.dev> (raw)
In-Reply-To: <20260904073311.1285024-1-cui.tao@linux.dev>

From: Tao Cui <cuitao@kylinos.cn>

mptcp_disconnect() clears msk->cb_flags with a plain write, dropping
any pending MPTCP_FLUSH_JOIN_LIST. When an MP_JOIN is processed while
the parent socket is being disconnected, the subflow is queued in
msk->join_list and the flag is set under the data lock, but the plain
write can erase it: mptcp_release_cb() then skips the flush, and as
mptcp_destroy_common() only iterates conn_list, the subflow sockets
queued in the join list are leaked. Flags that were already pending
before the disconnect are dropped the same way.

Only clear the other flags and keep MPTCP_FLUSH_JOIN_LIST, so the
join list is flushed from mptcp_release_cb() at sock lock release
time as originally intended. Do the masking under the data lock, as
mptcp_finish_join() sets the flag while queuing the subflow.

Fixes: b29fcfb54cd7 ("mptcp: full disconnect implementation")
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
 net/mptcp/protocol.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index e1f08f71cdb16..7445de5a80ff4 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3615,7 +3615,13 @@ static int mptcp_disconnect(struct sock *sk, int flags)
 	WRITE_ONCE(msk->flags, 0);
 	spin_unlock_bh(&msk->fallback_lock);
 
-	msk->cb_flags = 0;
+	/* keep a pending join list flush: mptcp_destroy_common()
+	 * leaves the list to mptcp_release_cb(), the data lock
+	 * matches the flag setter in mptcp_finish_join()
+	 */
+	mptcp_data_lock(sk);
+	msk->cb_flags &= BIT(MPTCP_FLUSH_JOIN_LIST);
+	mptcp_data_unlock(sk);
 	msk->recovery = false;
 	WRITE_ONCE(msk->can_ack, false);
 	WRITE_ONCE(msk->fully_established, false);
-- 
2.43.0


  reply	other threads:[~2026-09-04  7:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  7:33 [PATCH mptcp-next 0/2] mptcp: fix disconnect races around the PM and cb flags Tao Cui
2026-09-04  7:33 ` Tao Cui [this message]
2026-09-04  7:33 ` [PATCH mptcp-next 2/2] mptcp: pm: take pm->lock in mptcp_pm_data_reset() Tao Cui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260904073311.1285024-2-cui.tao@linux.dev \
    --to=cui.tao@linux.dev \
    --cc=cuitao@kylinos.cn \
    --cc=geliang@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox