From: sashiko-bot@kernel.org
To: "Tejas Birajdar" <tejasbirajdar@meta.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v2] tcp: honor BPF_SOCK_OPS_RWND_INIT on the active connect path
Date: Fri, 24 Jul 2026 21:42:40 +0000 [thread overview]
Message-ID: <20260724214241.199131F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260723214208.3655474-1-tejasbirajdar@meta.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Medium] Incomplete fix for integer overflow when computing the initial receive window in tcp_select_initial_window().
--
--- Patch [1]: [PATCH net-next v2] tcp: honor BPF_SOCK_OPS_RWND_INIT on the active connect path ---
commit 49a334daa027598fc715c7e2fdf73a1c1031f8be
Author: Tejas Birajdar <tejasbirajdar@meta.com>
Subject: tcp: honor BPF_SOCK_OPS_RWND_INIT on the active connect path
This commit enables the BPF_SOCK_OPS_RWND_INIT hook to set the initial TCP
receive window on the active connect path, matching the behavior of the
passive listener path. It also attempts to prevent integer overflow by
computing the inflated space in 64-bit arithmetic and clamping to INT_MAX.
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index d7c1444b5e304..ffa28c98c2118 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
[ ... ]
> @@ -4137,10 +4138,13 @@ static void tcp_connect_init(struct sock *sk)
> WRITE_ONCE(tp->window_clamp, tcp_full_space(sk));
>
> rcv_wnd = tcp_rwnd_init_bpf(sk);
> + full_space = tcp_full_space(sk);
> if (rcv_wnd == 0)
> rcv_wnd = dst_metric(dst, RTAX_INITRWND);
> + else if (full_space < (u64)rcv_wnd * tp->advmss)
> + full_space = min_t(u64, (u64)rcv_wnd * tp->advmss, INT_MAX);
>
> - tcp_select_initial_window(sk, tcp_full_space(sk),
> + tcp_select_initial_window(sk, full_space,
> tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0),
> &tp->rcv_wnd,
> &tp->window_clamp,
[Severity: Medium]
This is a pre-existing issue, but does the initial receive window calculation
still overflow inside tcp_select_initial_window() despite the u64 promotion
done here?
When a BPF program returns a very large initial receive window value (for
example, > 2941760 when MSS is 1460), the value is passed as the init_rcv_wnd
parameter into tcp_select_initial_window().
Inside net/ipv4/tcp_output.c:tcp_select_initial_window():
void tcp_select_initial_window(..., __u32 mss, ..., __u32 init_rcv_wnd)
{
...
if (init_rcv_wnd)
*rcv_wnd = min(*rcv_wnd, init_rcv_wnd * mss);
...
}
Because both init_rcv_wnd and mss are 32-bit types, does this multiplication
overflow and wrap around to a small value? This collapses the offered initial
receive window and appears to completely bypass the u64 overflow protection
this patch aims to introduce.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723214208.3655474-1-tejasbirajdar@meta.com?part=1
prev parent reply other threads:[~2026-07-24 21:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 21:42 [PATCH net-next v2] tcp: honor BPF_SOCK_OPS_RWND_INIT on the active connect path Tejas Birajdar
2026-07-24 21:42 ` sashiko-bot [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=20260724214241.199131F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tejasbirajdar@meta.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