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 2/2] mptcp: pm: take pm->lock in mptcp_pm_data_reset()
Date: Fri, 4 Sep 2026 15:33:11 +0800 [thread overview]
Message-ID: <20260904073311.1285024-3-cui.tao@linux.dev> (raw)
In-Reply-To: <20260904073311.1285024-1-cui.tao@linux.dev>
From: Tao Cui <cuitao@kylinos.cn>
mptcp_pm_data_reset() clears the PM state with a plain memset while
the RX path can access the same fields in BH context under pm->lock:
on a disconnecting socket, mptcp_pm_allow_new_subflow() and friends
can run concurrently with the reset and see partially cleared data.
Take pm->lock around the reset. All the callers hold the socket lock
at most, so there is no lock inversion.
Fixes: b29fcfb54cd7 ("mptcp: full disconnect implementation")
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
net/mptcp/pm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 8b68868255c50..e224aa6f63dd9 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -1179,6 +1179,10 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk)
u8 pm_type = mptcp_get_pm_type(sock_net((struct sock *)msk));
struct mptcp_pm_data *pm = &msk->pm;
+ /* the whole PM data is protected by pm->lock, the reset can
+ * race with the RX path on a disconnecting socket
+ */
+ spin_lock_bh(&pm->lock);
memset(&pm->reset, 0, sizeof(pm->reset));
pm->rm_list_tx.nr = 0;
pm->rm_list_rx.nr = 0;
@@ -1201,6 +1205,7 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk)
bitmap_fill(pm->id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
}
+ spin_unlock_bh(&pm->lock);
}
void mptcp_pm_data_init(struct mptcp_sock *msk)
--
2.43.0
prev parent 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 ` [PATCH mptcp-next 1/2] mptcp: keep pending join list flush across disconnect Tao Cui
2026-09-04 7:33 ` Tao Cui [this message]
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-3-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