Article View: linux.kernel.netdev
Article #3875Re: [PATCH net v2] net: ipv4: add zero check for snd_cwnd_clamp
From: Antoine Tenart
Date: Fri, 16 Oct 2026 07:29
Date: Fri, 16 Oct 2026 07:29
75 lines
9355 bytes
9355 bytes
On Thu, Oct 15, 2026 at 12:57:51PM -0400, Jerry Jiang wrote:
> I have considered rejecting 0 in tcp_snd_cwnd_set but afaik patching
> tcp_snd_cwnd only would just ignore the problem. My current patch
> should completely reject the user from creating a socket if 0 is
> passed for RTAX_CWND.
I'm not arguing against the current patch. My point is warning on 0
values in tcp_snd_cwnd_set made sense before but since this is now known
to cause oops there might be something better to do there.
> On Thu, Oct 15, 2026 at 5:57 AM Antoine Tenart <atenart@kernel.org> wrote:
> >
> > On Wed, Oct 14, 2026 at 03:56:41PM -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: 51c5d0c4b169 ("tcp: Maintain dynamic metrics in local cache.")
> >
> > This looks like a refactoring commit only, 814d488c6126 might be more
> > appropriate but please check.
> >
> > > Cc: stable@vger.kernel.org
> > > Reported-by: co+71b6509cb791e531@bugs.sh
> > > Assisted-by: LLM
> > > Signed-off-by: Kaho Jiang <kj2864@nyu.edu>
> > > ---
> > > net/ipv4/metrics.c | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > diff --git a/net/ipv4/metrics.c b/net/ipv4/metrics.c
> > > index ad40762a8b38..e83a129a25b6 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 == 0) {
> > > + NL_SET_ERR_MSG(extack, "RTAX_CWND must be greater than zero");
> > > + return -EINVAL;
> > > + }
> > > metrics[type - 1] = val;
> > > }
> >
> > My understanding is tcp_snd_cwnd(tp) can return 0 and then the divide by
> > 0 occurs in tcp_cong_avoid_ai. Have you also considered updating
> > tcp_snd_cwnd_set to not only warn about invalid values but also reject
> > them, preventing similar oops?
Technical Details
Message-ID:
<atHQupHr7_ocAJ_A@kwain>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347152-linux-kernel-netdev=dewy.ruReferences:
<20261014195640.430824-2-kj2864@nyu.edu> <atCf_85Ei_J9CDtd@kwain> <CAPqbLS2sM9JZ8VbrzWviV-6XNRniKib_L+seaKtnCfR3pwMMig@mail.gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347152-linux-kernel-netdev=dewy.ru From: atenart@kernel.org (Antoine Tenart) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] net: ipv4: add zero check for snd_cwnd_clamp Date: Fri, 16 Oct 2026 09:29:42 +0200 Organization: Usenet Network Message-ID: <atHQupHr7_ocAJ_A@kwain> References: <20261014195640.430824-2-kj2864@nyu.edu> <atCf_85Ei_J9CDtd@kwain> <CAPqbLS2sM9JZ8VbrzWviV-6XNRniKib_L+seaKtnCfR3pwMMig@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2708579"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Y1jYaxIme2ZNhL6d9KQwlAKEGgo= sha256:Czdj4lSufXAzsjjxEoqgTS7nW27cyKD31+yOv8m3rE0= sha1:P1kx5rMCZsoKSNxLYKsnQGBc8lQ= sha256:fuOlqB8A/KG0hqH2aKJh51Hs5jkG12ao837RcM73AH4= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 71D3C11048C; Fri, 16 Oct 2026 10:30:06 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.64 X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QfKWDd_MYs8s; Fri, 16 Oct 2026 10:30:03 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-347152-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 409F3110484; Fri, 16 Oct 2026 10:29:54 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 0416631F6F; Fri, 16 Oct 2026 07:29:52 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0A183E5A2F; Fri, 16 Oct 2026 07:29:48 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AqpNx+Hj" X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2B9B265623; Fri, 16 Oct 2026 07:29:47 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792135788; cv=none; b=fiWoaWsY55epIUNiCofJrIbFZzwlojanev41XHvVzvYnrqIs/3o0r02xfRxVUUbQg2AzTgwNH/CDLiWSOTE9ll95XLmBrRehjy5BKcl1uOADuEJHuNEhHFhC8ehqHXoKAUeieBhoZlN5gye3pmjW7tCOfiThpGXx2gx1Q+K/VpE= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792135788; c=relaxed/simple; bh=gmV+GbP2VEl5VU13HkRril9s1wl4NEpe5TWY5aTceAg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R4TbccONgowDsg6DbzwDHYDdjfOwRPAJg9MfvzFW/kALL6EM7ePbx4QwbLGAlo6rCxF17DlxqrFMG0A3ss1XaxHFhhF28QwZLBHfVu0YLgTiTFpMAcr+nNGAhMkoXHk5VIewNnjelXfZQCfQUihF2UAlm/0rNJLBk3r3NXd9jFo= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AqpNx+Hj; arc=none smtp.client-ip=100.103.45.18 X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 947EB1F000C4; Fri, 16 Oct 2026 07:29:46 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792135787; bh=k9n7YXXh/4p8cv6sga3JFDGjo9ZmIZeY5cQUzxvZfwM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=AqpNx+HjnUmXVZkNrUGL7lqQDAWLO8RwttV7lMcj9654og8/qd7dd/+SorEXqC6Uu fSnqiXYu3yf2/2DsyUe3KdoXvXqWFQvaod8XHmIxkaE3V7UxyhWQQ9PF/jBhxhRaFC tk/S92/EmbrqY9LZ5V+6rPxp52d0kE218RkUnBSwD2/HFJRC3sJUzcYi8f9H5UEAh7 JJD3NExpWEalnbqFAHGA56qTC2AHFfDMakvZ4pRuZ8JBkCL75dDdkXrrb+TUvdkFB0 DMoK6QhXilPlYw7GXgnHd58IfxSVhwjizlyA6trEWtFn0CB3jj3Ttxof0fPw/JNyXV MspwDeqeK+18w== X-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 X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-In-Reply-To: <CAPqbLS2sM9JZ8VbrzWviV-6XNRniKib_L+seaKtnCfR3pwMMig@mail.gmail.com>