All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Granados <joel.granados@kernel.org>
To: wen.yang@linux.dev
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 01/39] sysctl: replace overloaded extra pointers with typed bounds and context
Date: Sat, 7 Nov 2026 18:43:52 +0100	[thread overview]
Message-ID: <au9L9-UqlO90UbSQ@hobbes> (raw)
In-Reply-To: <fec089bb7a3ea62a5e2006cf578b1efec2df4aff.1793204511.git.wen.yang@linux.dev>

[-- Attachment #1: Type: text/plain, Size: 28121 bytes --]

On Thu, Oct 29, 2026 at 12:34:40AM +0800, wen.yang@linux.dev wrote:
> From: Wen Yang <wen.yang@linux.dev>
> 
> struct ctl_table has two untyped misc pointers, extra1 and extra2, whose
> meaning depends on the handler that reads them. In-tree use has grown to
> cover at least seven unrelated jobs: a fixed bound, a bound read through a
> pointer on every call, an object or namespace pointer, a small integer
> cookie encoded into the pointer, a lock signal, NULL standing for "no
<... snip ...>
>  #include <linux/nsproxy.h>
>  #include <linux/sysctl.h>
> @@ -80,6 +81,8 @@ static const struct ctl_table ipc_sysctls[] = {
>  		.maxlen		= sizeof(init_ipc_ns.shm_ctlmax),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "shmall",
> @@ -87,6 +90,8 @@ static const struct ctl_table ipc_sysctls[] = {
>  		.maxlen		= sizeof(init_ipc_ns.shm_ctlall),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "shmmni",
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index f5145b32f6be..7d0bcd2b24ef 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -423,11 +423,15 @@ int proc_uint_conv(ulong *u_ptr, uint *k_ptr, int dir,
>  		ret = user_to_kern(u_ptr, &tmp_k);
>  		if (ret)
>  			return ret;
> -		if ((tbl->extra1 &&
> -		     *(uint *)tbl->extra1 > tmp_k) ||
> -		    (tbl->extra2 &&
> -		     *(uint *)tbl->extra2 < tmp_k))
> +		if (tbl->extra1 || tbl->extra2) {
> +			if ((tbl->extra1 &&
> +			     *(uint *)tbl->extra1 > tmp_k) ||
> +			    (tbl->extra2 &&
> +			     *(uint *)tbl->extra2 < tmp_k))
> +				return -ERANGE;
> +		} else if (tbl->min > tmp_k || tbl->max < tmp_k) {

One of the things that the void * pointers coded was whether there was a
value there to use for the range check. If there was not value (NULL),
then there was no check.

I see that you are changing all the callers in such a way that they
define the min max every time, but this is not really needed if you
end up calling a converter that does not check range, you will never
use those values.

Is there a way to tell from within the sysctl core that there needs to
be a range check? I think max == min == 0 is not a good option as zero
is a valid value.

I wonder if we can use the hole (I think it is 2 byte) in the ctl_table
struct. Could we add a bit flag there and then code whether to do the
range check or not?

Best


>  			return -ERANGE;
> +		}
>  		WRITE_ONCE(*k_ptr, tmp_k);
>  	} else
>  		return user_to_kern(u_ptr, k_ptr);
> @@ -543,17 +547,19 @@ int proc_int_conv(bool *negp, ulong *u_ptr, int *k_ptr, int dir,
>  		ret = user_to_kern(negp, u_ptr, &tmp_k);
>  		if (ret)
>  			return ret;
> -		if ((tbl->extra1 && *(int *)tbl->extra1 > tmp_k) ||
> -		    (tbl->extra2 && *(int *)tbl->extra2 < tmp_k))
> +		if (tbl->extra1 || tbl->extra2) {
> +			if ((tbl->extra1 && *(int *)tbl->extra1 > tmp_k) ||
> +			    (tbl->extra2 && *(int *)tbl->extra2 < tmp_k))
> +				return -EINVAL;
> +		} else if ((long)tbl->min > tmp_k || (long)tbl->max < tmp_k) {
>  			return -EINVAL;
> +		}
>  		WRITE_ONCE(*k_ptr, tmp_k);
>  	} else
>  		return user_to_kern(negp, u_ptr, k_ptr);
>  	return 0;
>  }
>  
> -
> -
>  static int sysctl_user_to_kern_int_conv(const bool *negp, const ulong *u_ptr,
>  					int *k_ptr)
>  {
> @@ -985,7 +991,7 @@ int proc_dou8vec_minmax(const struct ctl_table *table, int dir,
>  			void *buffer, size_t *lenp, loff_t *ppos)
>  {
>  	struct ctl_table tmp;
> -	unsigned int min = 0, max = 255U, val;
> +	unsigned int val;
>  	u8 *data = table->data;
>  	int res;
>  
> @@ -997,10 +1003,6 @@ int proc_dou8vec_minmax(const struct ctl_table *table, int dir,
>  
>  	tmp.maxlen = sizeof(val);
>  	tmp.data = &val;
> -	if (!tmp.extra1)
> -		tmp.extra1 = (unsigned int *) &min;
> -	if (!tmp.extra2)
> -		tmp.extra2 = (unsigned int *) &max;
>  
>  	val = READ_ONCE(*data);
>  	res = proc_douintvec_minmax(&tmp, dir, buffer, lenp, ppos);
> @@ -1045,9 +1047,13 @@ int proc_ulong_conv(ulong *u_ptr, ulong *k_ptr, int dir,
>  		ret = user_to_kern(u_ptr, &tmp_k);
>  		if (ret)
>  			return ret;
> -		if ((tbl->extra1 && *(ulong *)tbl->extra1 > tmp_k) ||
> -		    (tbl->extra2 && *(ulong *)tbl->extra2 < tmp_k))
> +		if (tbl->extra1 || tbl->extra2) {
> +			if ((tbl->extra1 && *(ulong *)tbl->extra1 > tmp_k) ||
> +			    (tbl->extra2 && *(ulong *)tbl->extra2 < tmp_k))
> +				return -ERANGE;
> +		} else if (tbl->min > tmp_k || tbl->max < tmp_k) {
>  			return -ERANGE;
> +		}
>  		WRITE_ONCE(*k_ptr, tmp_k);
>  	} else
>  		return user_to_kern(u_ptr, k_ptr);
> diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c
> index 65ce42346170..eed2cc1bea82 100644
> --- a/lib/test_sysctl.c
> +++ b/lib/test_sysctl.c
> @@ -15,6 +15,7 @@
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>  
>  #include <linux/init.h>
> +#include <linux/limits.h>
>  #include <linux/jiffies.h>
>  #include <linux/list.h>
>  #include <linux/module.h>
> @@ -217,6 +218,8 @@ static const struct ctl_table test_table_unregister[] = {
>  		.maxlen		= sizeof(int),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec_minmax,
> +		.min		= INT_MIN,
> +		.max		= INT_MAX,
>  	},
>  };
>  
> diff --git a/mm/util.c b/mm/util.c
> index 8acfe2148ba5..2f2bc521868a 100644
> --- a/mm/util.c
> +++ b/mm/util.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0-only
>  #include <linux/mm.h>
> +#include <linux/limits.h>
>  #include <linux/slab.h>
>  #include <linux/string.h>
>  #include <linux/compiler.h>
> @@ -880,6 +881,8 @@ static const struct ctl_table util_sysctl_table[] = {
>  		.maxlen		= sizeof(sysctl_user_reserve_kbytes),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "admin_reserve_kbytes",
> @@ -887,6 +890,8 @@ static const struct ctl_table util_sysctl_table[] = {
>  		.maxlen		= sizeof(sysctl_admin_reserve_kbytes),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  };
>  
> diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
> index ddb6a5817d09..a2167f76ecc3 100644
> --- a/net/ieee802154/6lowpan/reassembly.c
> +++ b/net/ieee802154/6lowpan/reassembly.c
> @@ -10,6 +10,7 @@
>  #define pr_fmt(fmt) "6LoWPAN: " fmt
>  
>  #include <linux/net.h>
> +#include <linux/limits.h>
>  #include <linux/list.h>
>  #include <linux/netdevice.h>
>  #include <linux/random.h>
> @@ -332,12 +333,16 @@ static struct ctl_table lowpan_frags_ns_ctl_table[] = {
>  		.maxlen		= sizeof(unsigned long),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "6lowpanfrag_low_thresh",
>  		.maxlen		= sizeof(unsigned long),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "6lowpanfrag_time",
> diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
> index c790d2f49487..75bc675e5579 100644
> --- a/net/ipv4/ip_fragment.c
> +++ b/net/ipv4/ip_fragment.c
> @@ -24,6 +24,7 @@
>  #define pr_fmt(fmt) "IPv4: " fmt
>  
>  #include <linux/compiler.h>
> +#include <linux/limits.h>
>  #include <linux/module.h>
>  #include <linux/types.h>
>  #include <linux/mm.h>
> @@ -551,12 +552,16 @@ static struct ctl_table ip4_frags_ns_ctl_table[] = {
>  		.maxlen		= sizeof(unsigned long),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "ipfrag_low_thresh",
>  		.maxlen		= sizeof(unsigned long),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "ipfrag_time",
> diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
> index e3760daa3470..2ed9f59ea747 100644
> --- a/net/ipv4/sysctl_net_ipv4.c
> +++ b/net/ipv4/sysctl_net_ipv4.c
> @@ -7,6 +7,7 @@
>   */
>  
>  #include <linux/sysctl.h>
> +#include <linux/limits.h>
>  #include <linux/seqlock.h>
>  #include <linux/init.h>
>  #include <linux/slab.h>
> @@ -564,6 +565,8 @@ static struct ctl_table ipv4_table[] = {
>  		.data		= &sysctl_tcp_mem,
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "tcp_low_latency",
> @@ -614,6 +617,8 @@ static struct ctl_table ipv4_table[] = {
>  		.maxlen		= sizeof(sysctl_udp_mem),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "fib_sync_mem",
> @@ -778,6 +783,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "ip_early_demux",
> @@ -785,6 +792,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname       = "udp_early_demux",
> @@ -792,6 +801,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen         = sizeof(u8),
>  		.mode           = 0644,
>  		.proc_handler   = proc_dou8vec_minmax,
> +		.min           = 0,
> +		.max           = U8_MAX,
>  	},
>  	{
>  		.procname       = "tcp_early_demux",
> @@ -799,6 +810,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen         = sizeof(u8),
>  		.mode           = 0644,
>  		.proc_handler   = proc_dou8vec_minmax,
> +		.min           = 0,
> +		.max           = U8_MAX,
>  	},
>  	{
>  		.procname       = "nexthop_compat_mode",
> @@ -845,6 +858,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "ip_forward_use_pmtu",
> @@ -852,6 +867,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "ip_forward_update_priority",
> @@ -868,6 +885,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "ip_autobind_reuse",
> @@ -884,6 +903,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_fwmark_accept",
> @@ -891,6 +912,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  #ifdef CONFIG_NET_L3_MASTER_DEV
>  	{
> @@ -909,6 +932,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_base_mss",
> @@ -956,6 +981,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "igmp_max_memberships",
> @@ -1013,6 +1040,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_keepalive_intvl",
> @@ -1036,6 +1065,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  #ifdef CONFIG_SYN_COOKIES
>  	{
> @@ -1044,6 +1075,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  #endif
>  	{
> @@ -1078,6 +1111,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_orphan_retries",
> @@ -1085,6 +1120,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_fin_timeout",
> @@ -1212,6 +1249,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_window_scaling",
> @@ -1219,6 +1258,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_timestamps",
> @@ -1226,6 +1267,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_early_retrans",
> @@ -1242,6 +1285,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname       = "tcp_thin_linear_timeouts",
> @@ -1249,6 +1294,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen         = sizeof(u8),
>  		.mode           = 0644,
>  		.proc_handler   = proc_dou8vec_minmax,
> +		.min           = 0,
> +		.max           = U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_slow_start_after_idle",
> @@ -1256,6 +1303,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_retrans_collapse",
> @@ -1263,6 +1312,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_stdurg",
> @@ -1270,6 +1321,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_rfc1337",
> @@ -1277,6 +1330,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_abort_on_overflow",
> @@ -1284,6 +1339,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_fack",
> @@ -1291,6 +1348,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_max_reordering",
> @@ -1306,6 +1365,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_app_win",
> @@ -1331,6 +1392,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_no_metrics_save",
> @@ -1338,6 +1401,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_no_ssthresh_metrics_save",
> @@ -1354,6 +1419,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_rcvbuf_low_rtt",
> @@ -1370,6 +1437,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_workaround_signed_windows",
> @@ -1377,6 +1446,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_limit_output_bytes",
> @@ -1406,6 +1477,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "tcp_min_rtt_wlen",
> @@ -1472,6 +1545,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(unsigned long),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "tcp_comp_sack_rtt_percent",
> @@ -1488,6 +1563,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen		= sizeof(unsigned long),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "tcp_comp_sack_nr",
> @@ -1601,6 +1678,8 @@ static const struct ctl_table ipv4_net_table[] = {
>  		.maxlen         = sizeof(u8),
>  		.mode           = 0644,
>  		.proc_handler   = proc_dou8vec_minmax,
> +		.min           = 0,
> +		.max           = U8_MAX,
>  	},
>  	{
>  		.procname       = "tcp_plb_cong_thresh",
> diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
> index a95b0351824f..1ba2ff759075 100644
> --- a/net/ipv6/icmp.c
> +++ b/net/ipv6/icmp.c
> @@ -28,6 +28,7 @@
>  #define pr_fmt(fmt) "IPv6: " fmt
>  
>  #include <linux/module.h>
> +#include <linux/limits.h>
>  #include <linux/errno.h>
>  #include <linux/types.h>
>  #include <linux/socket.h>
> @@ -1388,6 +1389,8 @@ static const struct ctl_table ipv6_icmp_table_template[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler = proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "echo_ignore_multicast",
> @@ -1395,6 +1398,8 @@ static const struct ctl_table ipv6_icmp_table_template[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler = proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "echo_ignore_anycast",
> @@ -1402,6 +1407,8 @@ static const struct ctl_table ipv6_icmp_table_template[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler = proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "ratemask",
> diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
> index be72c4346f8b..1f3ba85f6dca 100644
> --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
> +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
> @@ -13,6 +13,7 @@
>  #define pr_fmt(fmt) "IPv6-nf: " fmt
>  
>  #include <linux/errno.h>
> +#include <linux/limits.h>
>  #include <linux/types.h>
>  #include <linux/string.h>
>  #include <linux/net.h>
> @@ -55,12 +56,16 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
>  		.maxlen		= sizeof(unsigned long),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "nf_conntrack_frag6_high_thresh",
>  		.maxlen		= sizeof(unsigned long),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  };
>  
> diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
> index a7964125c764..70c845385744 100644
> --- a/net/ipv6/reassembly.c
> +++ b/net/ipv6/reassembly.c
> @@ -26,6 +26,7 @@
>  #define pr_fmt(fmt) "IPv6: " fmt
>  
>  #include <linux/errno.h>
> +#include <linux/limits.h>
>  #include <linux/types.h>
>  #include <linux/string.h>
>  #include <linux/socket.h>
> @@ -427,12 +428,16 @@ static struct ctl_table ip6_frags_ns_ctl_table[] = {
>  		.maxlen		= sizeof(unsigned long),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "ip6frag_low_thresh",
>  		.maxlen		= sizeof(unsigned long),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "ip6frag_time",
> diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
> index 1a0a36dcdabc..c870a364de60 100644
> --- a/net/ipv6/sysctl_net_ipv6.c
> +++ b/net/ipv6/sysctl_net_ipv6.c
> @@ -7,6 +7,7 @@
>   */
>  
>  #include <linux/mm.h>
> +#include <linux/limits.h>
>  #include <linux/sysctl.h>
>  #include <linux/in6.h>
>  #include <linux/ipv6.h>
> @@ -68,6 +69,8 @@ static const struct ctl_table ipv6_table_template[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "anycast_src_echo_reply",
> @@ -75,6 +78,8 @@ static const struct ctl_table ipv6_table_template[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "flowlabel_consistency",
> @@ -82,6 +87,8 @@ static const struct ctl_table ipv6_table_template[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "auto_flowlabels",
> @@ -97,6 +104,8 @@ static const struct ctl_table ipv6_table_template[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "idgen_retries",
> @@ -118,6 +127,8 @@ static const struct ctl_table ipv6_table_template[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "ip_nonlocal_bind",
> @@ -125,6 +136,8 @@ static const struct ctl_table ipv6_table_template[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	{
>  		.procname	= "flowlabel_reflect",
> diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
> index 63c5747f0f63..e5a5995c5753 100644
> --- a/net/mptcp/ctrl.c
> +++ b/net/mptcp/ctrl.c
> @@ -6,6 +6,7 @@
>  
>  #ifdef CONFIG_SYSCTL
>  #include <linux/sysctl.h>
> +#include <linux/limits.h>
>  #endif
>  
>  #include <net/net_namespace.h>
> @@ -317,6 +318,8 @@ static struct ctl_table mptcp_sysctl_table[] = {
>  		.maxlen = sizeof(unsigned int),
>  		.mode = 0644,
>  		.proc_handler = proc_douintvec_minmax,
> +		.min = 0,
> +		.max = UINT_MAX,
>  	},
>  	{
>  		.procname = "pm_type",
> @@ -356,6 +359,8 @@ static struct ctl_table mptcp_sysctl_table[] = {
>  		.maxlen = sizeof(u8),
>  		.mode = 0644,
>  		.proc_handler = proc_dou8vec_minmax,
> +		.min = 0,
> +		.max = U8_MAX,
>  	},
>  	{
>  		.procname = "path_manager",
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index ce9fe20d6106..6c29a901d139 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -16,6 +16,7 @@
>  #define pr_fmt(fmt) "IPVS: " fmt
>  
>  #include <linux/module.h>
> +#include <linux/limits.h>
>  #include <linux/init.h>
>  #include <linux/types.h>
>  #include <linux/capability.h>
> @@ -2778,6 +2779,8 @@ static struct ctl_table vs_vars[] = {
>  		.maxlen		= sizeof(unsigned long),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "sync_sock_size",
> diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> index d88a10230862..561db3aecada 100644
> --- a/net/netfilter/nf_conntrack_standalone.c
> +++ b/net/netfilter/nf_conntrack_standalone.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #include <linux/types.h>
> +#include <linux/limits.h>
>  #include <linux/netfilter.h>
>  #include <linux/slab.h>
>  #include <linux/module.h>
> @@ -821,6 +822,8 @@ static const struct ctl_table nf_ct_sysctl_table[] = {
>  		.maxlen		= sizeof(u8),
>  		.mode		= 0644,
>  		.proc_handler	= proc_dou8vec_minmax,
> +		.min		= 0,
> +		.max		= U8_MAX,
>  	},
>  	[NF_SYSCTL_CT_PROTO_TIMEOUT_UDP] = {
>  		.procname	= "nf_conntrack_udp_timeout",
> diff --git a/net/rds/ib_sysctl.c b/net/rds/ib_sysctl.c
> index 2af678e71e3c..b7757f31001c 100644
> --- a/net/rds/ib_sysctl.c
> +++ b/net/rds/ib_sysctl.c
> @@ -31,6 +31,7 @@
>   *
>   */
>  #include <linux/kernel.h>
> +#include <linux/limits.h>
>  #include <linux/sysctl.h>
>  #include <linux/proc_fs.h>
>  
> @@ -95,6 +96,8 @@ static struct ctl_table rds_ib_sysctl_table[] = {
>  		.maxlen         = sizeof(unsigned long),
>  		.mode           = 0644,
>  		.proc_handler   = proc_doulongvec_minmax,
> +		.min           = 0,
> +		.max           = ULONG_MAX,
>  	},
>  	{
>  		.procname	= "flow_control",
> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
> index 2b94c211427d..59c6f22337ea 100644
> --- a/net/sctp/sysctl.c
> +++ b/net/sctp/sysctl.c
> @@ -24,6 +24,7 @@
>  #include <net/sctp/structs.h>
>  #include <net/sctp/sctp.h>
>  #include <linux/sysctl.h>
> +#include <linux/limits.h>
>  
>  static int timer_max = 86400000; /* ms in one day */
>  static int sack_timer_min = 1;
> @@ -65,6 +66,8 @@ static struct ctl_table sctp_table[] = {
>  		.maxlen		= sizeof(sysctl_sctp_mem),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  	{
>  		.procname	= "sctp_rmem",
> diff --git a/net/tipc/sysctl.c b/net/tipc/sysctl.c
> index 30d2e06e3d8c..8352c790c8fe 100644
> --- a/net/tipc/sysctl.c
> +++ b/net/tipc/sysctl.c
> @@ -38,6 +38,7 @@
>  #include "crypto.h"
>  #include "bcast.h"
>  #include <linux/sysctl.h>
> +#include <linux/limits.h>
>  
>  static struct ctl_table_header *tipc_ctl_hdr;
>  
> @@ -64,6 +65,8 @@ static struct ctl_table tipc_table[] = {
>  		.maxlen         = sizeof(sysctl_tipc_sk_filter),
>  		.mode           = 0644,
>  		.proc_handler   = proc_doulongvec_minmax,
> +		.min           = 0,
> +		.max           = ULONG_MAX,
>  	},
>  #ifdef CONFIG_TIPC_CRYPTO
>  	{
> @@ -90,6 +93,8 @@ static struct ctl_table tipc_table[] = {
>  		.maxlen		= sizeof(sysctl_tipc_bc_retruni),
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
> +		.min		= 0,
> +		.max		= ULONG_MAX,
>  	},
>  };
>  
> -- 
> 2.25.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

  parent reply	other threads:[~2026-11-07 17:43 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 16:34 [RFC PATCH 00/39] sysctl: replace overloaded extra pointers with typed bounds and context wen.yang
2026-10-28 16:34 ` [RFC PATCH 01/39] " wen.yang
2026-10-28 21:09   ` David Laight
2026-11-07 17:43   ` Joel Granados [this message]
2026-10-28 16:34 ` [RFC PATCH 02/39] test_sysctl: convert bounds to numeric values wen.yang
2026-10-28 16:34 ` [RFC PATCH 03/39] sysctl: add KUnit coverage for numeric bounds and handlers wen.yang
2026-11-04  5:46   ` kernel test robot
2026-10-28 16:34 ` [RFC PATCH 04/39] sysctl: cover runtime ranges and context lifecycles in KUnit wen.yang
2026-10-28 16:34 ` [RFC PATCH 05/39] sysctl: cover priv in KUnit and the debug test module wen.yang
2026-10-28 16:34 ` [RFC PATCH 06/39] sysctl: convert core table bounds to numeric values wen.yang
2026-10-28 16:34 ` [RFC PATCH 07/39] sysctl: store architecture sysctl bounds by value wen.yang
2026-10-28 16:34 ` [RFC PATCH 08/39] sysctl: store crypto " wen.yang
2026-10-28 16:34 ` [RFC PATCH 09/39] sysctl: store device " wen.yang
2026-10-28 16:34 ` [RFC PATCH 10/39] sysctl: store filesystem " wen.yang
2026-10-28 16:34 ` [RFC PATCH 11/39] sysctl: store message-queue " wen.yang
2026-10-28 16:34 ` [RFC PATCH 12/39] sysctl: store kernel " wen.yang
2026-10-28 16:34 ` [RFC PATCH 13/39] sysctl: store memory-management " wen.yang
2026-10-28 16:34 ` [RFC PATCH 14/39] sysctl: store IPv6 scalar " wen.yang
2026-10-28 16:34 ` [RFC PATCH 15/39] sysctl: store netfilter " wen.yang
2026-10-28 16:34 ` [RFC PATCH 16/39] sysctl: store RPC " wen.yang
2026-10-28 16:34 ` [RFC PATCH 17/39] sysctl: store remaining network " wen.yang
2026-10-28 16:34 ` [RFC PATCH 18/39] sysctl: store security " wen.yang
2026-10-28 16:34 ` [RFC PATCH 19/39] io_uring: store its " wen.yang
2026-10-28 16:34 ` [RFC PATCH 20/39] sysctl: refresh dynamic scheduler and PID bounds per call wen.yang
2026-10-28 16:35 ` [RFC PATCH 21/39] sysctl: refresh device-dependent " wen.yang
2026-10-28 16:35 ` [RFC PATCH 22/39] sysctl: refresh namespace IPC " wen.yang
2026-10-28 16:35 ` [RFC PATCH 23/39] yama: preserve scope locking with numeric sysctl bounds wen.yang
2026-10-28 16:35 ` [RFC PATCH 24/39] net: refresh core sysctl limits without bound pointers wen.yang
2026-10-28 16:35 ` [RFC PATCH 25/39] sctp: resolve numeric ranges from the current namespace wen.yang
2026-10-28 16:35 ` [RFC PATCH 26/39] rds: preserve live reconnect limits with numeric bounds wen.yang
2026-10-28 16:35 ` [RFC PATCH 27/39] ipv4: preserve live and vector bounds with numeric sysctls wen.yang
2026-10-28 16:35 ` [RFC PATCH 28/39] net: refresh fragment and remaining dynamic sysctl bounds wen.yang
2026-10-28 16:35 ` [RFC PATCH 29/39] neighbour: derive sysctl ownership independently of bounds wen.yang
2026-10-28 16:35 ` [RFC PATCH 30/39] net: resolve sysctl owners from their backing data wen.yang
2026-10-28 16:35 ` [RFC PATCH 31/39] ipvs: derive sysctl ownership from numeric storage wen.yang
2026-10-28 16:35 ` [RFC PATCH 32/39] sysctl: remove obsolete nr_open bound variables wen.yang
2026-10-28 16:35 ` [RFC PATCH 33/39] ipv6: move address sysctl context to priv wen.yang
2026-10-28 16:35 ` [RFC PATCH 34/39] ipv4: move device " wen.yang
2026-10-28 16:35 ` [RFC PATCH 35/39] netfilter: move logger " wen.yang
2026-10-28 16:35 ` [RFC PATCH 36/39] parport: move device " wen.yang
2026-10-28 16:35 ` [RFC PATCH 37/39] net: move namespace " wen.yang
2026-10-28 16:35 ` [RFC PATCH 38/39] arm64: move vector-length " wen.yang
2026-10-28 16:35 ` [RFC PATCH 39/39] sysctl: remove the extra pointers and the compatibility bounds read wen.yang
2026-11-04  5:17   ` kernel test robot
2026-11-04  5:45   ` kernel test robot
2026-10-29 10:58 ` [RFC PATCH 00/39] sysctl: replace overloaded extra pointers with typed bounds and context David Laight
2026-11-02 15:40   ` Wen Yang
2026-11-02 16:54     ` David Laight
2026-11-04 18:32       ` Wen Yang
2026-11-07 15:27     ` Joel Granados
2026-11-07 17:05       ` David Laight
2026-11-07 21:26 ` Joel Granados

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=au9L9-UqlO90UbSQ@hobbes \
    --to=joel.granados@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wen.yang@linux.dev \
    /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.