From: Shardul Bankar <shardul.b@mpiricsoftware.com>
To: mptcp@lists.linux.dev
Cc: Matthieu Baerts <matttbe@kernel.org>,
Mat Martineau <martineau@kernel.org>,
Geliang Tang <geliang@kernel.org>,
pabeni@redhat.com, kalpan.jani@mpiricsoftware.com,
janak@mpiric.us, shardulsb08@gmail.com,
Shardul Bankar <shardul.b@mpiricsoftware.com>
Subject: [PATCH mptcp-next 1/2] Squash to "mptcp: pm: init and release mptcp_pm_ops"
Date: Sat, 20 Jun 2026 14:14:23 +0530 [thread overview]
Message-ID: <20260620084424.3072634-2-shardul.b@mpiricsoftware.com> (raw)
In-Reply-To: <20260620084424.3072634-1-shardul.b@mpiricsoftware.com>
The userspace local address list is freed from the userspace path
manager .release callback (via mptcp_pm_ops_release()), i.e. only when
the socket currently uses the userspace PM. A socket that used the
userspace PM can be reused via mptcp_disconnect() and re-selected to a
different path manager; an entry appended late would then not be freed by
the next teardown running a non-userspace PM, and leaks.
Free msk->pm.userspace_pm_local_addr_list unconditionally in
mptcp_pm_destroy() and drop the now-redundant userspace .release. The
list is initialised in the generic mptcp_pm_data_init(), so freeing it
from the generic teardown is consistent; it is empty for a kernel-PM
socket, so this is a no-op there.
Signed-off-by: Shardul Bankar <shardul.b@mpiricsoftware.com>
---
net/mptcp/pm.c | 6 ++++++
net/mptcp/pm_userspace.c | 6 ------
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 9dc7b41fb5626..8e6d066a868d7 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -1170,6 +1170,12 @@ void mptcp_pm_destroy(struct mptcp_sock *msk)
{
mptcp_pm_free_announced_list(msk);
mptcp_pm_ops_release(msk);
+ /* Free the userspace local address list unconditionally: the socket
+ * can be reused (mptcp_disconnect()) and re-selected to a different
+ * path manager, so entries queued under the userspace PM must be
+ * reclaimed regardless of the PM in effect at teardown.
+ */
+ mptcp_userspace_pm_free_local_addr_list(msk);
}
void mptcp_pm_data_reset(struct mptcp_sock *msk)
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index ad6ba658e5a58..96fdaf12f6ddd 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -689,15 +689,9 @@ int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
return ret;
}
-static void mptcp_pm_userspace_release(struct mptcp_sock *msk)
-{
- mptcp_userspace_pm_free_local_addr_list(msk);
-}
-
static struct mptcp_pm_ops mptcp_pm_userspace = {
.get_local_id = mptcp_pm_userspace_get_local_id,
.get_priority = mptcp_pm_userspace_get_priority,
- .release = mptcp_pm_userspace_release,
.name = "userspace",
.owner = THIS_MODULE,
};
--
2.34.1
next prev parent reply other threads:[~2026-06-20 8:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-20 8:44 [PATCH mptcp-next 0/2] mptcp: pm: net-next port of the alloc-during-teardown leak fix Shardul Bankar
2026-06-20 8:44 ` Shardul Bankar [this message]
2026-06-20 8:44 ` [PATCH mptcp-next 2/2] mptcp: pm: fix memory leak from alloc-during-teardown race Shardul Bankar
2026-06-22 17:37 ` Matthieu Baerts
2026-06-24 12:46 ` Shardul Bankar
2026-06-20 9:37 ` [PATCH mptcp-next 0/2] mptcp: pm: net-next port of the alloc-during-teardown leak fix MPTCP CI
2026-07-31 15:49 ` Matthieu Baerts
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=20260620084424.3072634-2-shardul.b@mpiricsoftware.com \
--to=shardul.b@mpiricsoftware.com \
--cc=geliang@kernel.org \
--cc=janak@mpiric.us \
--cc=kalpan.jani@mpiricsoftware.com \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=pabeni@redhat.com \
--cc=shardulsb08@gmail.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