From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: mdshahid03@gmail.com, netdev@vger.kernel.org
Cc: edumazet@kernel.org, ncardwell@google.com, kuniyu@google.com,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, willemb@google.com
Subject: Re: [PATCH net v2] tcp: fix division by zero in tcp_cong_avoid_ai()
Date: Fri, 27 Nov 2026 09:58:16 +0800 [thread overview]
Message-ID: <95498d18-5267-4153-bc06-7b918f9f469c@linux.dev> (raw)
In-Reply-To: <20261126164150.8838-1-mdshahid03@gmail.com>
On 11/27/26 12:41 AM, mdshahid03@gmail.com wrote:
> From: Mohammad Shahid <mdshahid03@gmail.com>
>
> The tcp_cong_avoid_ai() function divides tp->snd_cwnd_cnt by
> the argument w without checking whether w is zero.
>
> Since w is an unsigned value, the condition tp->snd_cwnd_cnt
>> = w does not prevent division by zero when w is zero.
> The function is also exposed as BPF kfunc through the bpf-tcp-cc
> allowlist. The BPF verifier does not enforce a nonzero value for
> this argument.
>
> Return early when w is zero to prevent division by zero.
>
> Fixes: e78aea8b2170 ("bpf: tcp: Put some tcp cong functions in allowlist for bpf-tcp-cc")
> Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
> ---
> net/ipv4/tcp_cong.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
> index 8e83ef81fc18..f70f49b4b1e7 100644
> --- a/net/ipv4/tcp_cong.c
> +++ b/net/ipv4/tcp_cong.c
> @@ -469,6 +469,9 @@ EXPORT_SYMBOL_GPL(tcp_slow_start);
> */
> __bpf_kfunc void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked)
> {
> + if (unlikely(!w))
> + return;
> +
> /* If credits accumulated at a higher w, apply them gently now. */
> if (tp->snd_cwnd_cnt >= w) {
> tp->snd_cwnd_cnt = 0;
prev parent reply other threads:[~2026-11-27 1:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 16:41 [PATCH net v2] tcp: fix division by zero in tcp_cong_avoid_ai() mdshahid03
2026-11-26 16:43 ` netdev-bot+sinfo
2026-11-27 1:58 ` Jiayuan Chen [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=95498d18-5267-4153-bc06-7b918f9f469c@linux.dev \
--to=jiayuan.chen@linux.dev \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mdshahid03@gmail.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.