From: Jerry Jiang <kj2864@nyu.edu>
To: Antoine Tenart <atenart@kernel.org>
Cc: ncardwell@google.com, kuniyu@google.com, davem@davemloft.net,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
edumazet@google.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, co+71b6509cb791e531@bugs.sh,
stable@vger.kernel.org
Subject: Re: [PATCH net v4] net: ipv4: add zero check for snd_cwnd_clamp
Date: Mon, 19 Oct 2026 18:26:50 -0400 [thread overview]
Message-ID: <CAPqbLS3wzSQTJJRoBGjJ-C-2GZ95qn6GLAwYBYOt3o75uRiW8Q@mail.gmail.com> (raw)
In-Reply-To: <atXVqZDUhE9Z8InH@kwain>
I apologize for deleting the warning.
v5 is proposed:
https://lore.kernel.org/all/20261019222531.1073-1-kj2864@nyu.edu/
On Mon, Oct 19, 2026 at 4:33 AM Antoine Tenart <atenart@kernel.org> wrote:
>
> On Sat, Oct 17, 2026 at 05:48:46PM -0400, Kaho Jiang wrote:
> > User can pass zero to snd_cwnd_clamp via RTAX_CWND type.
> > This could lead to division of zero error if not checked properly.
> >
> > Oops: divide error: 0000 [#1] SMP KASAN NOPTI
> > Call Trace:
> > <IRQ>
> > tcp_reno_cong_avoid (net/ipv4/tcp_cong.c:510 (discriminator 1))
> > tcp_ack (net/ipv4/tcp_input.c:3517 net/ipv4/tcp_input.c:3873 net/ipv4/tcp_input.c:4440)
> > tcp_rcv_established (net/ipv4/tcp_input.c:6685)
> > tcp_v4_do_rcv (net/ipv4/tcp_ipv4.c:1854)
> > tcp_v4_rcv (net/ipv4/tcp_ipv4.c:2248)
> > ip_protocol_deliver_rcu (net/ipv4/ip_input.c:207 (discriminator 1))
> > ip_local_deliver_finish (net/ipv4/ip_input.c:241 (discriminator 1))
> > ip_local_deliver (./include/linux/netfilter.h:325 ./include/linux/netfilter.h:319 net/ipv4/ip_input.c:262)
> > ip_rcv (./include/net/dst.h:481 (discriminator 6) net/ipv4/ip_input.c:492 (discriminator 6) ./include/linux/netfilter.h:325 (discriminator 6) ./include/li)
> > __netif_receive_skb_one_core (net/core/dev.c:6297 (discriminator 4))
> > __netif_receive_skb (net/core/dev.c:6410)
> > process_backlog (net/core/dev.c:6761)
> > __napi_poll.constprop.0 (net/core/dev.c:7830)
> > net_rx_action (net/core/dev.c:7893 net/core/dev.c:8050)
> > handle_softirqs (kernel/softirq.c:645)
> > __irq_exit_rcu (kernel/softirq.c:679 kernel/softirq.c:519 kernel/softirq.c:758)
> > irq_exit_rcu (kernel/softirq.c:775)
> > sysvec_apic_timer_interrupt (arch/x86/kernel/apic/apic.c:1062 (discriminator 35) arch/x86/kernel/apic/apic.c:1062 (discriminator 35))
> > RIP: 0010:tcp_cong_avoid_ai (net/ipv4/tcp_cong.c:482)
> >
> > Fix by checking if user pass in zero as parameter,
> > if so reject the value zero.
> >
> > Fixes: 814d488c6126 ("tcp: fix the timid additive increase on stretch ACKs")
> > Cc: stable@vger.kernel.org
> > Reported-by: co+71b6509cb791e531@bugs.sh
> > Assisted-by: LLM
> > Signed-off-by: Kaho Jiang <kj2864@nyu.edu>
> > ---
> > include/net/tcp.h | 3 +--
> > net/ipv4/metrics.c | 4 ++++
> > 2 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/net/tcp.h b/include/net/tcp.h
> > index 4416cdf9bf30..ad80b8fb8a52 100644
> > --- a/include/net/tcp.h
> > +++ b/include/net/tcp.h
> > @@ -1521,8 +1521,7 @@ static inline u32 tcp_snd_cwnd(const struct tcp_sock *tp)
> >
> > static inline void tcp_snd_cwnd_set(struct tcp_sock *tp, u32 val)
> > {
> > - WARN_ON_ONCE((int)val <= 0);
> > - WRITE_ONCE(tp->snd_cwnd, val);
> > + WRITE_ONCE(tp->snd_cwnd, max(val, 1U));
>
> Please keep the warning (it's not only about 0).
>
> > }
> >
> > static inline bool tcp_in_slow_start(const struct tcp_sock *tp)
> > diff --git a/net/ipv4/metrics.c b/net/ipv4/metrics.c
> > index ad40762a8b38..cb36686973e5 100644
> > --- a/net/ipv4/metrics.c
> > +++ b/net/ipv4/metrics.c
> > @@ -54,6 +54,10 @@ static int ip_metrics_convert(struct nlattr *fc_mx,
> > NL_SET_ERR_MSG(extack, "Unknown flag set in feature mask in metrics attribute");
> > return -EINVAL;
> > }
> > + if (type == RTAX_CWND && !val) {
> > + NL_SET_ERR_MSG(extack, "RTAX_CWND must be greater than zero");
> > + return -EINVAL;
> > + }
> > metrics[type - 1] = val;
> > }
> >
> > --
> > 2.43.0
> >
prev parent reply other threads:[~2026-10-19 22:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-17 21:48 Kaho Jiang
2026-10-18 22:31 ` netdev-bot+sashiko
2026-10-19 8:33 ` Antoine Tenart
2026-10-19 22:26 ` Jerry Jiang [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=CAPqbLS3wzSQTJJRoBGjJ-C-2GZ95qn6GLAwYBYOt3o75uRiW8Q@mail.gmail.com \
--to=kj2864@nyu.edu \
--cc=atenart@kernel.org \
--cc=co+71b6509cb791e531@bugs.sh \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®