From: sashiko-bot@kernel.org
To: "Kalpan Jani" <kalpan.jani@mpiricsoftware.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v3 1/2] mptcp: sched: add subflow avoid flag and enforce it in core
Date: Mon, 31 Aug 2026 10:07:48 +0000 [thread overview]
Message-ID: <20260831100749.0CB581F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831094651.2682660-2-kalpan.jani@mpiricsoftware.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Concurrent modification of the `mptcp_subflow_context` bitfield causes a read-modify-write data race, leading to corrupted critical subflow state.
- [Medium] The `avoid` flag is not enforced by the core when a custom BPF scheduler is loaded, directly contradicting the commit message's claims.
--
commit 99e88cae3546011d9eecb7fbb324ce6a3cff75f9
Author: Kalpan Jani <kalpan.jani@mpiricsoftware.com>
mptcp: sched: add subflow avoid flag and enforce it in core
This commit adds a new avoid flag to the MPTCP subflow context to allow
BPF schedulers to bench subflows. It also modifies the core send and
retransmit paths to skip subflows marked with this flag.
Link: https://github.com/multipath-tcp/mptcp_net-next/issues/349
> - mptcp_subflow_get_send() and mptcp_subflow_get_retrans() -- the
> default in-kernel subflow picker -- now skip an avoided subflow
> next to the existing active-subflow check. This runs regardless of
> whether a custom scheduler is loaded, so the flag has real weight
> on core selection and isn't only meaningful to whatever BPF
> program happens to read it back. avoid defaults to false and only
> an explicit set_avoid() call flips it, so this is a no-op for
> anyone who doesn't use it;
[Severity: Medium]
Is this description accurate regarding custom BPF schedulers?
Looking at mptcp_sched_get_send() in net/mptcp/sched.c, if a custom
BPF scheduler is active (msk->sched != &mptcp_sched_default), the core
directly returns the result of the custom scheduler's callback:
net/mptcp/sched.c:mptcp_sched_get_send() {
...
if (msk->sched == &mptcp_sched_default || !msk->sched)
return mptcp_sched_default_get_send(msk);
return msk->sched->get_send(msk);
}
This appears to bypass mptcp_subflow_get_send() entirely (which is
where the avoid check lives) when a custom scheduler is used. Does the
core provide fallback enforcement elsewhere, or does the flag become a
no-op unless the custom BPF program manually checks it?
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index 3d250e8204d52..7768a464ff4e8 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -586,7 +586,8 @@ struct mptcp_subflow_context {
> is_mptfo : 1, /* subflow is doing TFO */
> close_event_done : 1, /* has done the post-closed part */
> mpc_drop : 1, /* the MPC option has been dropped in a rtx */
> - __unused : 9;
> + avoid : 1, /* pkt scheduler: skip subflow if possible */
> + __unused : 8;
> bool data_avail;
[Severity: High]
Can placing avoid in this shared bitfield lead to data corruption via
a read-modify-write (RMW) race?
The core network stack modifies other flags in this same 32-bit bitfield
from the RX softirq path while holding only the TCP subflow socket lock
(ssk). For example, it clears subflow->map_valid = 0 in
net/mptcp/subflow.c:mptcp_subflow_data_available().
Because bitfield assignments compile to non-atomic RMW operations on the
containing 32-bit word, modifying this new flag from the BPF kfunc under
the MPTCP socket lock (msk) could race with those softirq updates.
[ ... ]
> diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
> index 1e59072d478c9..8a448814a11d4 100644
> --- a/net/mptcp/sched.c
> +++ b/net/mptcp/sched.c
> @@ -165,6 +165,12 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
> WRITE_ONCE(subflow->scheduled, scheduled);
> }
>
> +__bpf_kfunc void mptcp_subflow_set_avoid(struct mptcp_subflow_context *subflow,
> + bool avoid)
> +{
> + subflow->avoid = avoid;
> +}
[Severity: High]
Does this bitfield assignment risk overwriting concurrent softirq updates?
Since this function executes under the msk lock and not the ssk lock,
this assignment races with the ssk-locked updates to the same bitfield word
mentioned above, potentially causing flags like map_valid or mpc_drop
to be silently dropped.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831094651.2682660-1-kalpan.jani@mpiricsoftware.com?part=1
next prev parent reply other threads:[~2026-08-31 10:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 9:46 [PATCH mptcp-next v3 0/2] mptcp: sched: add subflow avoid flag Kalpan Jani
2026-08-31 9:46 ` [PATCH mptcp-next v3 1/2] mptcp: sched: add subflow avoid flag and enforce it in core Kalpan Jani
2026-08-31 10:07 ` sashiko-bot [this message]
2026-08-31 9:46 ` [PATCH mptcp-next v3 2/2] selftests: mptcp: bpf: exercise the subflow avoid flag across rounds Kalpan Jani
2026-08-31 10:18 ` sashiko-bot
2026-08-31 10:57 ` [PATCH mptcp-next v3 0/2] mptcp: sched: add subflow avoid flag 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=20260831100749.0CB581F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kalpan.jani@mpiricsoftware.com \
--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