From: Paolo Abeni <pabeni@redhat.com>
To: Tejas Birajdar <tejasbirajdar@meta.com>,
Eric Dumazet <edumazet@google.com>
Cc: bpf@vger.kernel.org,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
sashiko-reviews@lists.linux.dev
Subject: Re: [PATCH net-next v3] tcp: honor BPF_SOCK_OPS_RWND_INIT on the active connect path
Date: Thu, 6 Aug 2026 11:15:08 +0200 [thread overview]
Message-ID: <1f36d5be-906a-4ba5-8679-24cbcf899254@redhat.com> (raw)
In-Reply-To: <20260731220124.B0C621F00AC4@smtp.kernel.org>
On 8/1/26 12:01 AM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [Medium] The `SOCK_RCVBUF_LOCK` check executes before the BPF program runs and before `full_space` is inflated, silently defeating BPF-requested windows and bypassing dynamic `SO_RCVBUF` adjustments.
> --
>
> --- Patch [1]: [PATCH net-next v3] tcp: honor BPF_SOCK_OPS_RWND_INIT on the active connect path ---
> commit 2cf5d1d17ae1c7488533ecaa0fcbb83ae4591ec8
> Author: Tejas Birajdar <tejasbirajdar@meta.com>
>
> tcp: honor BPF_SOCK_OPS_RWND_INIT on the active connect path
>
> This commit updates tcp_connect_init() to honor the initial TCP receive
> window requested by a BPF_SOCK_OPS_RWND_INIT program on the active connect
> path. It inflates full_space if the program returns a non-zero window,
> matching the listener path's behavior, and uses u64 arithmetic to prevent
> overflows.
>
> Link: https://lore.kernel.org/netdev/20260723214208.3655474-1-tejasbirajdar@meta.com/
> Link: https://lore.kernel.org/netdev/20260722170033.2763794-1-tejasbirajdar@meta.com/
>
>> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
>> index d7c1444b5e304..fcaa04e65189b 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);
>
> [Severity: Medium]
> This is a pre-existing issue, but does the SOCK_RCVBUF_LOCK check happening
> before the BPF program runs defeat the purpose of allowing BPF to adjust
> the receive window?
>
> If an application sets SO_RCVBUF prior to connect(), SOCK_RCVBUF_LOCK is
> set. In tcp_connect_init(), this caps tp->window_clamp to the old
> tcp_full_space() before tcp_rwnd_init_bpf() is invoked.
>
> When the BPF program returns a large requested window and full_space is
> inflated, tcp_select_initial_window() bounds space by
> min(window_clamp, space).
>
> This caps it right back to the pre-BPF full_space and discards the BPF
> request.
>
> Conversely, if the application did not set SO_RCVBUF but the BPF program
> adjusts it dynamically (which sets SOCK_RCVBUF_LOCK),
I read the above alike: 'a badly written bpf program could be
ineffective'; not much relevant.
This version LGTM; Eric do you have some comments?
Thanks,
Paolo
next prev parent reply other threads:[~2026-08-06 9:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 22:00 [PATCH net-next v3] tcp: honor BPF_SOCK_OPS_RWND_INIT on the active connect path Tejas Birajdar
[not found] ` <20260731220124.B0C621F00AC4@smtp.kernel.org>
2026-08-06 9:15 ` Paolo Abeni [this message]
2026-08-06 13:45 ` Eric Dumazet
2026-08-06 19:40 ` patchwork-bot+netdevbpf
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=1f36d5be-906a-4ba5-8679-24cbcf899254@redhat.com \
--to=pabeni@redhat.com \
--cc=bpf@vger.kernel.org \
--cc=edumazet@google.com \
--cc=netdev@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