MPTCP Linux Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gang Yan" <gang.yan@linux.dev>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v5 6/6] Squash to previous one
Date: Fri, 28 Aug 2026 06:21:19 +0000	[thread overview]
Message-ID: <20260828062119.B2A421F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260828060643.14397-7-gang.yan@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] BPF Path Manager per-socket resources leak on socket disconnect or PM swap due to omitted `release()` callback.
--

commit 2b82d535eb907aa1641a5d2cebbd47571b430146
Author: Gang Yan <yangang@kylinos.cn>
Subject: Squash to previous one

This commit updates the MPTCP Path Manager operations to use RCU
protection for the pm.ops pointer. It modifies the assignment,
dereferencing, and cleanup paths to follow RCU reader/writer disciplines
and handle concurrent socket operations.

Link: https://sashiko.dev/#/patchset/20260819125629.49823-1-gang.yan@linux.dev?part=5

> Note also that the swap path does not call old->release() and that
> init() runs again when the ops is unchanged: the per-socket PM
> resources are already freed by mptcp_pm_destroy() before the reset
> swaps the ops, and mptcp_pm_kernel_init() only re-sets flags from
> the current sysctl, it does not allocate.

[Severity: High]
Does this assumption hold true for custom BPF-based path managers?

While mptcp_pm_destroy() cleans up the in-tree kernel PM resources, it
would not free custom BPF map allocations if the PM's release() callback is
skipped.

> diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
> --- a/net/mptcp/pm.c
> +++ b/net/mptcp/pm.c

[ ... ]

> @@ -1158,23 +1166,41 @@ void mptcp_pm_worker(struct mptcp_sock *msk)
>  static void mptcp_pm_ops_init(struct mptcp_sock *msk,
>  			      struct mptcp_pm_ops *pm_ops)
>  {

[ ... ]

> +	if (need_sync)
> +		synchronize_rcu();
> +	if (old)
> +		bpf_module_put(old, old->owner);
> +
> +	if (pm_ops->init)
> +		pm_ops->init(msk);

[Severity: High]
Since the swap path skips calling old->release(), can this cause an
unbounded memory leak if a socket is repeatedly disconnected and
reconnected?

An unprivileged local user can repeatedly call connect(AF_UNSPEC) followed
by connect() on an MPTCP socket. This triggers mptcp_pm_data_reset() which
calls mptcp_pm_ops_init() again. If a custom BPF PM allocates resources in
its init() callback, those resources will leak each time the socket is
disconnected and reinitialized.

>  	pr_debug("pm %s initialized\n", pm_ops->name);
>  }

[ ... ]

> @@ -1195,8 +1221,6 @@ void mptcp_pm_destroy(struct mptcp_sock *msk)
>  	 * can be reused (mptcp_disconnect()) and re-selected to a different PM
>  	 */
>  	mptcp_userspace_pm_free_local_addr_list(msk);
> -
> -	mptcp_pm_ops_release(msk);
>  }

[Severity: High]
By removing the mptcp_pm_ops_release() call from mptcp_pm_destroy() in
net/mptcp/pm.c, does this prevent custom BPF path managers from freeing
their per-socket resources when an MPTCP socket is disconnected?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260828060643.14397-1-gang.yan@linux.dev?part=6

  reply	other threads:[~2026-08-28  6:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28  6:06 [PATCH mptcp-next v5 0/6] mptcp: avoid data-races around the sysctls Gang Yan
2026-08-28  6:06 ` [PATCH mptcp-next v5 1/6] mptcp: sched: change scheduler sysctl atomically Gang Yan
2026-08-28  6:06 ` [PATCH mptcp-next v5 2/6] mptcp: pm: change path_manager " Gang Yan
2026-08-28  6:06 ` [PATCH mptcp-next v5 3/6] mptcp: use READ_ONCE() over sysctls Gang Yan
2026-08-28  6:06 ` [PATCH mptcp-next v5 4/6] mptcp: pm: use WRITE_ONCE() for the pm_type sysctl Gang Yan
2026-08-28  6:06 ` [PATCH mptcp-next v5 5/6] Squash-to "mptcp: pm: init and release mptcp_pm_ops" Gang Yan
2026-08-28  6:06 ` [PATCH mptcp-next v5 6/6] Squash to previous one Gang Yan
2026-08-28  6:21   ` sashiko-bot [this message]
2026-08-28  7:14 ` [PATCH mptcp-next v5 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=20260828062119.B2A421F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=gang.yan@linux.dev \
    --cc=mptcp@lists.linux.dev \
    --cc=sashiko-reviews@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