Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by mdshahid03
Thu, 26 Nov 2026 16:41
[PATCH net v2] tcp: fix division by zero in tcp_cong_avoid_ai()
Author: mdshahid03
Date: Thu, 26 Nov 2026 16:41
Date: Thu, 26 Nov 2026 16:41
37 lines
11622 bytes
11622 bytes
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>
---
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;
--
2.43.0
Re: [PATCH net v2] tcp: fix division by zero in tcp_cong_avoid_ai()
Author: netdev-bot+sinfo
Date: Thu, 26 Nov 2026 16:43
Date: Thu, 26 Nov 2026 16:43
23 lines
8599 bytes
8599 bytes
Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. - Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. *IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. -- The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Re: [PATCH net v2] tcp: fix division by zero in tcp_cong_avoid_ai()
Author: Jiayuan Chen
Date: Fri, 27 Nov 2026 01:58
Date: Fri, 27 Nov 2026 01:58
41 lines
9547 bytes
9547 bytes
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;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads