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=1796129842; b=uFejHxXkBJLe02BfQIaF1lVru1bw2RsrOiR0M/jrw3p6OhUtpvTX8OUKzpNrteLidAnH ukunwWA7Ym5pI97/usvi+w3U8UVvo+TGEXXnCUxWooi2HXcj+t096KovDtC+ypoIhKbsk MEH+lDuqNk4UeZIdNASY5hhjZQI1aC+gq6mlU1qjp4iLYOPhsfn2EGbWyeC9xgh7iQr9S /uRPUsw++R6XW77xWaqgRpMWdBokvZ/EVpgZzVdn8P4Yeo/ZLnmQvBi1XVAyOTOvxw3tv pjnGkJsqoIDJGiTEwdvrMVvNm1+yA7Qk3Y+Tw6yhVV59YSl6KjgZceL9bol19K5rOew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129842; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ypMycYh0MPaV2ppt3aZzjCX9sLIp202+2uNoSD0NXc4=; b=A28srlc9C7Irf8mmzxxcvvV2cktEMnjjLKDhwd5VH1AzKI4c+/icmXKpb9NXxiO3IFON x3+hClfiva0qg3MWyqGQAK1X+cLbitfh3pPNe60oztcqHs5jxwjJQzP6CQNAIL2vCf+H1 IDkbu0wTwkD7ds7wLFiTDQbXbOnARKSqLssT3p1h832gIRktogURlRpTAwr27uCS1uy1v NIkFkdZuLRW95Bxo87smBKvxnYoQy4IVfJlrXoKCo+eEuWBmoNLIJte+UyEOaU7p9jYZx TBOWWenRLE1WQYG9laMBdCvC4dX4OS9bunKdulpj58CJPBWPw0yYnsTuzPlPg6Xifww== 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="P/tF9+86"; 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 CC191606A31A for ; Tue, 1 Dec 2026 12:57:22 +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=P/tF9+86 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 000F81F00897; Tue, 1 Dec 2026 12:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796129842; bh=ypMycYh0MPaV2ppt3aZzjCX9sLIp202+2uNoSD0NXc4=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=P/tF9+86nECRi0GHdvk0AKSYZetwwr52otp7oi+1mB7c0KbVHCICiv90J6K9b/5Cr whPoW5m1NdS++UbjlDhvyfdWd46PK4+n1QLplbKAAPL6JRna2DcHyXzWqS/oSpL1gP WH7V0fOy3PmU2vtxE7Hf12wD8dI/BuaXZTY15BZktHKQXHbfJ50s9YcIWASVcaYgbR vF7clqMDNE20pInC1sQcOdzF/HdbyET7oRq52uMQztZmZmuBYu3lKORrsnF4IPEKDD iuXP9h7JRaEvPSgOx7ONJ+Mdc6/FAstAFuu6Po5TlslI5+q5beW8T60N26ktCZF6cQ ARisdiMdkBgGg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v5 4/4] tcp: add MSS ceiling callback for congestion control Reply-To: sashiko-reviews@lists.linux.dev To: chia-yu.chang@nokia-bell-labs.com, bpf@vger.kernel.org In-Reply-To: <20261130125658.20292-5-chia-yu.chang@nokia-bell-labs.com> References: <20261130125658.20292-1-chia-yu.chang@nokia-bell-labs.com> <20261130125658.20292-5-chia-yu.chang@nokia-bell-labs.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 12:57:21 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [High] tcp: mss_ceiling() skipped at conn init, in ca->init(), and on CC switch - [High] bpf: unbounded recursion when struct_ops mss_ceiling() calls tcp_update_mss_ceiling() - [Medium] tcp: max(mss_ceiling, min_snd_mss) in tcp_sync_mss() overrides half-window bound - [Medium] tcp: tcp_v6_mtu_reduced() drops valid IPv6 PMTU reductions above mss_ceiling - [Medium] tcp: mss_ceiling in tp->mss_cache corrupts MTU probing search_low and snd_cwnd -- commit 6a2835052973696e33d5f9fcd760f0e3858c0186 Author: Chia-Yu Chang tcp: add MSS ceiling callback for congestion control This commit adds an optional mss_ceiling() callback to struct tcp_congestion_ops and a tcp_update_mss_ceiling() helper and BPF kfunc to recompute tp->mss_cache when the congestion control module changes its MSS 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) > BTF_KFUNCS_END(bpf_tcp_ca_check_kfunc_ids) [Severity: High] Can a BPF struct_ops congestion control program overflow the kernel stack by calling tcp_update_mss_ceiling() from inside its mss_ceiling() callback? tcp_update_mss_ceiling() is exposed to all BPF_PROG_TYPE_STRUCT_OPS callbacks without filtering out tcp_congestion_ops.mss_ceiling, and bpf_prog_check_recur() does not enable runtime recursion checks on the trampoline when jits_use_priv_stack is false: tcp_sync_mss(sk, pmtu) icsk->icsk_ca_ops->mss_ceiling(sk) tcp_update_mss_ceiling(sk) tcp_sync_mss(sk, icsk->icsk_pmtu_cookie) icsk->icsk_ca_ops->mss_ceiling(sk) <-- unbounded recursion [ ... ] > 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 pmt= u) > mss_now =3D tcp_mtu_to_mss(sk, pmtu); > mss_now =3D tcp_bound_to_half_wnd(tp, mss_now); > =20 > + /* > + * 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 =3D icsk->icsk_ca_ops->mss_ceiling(sk); > + > + if (mss_ceiling && mss_ceiling < mss_now) { > + u32 min_snd_mss =3D READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_min_snd_m= ss) - > + (tcp_sk(sk)->tcp_header_len - sizeof(struct tcphdr)); > + > + mss_now =3D max(mss_ceiling, min_snd_mss); > + } > + } [Severity: Medium] Can max(mss_ceiling, min_snd_mss) raise mss_now above the peer's half-window bound from tcp_bound_to_half_wnd()? tcp_mtu_to_mss() already enforces sysctl_tcp_min_snd_mss, after which tcp_bound_to_half_wnd() can reduce mss_now below min_snd_mss when the peer advertises a small receive window and sysctl_tcp_min_snd_mss is raised. If mss_ceiling is smaller still, assigning max(mss_ceiling, min_snd_mss) after tcp_bound_to_half_wnd() increases mss_now back up to min_snd_mss instead of capping it. > + > /* And store cached results */ > icsk->icsk_pmtu_cookie =3D pmtu; > if (icsk->icsk_mtup.enabled) [Severity: Medium] As reported by Eric Dumazet on v4 [1], does storing the ceiling-clamped value in tp->mss_cache cause tcp_v6_mtu_reduced() to drop valid IPv6 PMTU reductions above the ceiling? net/ipv6/tcp_ipv6.c:tcp_v6_mtu_reduced() { ... if (tcp_mtu_to_mss(sk, mtu) >=3D tcp_sk(sk)->mss_cache) return; ... } When a Packet Too Big arrives with an MTU below icsk->icsk_pmtu_cookie whose unclamped MSS is still at or above the ceiling-clamped tp->mss_cache, tcp_v6_mtu_reduced() returns early without updating the route PMTU or icsk_pmtu_cookie. Once the congestion control later raises its ceiling and calls tcp_update_mss_ceiling(), tp->mss_cache is recomputed from the stale icsk_pmtu_cookie and oversized packets are sent. [Severity: Medium] Does clamping tp->mss_cache to mss_ceiling also corrupt MTU probing (icsk_mtup) state when probing is enabled? When the reprobe timer fires in tcp_mtu_check_reprobe(), it sets icsk->icsk_mtup.search_low =3D tcp_mss_to_mtu(sk, tcp_current_mss(sk)) from the ceiling-clamped tp->mss_cache, so tcp_sync_mss() then clamps mss_now to that search_low and prevents tp->mss_cache from rising when the congestion control later increases its ceiling. In addition, when a probe succeeds, tcp_mtup_probe_success() scales tp->snd_cwnd down by tcp_mss_to_mtu(sk, tp->mss_cache) / icsk->icsk_mtup.probe_size assuming tp->mss_cache will grow to probe_size, but tcp_sync_mss() re-clamps tp->mss_cache to mss_ceiling and leaves snd_cwnd reduced. > @@ -2190,6 +2205,18 @@ unsigned int tcp_current_mss(struct sock *sk) > return mss_now; > } > =20 > +__bpf_kfunc unsigned int tcp_update_mss_ceiling(struct sock *sk) > +{ > + struct inet_connection_sock *icsk =3D inet_csk(sk); > + > + if (icsk->icsk_ca_initialized && > + icsk->icsk_ca_ops->mss_ceiling && > + icsk->icsk_pmtu_cookie) > + return tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); > + return tcp_sk(sk)->mss_cache; > +} > +EXPORT_SYMBOL_GPL(tcp_update_mss_ceiling); [Severity: High] Does gating on icsk->icsk_ca_initialized and icsk->icsk_ca_ops->mss_ceiling skip applying the ceiling at connection establishment, inside ca_ops->init(= ), and when switching congestion controls? During connection setup, tcp_sync_mss() runs before tcp_init_transfer() initializes congestion control, while icsk_ca_initialized is 0, and records icsk_pmtu_cookie =3D pmtu without calling mss_ceiling(). When tcp_init_congestion_control() then runs: 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 =3D 1; } icsk_ca_initialized is set only after init() returns, so calling tcp_update_mss_ceiling() from ca_ops->init() is a no-op, and nothing calls tcp_sync_mss() once icsk_ca_initialized becomes 1 because dst_mtu(dst) already matches icsk_pmtu_cookie. Conversely, switching via setsockopt(TCP_CONGESTION) from a module with mss_ceiling() to one without it (such as CUBIC) in tcp_reinit_congestion_control() never recomputes tp->mss_cache, leaving the socket stuck at the previous module's ceiling because tcp_update_mss_ceiling() requires icsk_ca_ops->mss_ceiling to be non-NULL. [1] https://lore.kernel.org/r/CAL4Wiip6JFsVH_WAn4HmrXCiuKEJCoZR9nUv9X7RZU73= _YJyzw@mail.gmail.com --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130125658.2029= 2-1-chia-yu.chang@nokia-bell-labs.com?part=3D4