From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796130626; b=pswyrmvs3R0Nk0W8AMPxIGaQPI3dsFaZOLtyFdc6lZi3h7oyPT/6JzCWjZKXKZybP/MK OyH0XLcoXn7XTPSstYRqq9FVs1gof3HqLmbmTAOKjR8hE/2rD80yJ7DoldSgysJK7reBQ n1EM3eUDhqBbZ2aExXAkkheCCK33rtR0C8JokpEfyBWcASF7sE12/eVKAcsaXSt2NcPKt PZpSUW1EKR8RamSmCd25eg5+PqCa10q8ul0hCrERr4iNGHaf4urLIEhdy5TVPRuVKfv8X h0owpMHwGmEByuSNtza+HoNyQICjE8EwO8dOU8FcGIsu0V2jXZnp8nx040EP4ehTK5w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796130626; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=PDdUJ2uVIsX6UDLWzF4k0PZ/m/iZyi0iHSSiqinJIg0=; b=FrgnT3QBd16LmcRDZWQqVMEKAs51l6HwKdQbpfpslZ40UZgDFbqQw2xsqSeTcR1U0AnW 7YFFvjCrvferi0y8NSpYo9pSzY8Zxor9t1JPQW/OaZpJi/mOkml+MwDsyf+0hZILLGEvN 6PtslbpdC2XKdIni/mwmEW4e1NMKsq5DNKIlk9wfEuw7/hpT97QE/9Upo5yvYvekfPpxQ H93bo63rVU3wK8kTSFJa3JXrpikAoBCHlr4ZJ/DiJTssMaAjwNbF0uKSIEAIE2ZbO6M5X sdPH8lk6UWxXSsUHMM8qRGrIQTDC2FWx6arWshQwQYFpk13h9XJwx8+8R/2u5TggqHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ap3mjnfK; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D844606A336; Tue, 1 Dec 2026 13:10:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ap3mjnfK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 870DD1F000C1; Tue, 1 Dec 2026 13:10:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796130625; bh=PDdUJ2uVIsX6UDLWzF4k0PZ/m/iZyi0iHSSiqinJIg0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Ap3mjnfKTyYBPbwwiaw/7qaingcROHZEqQks8xPd4SOM5K9W8Lm2tFLD4MZ0JITXf vVUp+7p3+x4kcGtrFm6JMCrXG7O74LxHuqCb+/i6suoSm4uxrFVlZrci3/51+hv9nI qw08QR+lvuVBfXMZmd1+E3lxKsCJUJGlrb1bT3DOwQTJEZaSR1HTaokYvD2LKbEg9b 7q2fnl8zyC04BHCyFnKSOZil9BJqad79Iokvmk+c/+L2jFHx/n0nc4AteARuatq+C4 Hxs3mPPAB9hCsveqXLrnr1kgE7ce8zKsrn2tgPEwEVal2aFrQscHTS8jQdKdRELiYt icOGa1AXUzNOA== Subject: Re: [PATCH net-next v5 4/4] tcp: add MSS ceiling callback for congestion control 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 Date: Tue, 01 Dec 2026 13:10:24 +0000 Message-ID: <179613062412.3146.15940448870863825733@kernel.org> In-Reply-To: <20261130125658.20292-5-chia-yu.chang@nokia-bell-labs.com> References: <20261130125658.20292-5-chia-yu.chang@nokia-bell-labs.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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