From: Geliang Tang <geliang@kernel.org>
To: Shardul Bankar <shardul.b@mpiricsoftware.com>, mptcp@lists.linux.dev
Cc: Matthieu Baerts <matttbe@kernel.org>,
Mat Martineau <martineau@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
kalpan.jani@mpiricsoftware.com, janak@mpiric.us,
shardulsb08@gmail.com
Subject: Re: [PATCH mptcp-next v2 2/5] Squash to "bpf: Export mptcp packet scheduler helpers"
Date: Wed, 22 Jul 2026 18:47:58 +0800 [thread overview]
Message-ID: <0ec3e0dcf31345a1356956c2b5082a6b56bf35d4.camel@kernel.org> (raw)
In-Reply-To: <2ec98c9e15ef4f96d01be048c59b160069cb3923.camel@mpiricsoftware.com>
Hi Shardul,
On Mon, 2026-07-06 at 16:33 +0530, Shardul Bankar wrote:
> Hi Geliang,
>
> Thanks for taking a look.
>
> On Mon, 2026-07-06 at 14:34 +0800, Geliang Tang wrote:
> > Hi Shardul,
> >
> > Thanks for this v2. It's much better now.
> >
> > On Fri, 2026-07-03 at 22:27 +0530, Shardul Bankar wrote:
> > > ...
> > > ...
> >
> > Sashiko complained that the rcu lock is not held here [1]. It seems
> > we
> > can add the lock, something like:
> >
> > rcu_read_lock();
> > subflow = mptcp_subflow_ctx(ssk);
> > if (subflow && subflow->conn == (const struct sock *)msk)
> > mptcp_pm_subflow_chk_stale(msk, ssk);
> > rcu_read_unlock();
> >
> >
> > WDYT?
> >
> > Thanks,
> > -Geliang
> >
> > [1]
> > https://sashiko.dev/#/patchset/20260703-mptcp_bpf_kfunc_fixes-v2-0-87ae3c64dc7e@mpiricsoftware.com?part=2
> >
> >
>
> I don't think we need the rcu_read_lock() here, and I think it would
> actually be unsafe.
>
> The subflow context is freed with kfree_rcu(), but in this path the
> msk
> socket lock prevents that free, so rcu_read_lock() is not needed.
> get_retrans() runs with the msk lock held (msk_owned_by_me() in
> mptcp_sched_get_retrans()). A subflow is removed from msk->conn_list
> by
> __mptcp_close_ssk() under that same lock, and only then can it be
> torn
> down and its context freed, so it cannot be freed while get_retrans()
> is running. The in-kernel mptcp_subflow_get_retrans() relies on
> exactly
> this: it dereferences the subflow and calls
> mptcp_pm_subflow_chk_stale() under the msk lock, without
> rcu_read_lock().
If that is the case, would it be reasonable to add a
msk_owned_by_me(msk) check inside bpf_mptcp_pm_subflow_chk_stale()?
Thanks,
-Geliang
>
> rcu_read_lock() would also not be the right call here:
> mptcp_pm_subflow_chk_stale() is not a pure reader (it updates
> subflow-
> > stale_count and can trigger a retransmit), so it needs the msk lock
> for serialization, which rcu_read_lock() would not provide. It is
> also
> KF_SLEEPABLE and can sleep (its stale path takes lock_sock_fast() and
> calls __mptcp_push_pending()), so it cannot run inside an RCU
> read-side critical section anyway.
>
> So I'd prefer to keep the code as is. If it helps, I can add a short
> comment noting that the msk lock keeps the subflow context alive.
> Does
> this address the concern?
>
> Thanks,
> Shardul
next prev parent reply other threads:[~2026-07-22 10:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 16:57 [PATCH mptcp-next v2 0/5] mptcp: bpf: fix scheduler kfunc socket type confusion Shardul Bankar
2026-07-03 16:57 ` [PATCH mptcp-next v2 1/5] Squash to "bpf: Export mptcp packet scheduler helpers" Shardul Bankar
2026-07-03 16:57 ` [PATCH mptcp-next v2 2/5] " Shardul Bankar
2026-07-06 6:34 ` Geliang Tang
2026-07-06 11:03 ` Shardul Bankar
2026-07-22 10:47 ` Geliang Tang [this message]
2026-07-03 16:57 ` [PATCH mptcp-next v2 3/5] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Shardul Bankar
2026-07-03 16:57 ` [PATCH mptcp-next v2 4/5] DO-NOT-MERGE: selftests/bpf: mptcp: verify scheduler rejects non-msk socket to set_timeout Shardul Bankar
2026-07-03 16:57 ` [PATCH mptcp-next v2 5/5] DO-NOT-MERGE: selftests/bpf: mptcp: extend bad scheduler test to the kfunc type contract Shardul Bankar
2026-07-03 18:18 ` [PATCH mptcp-next v2 0/5] mptcp: bpf: fix scheduler kfunc socket type confusion 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=0ec3e0dcf31345a1356956c2b5082a6b56bf35d4.camel@kernel.org \
--to=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=shardul.b@mpiricsoftware.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