From: netdev-bot+sashiko@kernel.org
To: chia-yu.chang@nokia-bell-labs.com
Cc: emil@etsalapatis.com, martin.lau@kernel.org, ast@kernel.org,
kafai.wan@linux.dev, bpf@vger.kernel.org, willemb@google.com,
horms@kernel.org, linux-kernel@vger.kernel.org, kuba@kernel.org,
netdev@vger.kernel.org, pabeni@redhat.com, davem@davemloft.net,
edumazet@kernel.org, kuniyu@google.com, ij@kernel.org,
ncardwell@google.com, koen0607@gmail.com, g.white@cablelabs.com,
ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com,
cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com,
vidhi_goel@apple.com, Mike_Rudolph@comcast.com,
Jeff_Howe@comcast.com, srichard@netapp.com
Subject: Re: [PATCH net-next v5 4/4] tcp: add MSS ceiling callback for congestion control
Date: Tue, 01 Dec 2026 13:10:24 +0000 [thread overview]
Message-ID: <179613062412.3146.15940448870863825733@kernel.org> (raw)
In-Reply-To: <20261130125658.20292-5-chia-yu.chang@nokia-bell-labs.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] Unbounded recursion that can overflow the kernel stack.
- [Medium] The MSS ceiling only takes effect inside tcp_sync_mss(), and
nothing re-syncs mss_cache when the congestion control is initialised…
- [Medium] tcp: mss_ceiling in tp->mss_cache corrupts MTU probing
search_low and snd_cwnd
- [Low] The mss_ceiling() callback is documented in include/net/tcp.h as
returning 'the maximum value allowed for tp->mss_cache', but in…
- [Low] The patch adds a new tcp_congestion_ops member (mss_ceiling), a
matching BPF struct_ops CFI stub slot, and a new EXPORT_SYMBOL_GPL…
--
tcp: add MSS ceiling callback for congestion control
This adds an optional mss_ceiling() callback to tcp_congestion_ops.
tcp_sync_mss() uses it to cap tp->mss_cache. The patch also adds
tcp_update_mss_ceiling(), which is exported and registered as a tcp_ca
kfunc, so a congestion control can force mss_cache to be recomputed after
it changes its ceiling.
> diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c
> index 2a71dc81562f4..b03cc9e9c0641 100644
> --- a/net/ipv4/bpf_tcp_ca.c
> +++ b/net/ipv4/bpf_tcp_ca.c
> @@ -195,6 +195,7 @@ BTF_ID_FLAGS(func, tcp_reno_undo_cwnd)
> BTF_ID_FLAGS(func, tcp_slow_start)
> BTF_ID_FLAGS(func, tcp_cong_avoid_ai)
> BTF_ID_FLAGS(func, tcp_tso_autosize)
> +BTF_ID_FLAGS(func, tcp_update_mss_ceiling)
[Severity: High]
Can a BPF mss_ceiling() implementation recurse without bound through this
kfunc?
bpf_tcp_ca_kfunc_set has only .owner and .set and no .filter, and it is
registered for BPF_PROG_TYPE_STRUCT_OPS. Every tcp_congestion_ops member
program can therefore call tcp_update_mss_ceiling(), including the program
that implements the new .mss_ceiling member.
On an established socket, icsk_ca_initialized, icsk_ca_ops->mss_ceiling and
icsk_pmtu_cookie are all set. The gate in tcp_update_mss_ceiling() passes,
so the calls go:
bpf mss_ceiling()
tcp_update_mss_ceiling()
tcp_sync_mss()
icsk->icsk_ca_ops->mss_ceiling()
tcp_update_mss_ceiling()
tcp_sync_mss()
...
The trampoline does not seem to stop this either. For STRUCT_OPS,
bpf_prog_check_recur() returns prog->aux->jits_use_priv_stack. That is
false for tcp_ca programs, so __bpf_prog_enter() runs without the
prog->active recursion check.
Each level adds a trampoline frame, up to 512 bytes of BPF stack, and the
tcp_update_mss_ceiling() and tcp_sync_mss() frames. Any tcp_sync_mss() on
such a socket can start the loop, for example:
- tcp_current_mss() on a PMTU change
- tcp_v4_mtu_reduced()
- tcp_ack_update_window() when the peer window grows
net/core/filter.c uses bpf_chg_cc_inprogress to guard a similar struct_ops
self-recursion in bpf_setsockopt(TCP_CONGESTION). Does this path need a
re-entrancy guard, or a kfunc filter that keeps the mss_ceiling member from
calling this kfunc?
> BTF_KFUNCS_END(bpf_tcp_ca_check_kfunc_ids)
>
> static const struct btf_kfunc_id_set bpf_tcp_ca_kfunc_set = {
[ ... ]
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 7b694479095e0..96ed9ba7abe6d 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -2147,6 +2147,21 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu)
> mss_now = tcp_mtu_to_mss(sk, pmtu);
> mss_now = tcp_bound_to_half_wnd(tp, mss_now);
>
> + /*
> + * Apply an optional MSS ceiling requested by the congestion control
> + * module. Values below the effective minimum send MSS are clamped.
> + */
> + if (icsk->icsk_ca_initialized && icsk->icsk_ca_ops->mss_ceiling) {
> + u32 mss_ceiling = icsk->icsk_ca_ops->mss_ceiling(sk);
> +
> + if (mss_ceiling && mss_ceiling < mss_now) {
> + u32 min_snd_mss = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss) -
> + (tcp_sk(sk)->tcp_header_len - sizeof(struct tcphdr));
> +
> + mss_now = max(mss_ceiling, min_snd_mss);
[Severity: Medium]
Does folding the CC ceiling into tp->mss_cache confuse MTU probing?
When icsk_mtup.enabled is set (tcp_mtu_probing=2, or 1 after a
blackhole is detected), the probing code treats tp->mss_cache as the
MSS the path is currently known to carry. With this change it can be
the much smaller CC ceiling instead. That value then leaks into the
search state in two places.
First, tcp_mtu_check_reprobe() rebuilds the search range from the
cached value once tcp_probe_interval has elapsed:
net/ipv4/tcp_output.c:tcp_mtu_check_reprobe() {
...
int mss = tcp_current_mss(sk);
...
icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss);
...
}
If the ceiling is in effect at that point, search_low drops to the MTU
that matches the ceiling. Later the CC may raise or drop its ceiling
and call tcp_update_mss_ceiling(). tcp_sync_mss() still applies
min(mss_now, tcp_mtu_to_mss(sk, search_low)), so mss_cache stays at
the old ceiling. It only recovers as new probes succeed and walk
search_low back up.
Second, tcp_mtu_probe() picks probe_size from search_low and
search_high without looking at the ceiling. The probe segment is
therefore larger than what the CC asked for. When it is ACKed,
tcp_mtup_probe_success() rescales cwnd on the assumption that
mss_cache is about to grow to the probe size:
net/ipv4/tcp_input.c:tcp_mtup_probe_success() {
...
val = (u64)tcp_snd_cwnd(tp) * tcp_mss_to_mtu(sk, tp->mss_cache);
do_div(val, icsk->icsk_mtup.probe_size);
...
icsk->icsk_mtup.search_low = icsk->icsk_mtup.probe_size;
icsk->icsk_mtup.probe_size = 0;
tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
...
}
The final tcp_sync_mss() re-applies the ceiling, so mss_cache does not
grow. By then snd_cwnd has already been scaled by the ratio of the
mss_cache MTU to probe_size. With a 500 byte ceiling and a 1500 byte
probe, cwnd is cut to roughly a third, and no larger segments make up
for it. Every further successful probe in the same search cuts it
again.
Should the ceiling be kept apart from the path MSS that MTU probing
works with? For example, tcp_mtu_check_reprobe() and
tcp_mtup_probe_success() could use the uncapped value, or the ceiling
could be applied somewhere other than tp->mss_cache. Or is the intent
that a CC using mss_ceiling() is never combined with icsk_mtup?
[Severity: Low]
Can this raise mss_cache instead of capping it?
include/net/tcp.h documents the callback as returning "the maximum value
allowed for tp->mss_cache". At this point, though, mss_now has already been
through tcp_bound_to_half_wnd(). That function can lower it below
sysctl_tcp_min_snd_mss, down to max(cutoff, 68 - tcp_header_len). The max()
here can then push it back above that bound.
For example, take tcp_min_snd_mss = 1000, timestamps enabled, and a peer
max_window of 1200. Then cutoff is 600 and mss_now is 600. If mss_ceiling()
returns 300, mss_now becomes max(300, 988) = 988, which is above the
half-window bound computed just before.
Would min(mss_now, max(mss_ceiling, min_snd_mss)) keep the documented
semantics?
Also, the comment in include/net/tcp.h does not say that a return value of
0 means no ceiling. This code and the BPF CFI stub both rely on that.
> + }
> + }
> +
> /* And store cached results */
> icsk->icsk_pmtu_cookie = pmtu;
> if (icsk->icsk_mtup.enabled)
> @@ -2190,6 +2205,18 @@ unsigned int tcp_current_mss(struct sock *sk)
> return mss_now;
> }
>
> +__bpf_kfunc unsigned int tcp_update_mss_ceiling(struct sock *sk)
> +{
> + struct inet_connection_sock *icsk = inet_csk(sk);
> +
> + if (icsk->icsk_ca_initialized &&
> + icsk->icsk_ca_ops->mss_ceiling &&
> + icsk->icsk_pmtu_cookie)
[Severity: Medium]
Does this gate turn the helper into a no-op in the two places a congestion
control is most likely to need it?
First, tcp_init_congestion_control() calls ->init() before it sets
icsk_ca_initialized:
net/ipv4/tcp_cong.c:tcp_init_congestion_control() {
...
if (icsk->icsk_ca_ops->init)
icsk->icsk_ca_ops->init(sk);
...
icsk->icsk_ca_initialized = 1;
}
So if a CC calls tcp_update_mss_ceiling() from init(), nothing happens. The
connection-setup tcp_sync_mss() calls also all run before CA init:
- tcp_connect_init()
- tcp_rcv_synsent_state_process(), before tcp_finish_connect()
- tcp_v4_syn_recv_sock() and tcp_v6_syn_recv_sock()
As a result the ceiling is not in effect when the connection becomes
established. It stays off until some unrelated tcp_sync_mss() trigger.
Second, tcp_reinit_congestion_control() swaps icsk_ca_ops and calls
tcp_init_congestion_control(), but it never calls tcp_sync_mss(). Suppose a
socket switches with setsockopt(TCP_CONGESTION) from a CC that set a
ceiling to one without mss_ceiling, such as cubic. tp->mss_cache keeps the
reduced value. This helper cannot fix that, because it returns early when
the new ops have no mss_ceiling.
After that, mss_cache is only recomputed on a PMTU change, a successful MTU
probe, peer window growth in tcp_ack_update_window(), or a mss_clamp
change. On a stable path with tcp_mtu_probing=0 and a steady peer window,
would the old CC's ceiling stay in effect for the rest of the connection?
> + return tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
> + return tcp_sk(sk)->mss_cache;
> +}
> +EXPORT_SYMBOL_GPL(tcp_update_mss_ceiling);
[Severity: Low]
This isn't a bug, but nothing in the tree uses the new mss_ceiling member
or the tcp_update_mss_ceiling() export and kfunc. There is also no BPF
selftest under tools/testing/selftests/bpf for the new struct_ops member or
the kfunc. The only stated user is the upcoming TCP Prague.
Could an in-tree user or a selftest be added with this series? No existing
test would catch the issues above.
> +
> /* RFC2861, slow part. Adjust cwnd, after it was not full during one rto.
> * As additional protections, we do not touch cwnd in retransmission phases,
> * and if application hit its sndbuf limit recently.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130125658.20292-1-chia-yu.chang%40nokia-bell-labs.com
prev parent reply other threads:[~2026-12-01 13:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 12:56 [PATCH net-next v5 0/4] TCP Prague preparation series chia-yu.chang
2026-11-30 12:56 ` [PATCH net-next v5 1/4] tcp: export CE count in rate_sample chia-yu.chang
2026-12-01 13:10 ` netdev-bot+sashiko
2026-11-30 12:56 ` [PATCH net-next v5 2/4] tcp: rename ECN transmit helper function chia-yu.chang
2026-11-30 12:56 ` [PATCH net-next v5 3/4] tcp: add TCP_ECN_SEND_ECT_1 flag for congestion control chia-yu.chang
2026-12-01 13:10 ` netdev-bot+sashiko
2026-11-30 12:56 ` [PATCH net-next v5 4/4] tcp: add MSS ceiling callback " chia-yu.chang
2026-12-01 13:10 ` netdev-bot+sashiko [this message]
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=179613062412.3146.15940448870863825733@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=Jason_Livingood@comcast.com \
--cc=Jeff_Howe@comcast.com \
--cc=Mike_Rudolph@comcast.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cheshire@apple.com \
--cc=chia-yu.chang@nokia-bell-labs.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=g.white@cablelabs.com \
--cc=horms@kernel.org \
--cc=ij@kernel.org \
--cc=ingemar.s.johansson@ericsson.com \
--cc=kafai.wan@linux.dev \
--cc=koen0607@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=mirja.kuehlewind@ericsson.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rs.ietf@gmx.at \
--cc=srichard@netapp.com \
--cc=vidhi_goel@apple.com \
--cc=willemb@google.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
all inboxes | Powered by JetHome®