mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: jiayuan.chen@linux.dev
Cc: netdev@vger.kernel.org, stable@vger.kernel.org,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, dsahern@kernel.org,
	idosch@nvidia.com, kuniyu@google.com, joel.granados@kernel.org,
	chia-yu.chang@nokia-bell-labs.com, bronzed_45_vested@icloud.com,
	yuuchihsu@gmail.com, fmancera@suse.de,
	hannes@stressinduktion.org, fbl@redhat.com, pmladek@suse.com,
	paulmck@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 1/5] ipv6: restrict gc_elasticity to 31
Date: Mon, 26 Oct 2026 12:15:38 +0000	[thread overview]
Message-ID: <179301693822.3134.16821045137329382001@kernel.org> (raw)
In-Reply-To: <20261023091419.167088-2-jiayuan.chen@linux.dev>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message for "ipv6: restrict gc_elasticity to 31" says
  only "Cap it at 31", and its reasoning covers only values >= 32.

--

ipv6: restrict gc_elasticity to 31

This commit switches the net.ipv6.route.gc_elasticity sysctl from
proc_dointvec to proc_dointvec_minmax with bounds [0, 31]. The upper bound
avoids an out-of-bounds shift of the u32 ip6_rt_gc_expire in ip6_dst_gc()
that UBSAN reported.

> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 94e5ef1c4f83e..6f2efc219f395 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c

[ ... ]

> @@ -6627,7 +6629,9 @@ static const struct ctl_table ipv6_route_table_template[] = {
>  		.data		=	&init_net.ipv6.sysctl.ip6_rt_gc_elasticity,
>  		.maxlen		=	sizeof(int),
>  		.mode		=	0644,
> -		.proc_handler	=	proc_dointvec,
> +		.proc_handler	=	proc_dointvec_minmax,
> +		.extra1		=	SYSCTL_ZERO,

[Severity: Low]
This isn't a bug, but should the commit message mention the new lower
bound too?

The changelog says:

  Cap it at 31. 31 and 32 are equivalent anyway [ ... ]
  Values above 31 add no new behaviour, they only hit the UB.

This only covers values >= 32. With extra1 set to SYSCTL_ZERO, negative
writes that proc_dointvec used to accept will now fail as well.

The lower bound also fixes real UB. In ip6_dst_gc(), rt_elasticity is a
signed int read from the sysctl:

	int rt_elasticity = READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_elasticity);
	[ ... ]
	atomic_set(&net->ipv6.ip6_rt_gc_expire, val - (val >> rt_elasticity));

so a negative value also gives a negative shift count.

"Cap" also reads as if values get clamped. proc_dointvec_minmax actually
rejects writes outside [0, 31] with -EINVAL.

Since this is tagged for stable, could the changelog say that writes
outside [0, 31] are now rejected in both directions? That would help
anyone with a negative or >= 32 value in sysctl.conf who starts seeing
the write fail.

> +		.extra2		=	&ip6_rt_gc_elasticity_max,
>  	},
>  	{
>  		.procname	=	"mtu_expires",

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261023091419.167088-1-jiayuan.chen%40linux.dev

  parent reply	other threads:[~2026-10-26 12:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23  9:13 [PATCH net 0/5] net: fix misc signed overflows caused by bad sysctl values Jiayuan Chen
2026-10-23  9:13 ` [PATCH net 1/5] ipv6: restrict gc_elasticity to 31 Jiayuan Chen
2026-10-23 13:31   ` Fernando Fernandez Mancera
2026-10-26 12:15   ` netdev-bot+sashiko [this message]
2026-10-27  5:18   ` Kuniyuki Iwashima
2026-10-23  9:13 ` [PATCH net 2/5] ipv4: fix shift-out-of-bounds in ip_rt_send_redirect() Jiayuan Chen
2026-10-23 14:11   ` Fernando Fernandez Mancera
2026-10-23 14:38     ` Jiayuan Chen
2026-10-26 12:15   ` netdev-bot+sashiko
2026-10-23  9:13 ` [PATCH net 3/5] ipv6: restrict mld_qrv to 255 Jiayuan Chen
2026-10-23 14:13   ` Fernando Fernandez Mancera
2026-10-26 12:15   ` netdev-bot+sashiko
2026-10-27  5:24   ` Kuniyuki Iwashima
2026-10-23  9:13 ` [PATCH net 4/5] ipv4: restrict igmp_qrv " Jiayuan Chen
2026-10-23 14:14   ` Fernando Fernandez Mancera
2026-10-26 12:15   ` netdev-bot+sashiko
2026-10-27  5:25   ` Kuniyuki Iwashima
2026-10-23  9:13 ` [PATCH net 5/5] net: restrict message_cost and message_burst to non-negative values Jiayuan Chen
2026-10-23 12:19   ` Joel Granados
2026-10-23 12:55     ` Fernando Fernandez Mancera
2026-10-23 14:30       ` Jiayuan Chen

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=179301693822.3134.16821045137329382001@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=bronzed_45_vested@icloud.com \
    --cc=chia-yu.chang@nokia-bell-labs.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=fbl@redhat.com \
    --cc=fmancera@suse.de \
    --cc=hannes@stressinduktion.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=jiayuan.chen@linux.dev \
    --cc=joel.granados@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=pmladek@suse.com \
    --cc=stable@vger.kernel.org \
    --cc=yuuchihsu@gmail.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

all inboxes | Powered by JetHome®