From: Gang Yan <gang.yan@linux.dev>
To: mptcp@lists.linux.dev
Subject: [PATCH mptcp-next v4 4/6] mptcp: pm: use WRITE_ONCE() for the pm_type sysctl
Date: Mon, 24 Aug 2026 15:36:23 +0800 [thread overview]
Message-ID: <20260824073625.57471-5-gang.yan@linux.dev> (raw)
In-Reply-To: <20260824073625.57471-1-gang.yan@linux.dev>
From: Gang Yan <yangang@kylinos.cn>
Write pernet->pm_type with WRITE_ONCE() in proc_path_manager(), pairing
it with the READ_ONCE() readers introduced earlier in this series.
Note that updating net.mptcp.path_manager swaps the ops pointer first,
then writes the derived pm_type: a socket created in between may see
the new ops with the old pm_type. As the net.mptcp.pm_type knob is
deprecated since v6.15 and will be removed, the race is not fixed on
purpose; document it above the assignment so it does not get reported
again.
Suggested-by: Matthieu Baerts <matttbe@kernel.org>
Assisted-by: Claude:GLM5.2
Co-developed-by: Tao Cui <cuitao@kylinos.cn>
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
---
net/mptcp/ctrl.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
index 5a75f9b76d15..87491b961bf2 100644
--- a/net/mptcp/ctrl.c
+++ b/net/mptcp/ctrl.c
@@ -265,7 +265,13 @@ static int proc_path_manager(const struct ctl_table *ctl, int write,
pm_type = MPTCP_PM_TYPE_KERNEL;
else if (strncmp(pm_name, "userspace", MPTCP_PM_NAME_MAX) == 0)
pm_type = MPTCP_PM_TYPE_USERSPACE;
- pernet->pm_type = pm_type;
+
+ /* Pre-existing race: two sequential writes, a socket
+ * created in between may see the new ops with the old
+ * pm_type. The knob is deprecated since v6.15 and will
+ * be removed: not fixed on purpose.
+ */
+ WRITE_ONCE(pernet->pm_type, pm_type);
}
}
--
2.43.0
next prev parent reply other threads:[~2026-08-24 7:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 7:36 [PATCH mptcp-next v4 0/6] mptcp: avoid data-races around the sysctls Gang Yan
2026-08-24 7:36 ` [PATCH mptcp-next v4 1/6] mptcp: sched: change scheduler sysctl atomically Gang Yan
2026-08-24 7:36 ` [PATCH mptcp-next v4 2/6] mptcp: pm: change path_manager " Gang Yan
2026-08-24 7:36 ` [PATCH mptcp-next v4 3/6] mptcp: use READ_ONCE() over sysctls Gang Yan
2026-08-24 7:36 ` Gang Yan [this message]
2026-08-24 7:36 ` [PATCH mptcp-next v4 5/6] Squash-to "mptcp: pm: init and release mptcp_pm_ops" Gang Yan
2026-08-24 7:36 ` [PATCH mptcp-next v4 6/6] Squash to previous one Gang Yan
2026-08-24 7:58 ` sashiko-bot
2026-08-24 9:21 ` gang.yan
2026-08-24 8:49 ` [PATCH mptcp-next v4 0/6] mptcp: avoid data-races around the sysctls MPTCP CI
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=20260824073625.57471-5-gang.yan@linux.dev \
--to=gang.yan@linux.dev \
--cc=mptcp@lists.linux.dev \
/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