[RFC PATCH v1 02/30] sysctl: add unsigned int limit constants
From: Alexey Gladkov
Date: Wed Aug 26 2026 - 15:45:55 EST
Some sysctl handlers use unsigned int storage for their limit arguments.
In particular, proc_dou8vec_minmax() expects extra1 and extra2 to point
to unsigned int values even though the controlled data is an u8.
Provide shared unsigned int constants so typed sysctl descriptors can
pass correctly typed min and max pointers without casting the existing
int constants.
Signed-off-by: Alexey Gladkov <legion@xxxxxxxxxx>
---
include/linux/sysctl.h | 7 +++++++
kernel/sysctl.c | 3 +++
2 files changed, 10 insertions(+)
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 2886fbceb5d6..8d993ba1488b 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -59,6 +59,12 @@ extern const int sysctl_vals[];
#define SYSCTL_LONG_ONE ((void *)&sysctl_long_vals[1])
#define SYSCTL_LONG_MAX ((void *)&sysctl_long_vals[2])
+#define SYSCTL_UINT_ZERO ((unsigned int *)&sysctl_uint_vals[0])
+#define SYSCTL_UINT_ONE ((unsigned int *)&sysctl_uint_vals[1])
+#define SYSCTL_UINT_TWO ((unsigned int *)&sysctl_uint_vals[2])
+#define SYSCTL_UINT_THREE ((unsigned int *)&sysctl_uint_vals[3])
+#define SYSCTL_UINT_FOUR ((unsigned int *)&sysctl_uint_vals[4])
+
/**
*
* "dir" originates from read_iter (dir = 0) or write_iter (dir = 1)
@@ -73,6 +79,7 @@ extern const int sysctl_vals[];
#define SYSCTL_KERN_TO_USER(dir) (!dir)
extern const unsigned long sysctl_long_vals[];
+extern const unsigned int sysctl_uint_vals[];
typedef int proc_handler(const struct ctl_table *ctl, int write, void *buffer,
size_t *lenp, loff_t *ppos);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index c9efb17cc255..d1b5284141c4 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -29,6 +29,9 @@ EXPORT_SYMBOL(sysctl_vals);
const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
EXPORT_SYMBOL_GPL(sysctl_long_vals);
+const unsigned int sysctl_uint_vals[] = { 0, 1, 2, 3, 4 };
+EXPORT_SYMBOL_GPL(sysctl_uint_vals);
+
#if defined(CONFIG_SYSCTL)
/* Constants used for minimum and maximum */
--
2.55.0