From: gang.yan@linux.dev
To: sashiko-reviews@lists.linux.dev
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v2 1/5] mptcp: sched: change scheduler sysctl atomically
Date: Tue, 18 Aug 2026 12:56:37 +0000 [thread overview]
Message-ID: <a9ef03bb12d3087e8f4af51d6d7dcd9967810942@linux.dev> (raw)
In-Reply-To: <20260818095955.6892E1F000E9@smtp.kernel.org>
August 18, 2026 at 5:59 PM, sashiko-bot@kernel.org mailto:sashiko-bot@kernel.org wrote:
>
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] Use-After-Free and module reference leak due to missing reference counting when setting the default MPTCP scheduler
> - [Medium] Redundant scheduler list traversal during socket initialization defeats pointer caching
> --
>
> --- Patch [1]: [PATCH mptcp-next v2 1/5] mptcp: sched: change scheduler sysctl atomically ---
> commit d5b1780c033b9909a1b30fbd814812af5c25ed2f
> Author: Gang Yan <yangang@kylinos.cn>
>
> mptcp: sched: change scheduler sysctl atomically
>
> This commit changes the per-netns scheduler storage from an inline string
> to an RCU-protected pointer to an mptcp_sched_ops struct. It updates the
> sysctl read/write paths and socket initialization to use this pointer,
> aiming to prevent concurrent readers from observing half-written names.
>
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/626
>
> >
> > diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
> > index 63c5747f0f63c..479b31eb30079 100644
> > --- a/net/mptcp/ctrl.c
> > +++ b/net/mptcp/ctrl.c
> >
> [ ... ]
>
> >
> > @@ -126,7 +133,7 @@ static int mptcp_set_scheduler(char *scheduler, const char *name)
> > rcu_read_lock();
> > sched = mptcp_sched_find(name);
> > if (sched)
> > - strscpy(scheduler, name, MPTCP_SCHED_NAME_MAX);
> > + xchg(&pernet->scheduler, sched);
> >
> [Severity: High]
> When replacing the scheduler pointer here with xchg(), does this leak the
> module reference for the previous scheduler returned by xchg()?
>
> Also, do we need to acquire a module reference for the newly assigned sched
> via bpf_try_module_get() before storing it? Without a reference, could the
> module be unloaded, leaving pernet->scheduler pointing to freed memory that
> would trigger a use-after-free when dereferenced by a concurrent reader in
> proc_scheduler()?
Hi Matt,
As far as I know, for linux-master branch, the sched ops cannot be torndown, and
the only static default scheduler is used, so no reference counting is needed.
It is safe for now, the pm is as the same. Right?
>
> [ ... ]
>
> >
> > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> > index c2762d74f29d7..82df0400d0f94 100644
> > --- a/net/mptcp/protocol.c
> > +++ b/net/mptcp/protocol.c
> >
> [ ... ]
>
> >
> > @@ -3271,8 +3272,8 @@ static int mptcp_init_sock(struct sock *sk)
> > return -ENOMEM;
> >
> > rcu_read_lock();
> > - ret = mptcp_init_sched(mptcp_sk(sk),
> > - mptcp_sched_find(mptcp_get_scheduler(net)));
> > + mptcp_get_scheduler(net, sched_name);
> > + ret = mptcp_init_sched(mptcp_sk(sk), mptcp_sched_find(sched_name));
> >
> [Severity: Medium]
> Since pernet->scheduler now stores the mptcp_sched_ops pointer directly,
> could we retrieve and use that pointer here directly? Extracting the name
> via mptcp_get_scheduler() just to perform a redundant list traversal with
> mptcp_sched_find() seems to defeat the purpose of caching the operations
> pointer.
>
That's a good point, will done in v3.
Thanks
Gang
> >
> > rcu_read_unlock();
> > if (ret)
> > return ret;
> >
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260818094825.48446-1-gang.yan@linux.dev?part=1
>
next prev parent reply other threads:[~2026-08-18 12:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 9:48 [PATCH mptcp-next v2 0/5] mptcp: avoid data-races around the sysctls Gang Yan
2026-08-18 9:48 ` [PATCH mptcp-next v2 1/5] mptcp: sched: change scheduler sysctl atomically Gang Yan
2026-08-18 9:59 ` sashiko-bot
2026-08-18 12:56 ` gang.yan [this message]
2026-08-18 9:48 ` [PATCH mptcp-next v2 2/5] mptcp: pm: change path_manager " Gang Yan
2026-08-18 10:00 ` sashiko-bot
2026-08-18 12:57 ` gang.yan
2026-08-18 9:48 ` [PATCH mptcp-next v2 3/5] mptcp: use READ_ONCE() over sysctls Gang Yan
2026-08-18 10:01 ` sashiko-bot
2026-08-18 13:02 ` gang.yan
2026-08-18 9:48 ` [PATCH mptcp-next v2 4/5] Squash to "mptcp: pm: init and release mptcp_pm_ops" Gang Yan
2026-08-18 10:03 ` sashiko-bot
2026-08-18 13:06 ` gang.yan
2026-08-18 9:48 ` [PATCH mptcp-next v2 5/5] Squash to "bpf: Add mptcp packet scheduler struct_ops" Gang Yan
2026-08-18 11:13 ` [PATCH mptcp-next v2 0/5] mptcp: avoid data-races around the sysctls MPTCP CI
-- strict thread matches above, loose matches on Subject: below --
2026-08-18 9:39 Gang Yan
2026-08-18 9:39 ` [PATCH mptcp-next v2 1/5] mptcp: sched: change scheduler sysctl atomically Gang Yan
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=a9ef03bb12d3087e8f4af51d6d7dcd9967810942@linux.dev \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.