summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-02-18 10:45:36 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-02-18 10:45:36 -0800
commit23b0f90ba871f096474e1c27c3d14f455189d2d9 (patch)
tree33d71899714ecc2e0d3aee6ff3f5be7ba34f96c7 /include/linux
parent7ad54bbbc9c512ba3bc90e4368264bcf15c25759 (diff)
parentd174174c6776a340f5c25aab1ac47a2dd950f380 (diff)
Merge tag 'sysctl-7.00-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl
Pull sysctl updates from Joel Granados: - Remove macros from proc handler converters Replace the proc converter macros with "regular" functions. Though it is more verbose than the macro version, it helps when debugging and better aligns with coding-style.rst. - General cleanup Remove superfluous ctl_table forward declarations. Const qualify the memory_allocation_profiling_sysctl and loadpin_sysctl_table arrays. Add missing kernel doc to proc_dointvec_conv. - Testing This series was run through sysctl selftests/kunit test suite in x86_64. And went into linux-next after rc4, giving it a good 3 weeks of testing * tag 'sysctl-7.00-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl: sysctl: replace SYSCTL_INT_CONV_CUSTOM macro with functions sysctl: Replace unidirectional INT converter macros with functions sysctl: Add kernel doc to proc_douintvec_conv sysctl: Replace UINT converter macros with functions sysctl: Add CONFIG_PROC_SYSCTL guards for converter macros sysctl: clarify proc_douintvec_minmax doc sysctl: Return -ENOSYS from proc_douintvec_conv when CONFIG_PROC_SYSCTL=n sysctl: Remove unused ctl_table forward declarations loadpin: Implement custom proc_handler for enforce alloc_tag: move memory_allocation_profiling_sysctls into .rodata sysctl: Add missing kernel-doc for proc_dointvec_conv
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/fs.h1
-rw-r--r--include/linux/hugetlb.h2
-rw-r--r--include/linux/printk.h1
-rw-r--r--include/linux/sysctl.h120
4 files changed, 17 insertions, 107 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a2af5ddd5323..8b3dd145b25e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3525,7 +3525,6 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
ssize_t simple_attr_write_signed(struct file *file, const char __user *buf,
size_t len, loff_t *ppos);
-struct ctl_table;
int __init list_bdev_fs_names(char *buf, size_t size);
#define __FMODE_EXEC ((__force int) FMODE_EXEC)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 94a03591990c..d2e48fa5f72e 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -16,8 +16,6 @@
#include <linux/userfaultfd_k.h>
#include <linux/nodemask.h>
-struct ctl_table;
-struct user_struct;
struct mmu_gather;
struct node;
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 45c663124c9b..63d516c873b4 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -78,7 +78,6 @@ extern void console_verbose(void);
/* strlen("ratelimit") + 1 */
#define DEVKMSG_STR_MAX_SIZE 10
extern char devkmsg_log_str[DEVKMSG_STR_MAX_SIZE];
-struct ctl_table;
extern int suppress_printk;
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 288fe0055cd5..2886fbceb5d6 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -59,7 +59,6 @@ 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_CONV_IDENTITY(val) (val)
/**
*
* "dir" originates from read_iter (dir = 0) or write_iter (dir = 1)
@@ -73,107 +72,6 @@ extern const int sysctl_vals[];
#define SYSCTL_USER_TO_KERN(dir) (!!(dir))
#define SYSCTL_KERN_TO_USER(dir) (!dir)
-#define SYSCTL_USER_TO_KERN_INT_CONV(name, u_ptr_op) \
-int sysctl_user_to_kern_int_conv##name(const bool *negp, \
- const unsigned long *u_ptr,\
- int *k_ptr) \
-{ \
- unsigned long u = u_ptr_op(*u_ptr); \
- if (*negp) { \
- if (u > (unsigned long) INT_MAX + 1) \
- return -EINVAL; \
- WRITE_ONCE(*k_ptr, -u); \
- } else { \
- if (u > (unsigned long) INT_MAX) \
- return -EINVAL; \
- WRITE_ONCE(*k_ptr, u); \
- } \
- return 0; \
-}
-
-#define SYSCTL_KERN_TO_USER_INT_CONV(name, k_ptr_op) \
-int sysctl_kern_to_user_int_conv##name(bool *negp, \
- unsigned long *u_ptr, \
- const int *k_ptr) \
-{ \
- int val = READ_ONCE(*k_ptr); \
- if (val < 0) { \
- *negp = true; \
- *u_ptr = -k_ptr_op((unsigned long)val); \
- } else { \
- *negp = false; \
- *u_ptr = k_ptr_op((unsigned long)val); \
- } \
- return 0; \
-}
-
-/**
- * To range check on a converted value, use a temp k_ptr
- * When checking range, value should be within (tbl->extra1, tbl->extra2)
- */
-#define SYSCTL_INT_CONV_CUSTOM(name, user_to_kern, kern_to_user, \
- k_ptr_range_check) \
-int do_proc_int_conv##name(bool *negp, unsigned long *u_ptr, int *k_ptr,\
- int dir, const struct ctl_table *tbl) \
-{ \
- if (SYSCTL_KERN_TO_USER(dir)) \
- return kern_to_user(negp, u_ptr, k_ptr); \
- \
- if (k_ptr_range_check) { \
- int tmp_k, ret; \
- if (!tbl) \
- return -EINVAL; \
- 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)) \
- return -EINVAL; \
- WRITE_ONCE(*k_ptr, tmp_k); \
- } else \
- return user_to_kern(negp, u_ptr, k_ptr); \
- return 0; \
-}
-
-#define SYSCTL_USER_TO_KERN_UINT_CONV(name, u_ptr_op) \
-int sysctl_user_to_kern_uint_conv##name(const unsigned long *u_ptr,\
- unsigned int *k_ptr) \
-{ \
- unsigned long u = u_ptr_op(*u_ptr); \
- if (u > UINT_MAX) \
- return -EINVAL; \
- WRITE_ONCE(*k_ptr, u); \
- return 0; \
-}
-
-#define SYSCTL_UINT_CONV_CUSTOM(name, user_to_kern, kern_to_user, \
- k_ptr_range_check) \
-int do_proc_uint_conv##name(unsigned long *u_ptr, unsigned int *k_ptr, \
- int dir, const struct ctl_table *tbl) \
-{ \
- if (SYSCTL_KERN_TO_USER(dir)) \
- return kern_to_user(u_ptr, k_ptr); \
- \
- if (k_ptr_range_check) { \
- unsigned int tmp_k; \
- int ret; \
- if (!tbl) \
- return -EINVAL; \
- ret = user_to_kern(u_ptr, &tmp_k); \
- if (ret) \
- return ret; \
- if ((tbl->extra1 && \
- *(unsigned int *)tbl->extra1 > tmp_k) || \
- (tbl->extra2 && \
- *(unsigned int *)tbl->extra2 < tmp_k)) \
- return -ERANGE; \
- WRITE_ONCE(*k_ptr, tmp_k); \
- } else \
- return user_to_kern(u_ptr, k_ptr); \
- return 0; \
-}
-
-
extern const unsigned long sysctl_long_vals[];
typedef int proc_handler(const struct ctl_table *ctl, int write, void *buffer,
@@ -182,6 +80,7 @@ typedef int proc_handler(const struct ctl_table *ctl, int write, void *buffer,
int proc_dostring(const struct ctl_table *, int, void *, size_t *, loff_t *);
int proc_dobool(const struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos);
+
int proc_dointvec(const struct ctl_table *, int, void *, size_t *, loff_t *);
int proc_dointvec_minmax(const struct ctl_table *table, int dir, void *buffer,
size_t *lenp, loff_t *ppos);
@@ -189,6 +88,15 @@ int proc_dointvec_conv(const struct ctl_table *table, int dir, void *buffer,
size_t *lenp, loff_t *ppos,
int (*conv)(bool *negp, unsigned long *u_ptr, int *k_ptr,
int dir, const struct ctl_table *table));
+int proc_int_k2u_conv_kop(ulong *u_ptr, const int *k_ptr, bool *negp,
+ ulong (*k_ptr_op)(const ulong));
+int proc_int_u2k_conv_uop(const ulong *u_ptr, int *k_ptr, const bool *negp,
+ ulong (*u_ptr_op)(const ulong));
+int proc_int_conv(bool *negp, ulong *u_ptr, int *k_ptr, int dir,
+ const struct ctl_table *tbl, bool k_ptr_range_check,
+ int (*user_to_kern)(const bool *negp, const ulong *u_ptr, int *k_ptr),
+ int (*kern_to_user)(bool *negp, ulong *u_ptr, const int *k_ptr));
+
int proc_douintvec(const struct ctl_table *, int, void *, size_t *, loff_t *);
int proc_douintvec_minmax(const struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos);
@@ -196,6 +104,13 @@ int proc_douintvec_conv(const struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos,
int (*conv)(unsigned long *lvalp, unsigned int *valp,
int write, const struct ctl_table *table));
+int proc_uint_k2u_conv(ulong *u_ptr, const uint *k_ptr);
+int proc_uint_u2k_conv_uop(const ulong *u_ptr, uint *k_ptr,
+ ulong (*u_ptr_op)(const ulong));
+int proc_uint_conv(ulong *u_ptr, uint *k_ptr, int dir,
+ const struct ctl_table *tbl, bool k_ptr_range_check,
+ int (*user_to_kern)(const ulong *u_ptr, uint *k_ptr),
+ int (*kern_to_user)(ulong *u_ptr, const uint *k_ptr));
int proc_dou8vec_minmax(const struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos);
@@ -206,7 +121,6 @@ int proc_doulongvec_minmax_conv(const struct ctl_table *table, int dir,
int proc_do_large_bitmap(const struct ctl_table *, int, void *, size_t *, loff_t *);
int proc_do_static_key(const struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos);
-int sysctl_kern_to_user_uint_conv(unsigned long *u_ptr, const unsigned int *k_ptr);
/*
* Register a set of sysctl names by calling register_sysctl