Re: [PATCH v3 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers

2024-04-23 Thread Luis Chamberlain
On Tue, Apr 23, 2024 at 09:54:35AM +0200, Thomas Weißschuh wrote:
> * Patch 1 is a bugfix for the stack_erasing sysctl handler
> * Patches 2-10 change various helper functions throughout the kernel to
>   be able to handle 'const ctl_table'.
> * Patch 11 changes the signatures of all proc handlers through the tree.
>   Some other signatures are also adapted, for details see the commit
>   message.
> 
> Only patch 1 changes any code at all.
> 
> The series was compile-tested on top of next-20230423 for
> i386, x86_64, arm, arm64, riscv, loongarch, s390 and m68k.
> 
> The series was split from my larger series sysctl-const series [0].
> It only focusses on the proc_handlers but is an important step to be
> able to move all static definitions of ctl_table into .rodata.
> 
> [0] 
> https://lore.kernel.org/lkml/20231204-const-sysctl-v2-0-7a5060b11...@weissschuh.net/
> 
> Signed-off-by: Thomas Weißschuh 

Cover letters don't need SOBS we only use them for patches.

But anyway:

Reviewed-by: Luis Chamberlain 

  Luis



[PATCH v3 01/11] stackleak: don't modify ctl_table argument

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers will change to
"const struct ctl_table".
As a preparation for that adapt the logic to work with a temporary
variable, similar to how it is done in other parts of the kernel.

Fixes: 964c9dff0091 ("stackleak: Allow runtime disabling of kernel stack 
erasing")
Acked-by: Kees Cook 
Signed-off-by: Thomas Weißschuh 
---
 kernel/stackleak.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/stackleak.c b/kernel/stackleak.c
index d099f3affcf1..558b9d6d28d3 100644
--- a/kernel/stackleak.c
+++ b/kernel/stackleak.c
@@ -27,10 +27,11 @@ static int stack_erasing_sysctl(struct ctl_table *table, 
int write,
int ret = 0;
int state = !static_branch_unlikely(&stack_erasing_bypass);
int prev_state = state;
+   struct ctl_table tmp = *table;
 
-   table->data = &state;
-   table->maxlen = sizeof(int);
-   ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+   tmp.data = &state;
+   tmp.maxlen = sizeof(int);
+   ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
state = !!state;
if (ret || !write || state == prev_state)
return ret;

-- 
2.44.0




[PATCH v3 04/11] utsname: constify ctl_table arguments of utility function

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 kernel/utsname_sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
index 76a772072557..04e4513f2985 100644
--- a/kernel/utsname_sysctl.c
+++ b/kernel/utsname_sysctl.c
@@ -15,7 +15,7 @@
 
 #ifdef CONFIG_PROC_SYSCTL
 
-static void *get_uts(struct ctl_table *table)
+static void *get_uts(const struct ctl_table *table)
 {
char *which = table->data;
struct uts_namespace *uts_ns;

-- 
2.44.0




[PATCH v3 00/11] sysctl: treewide: constify ctl_table argument of sysctl handlers

2024-04-23 Thread Thomas Weißschuh
* Patch 1 is a bugfix for the stack_erasing sysctl handler
* Patches 2-10 change various helper functions throughout the kernel to
  be able to handle 'const ctl_table'.
* Patch 11 changes the signatures of all proc handlers through the tree.
  Some other signatures are also adapted, for details see the commit
  message.

Only patch 1 changes any code at all.

The series was compile-tested on top of next-20230423 for
i386, x86_64, arm, arm64, riscv, loongarch, s390 and m68k.

The series was split from my larger series sysctl-const series [0].
It only focusses on the proc_handlers but is an important step to be
able to move all static definitions of ctl_table into .rodata.

[0] 
https://lore.kernel.org/lkml/20231204-const-sysctl-v2-0-7a5060b11...@weissschuh.net/

Signed-off-by: Thomas Weißschuh 
---
Changes in v3:
- Rebase on current -next
- Cc affected mailing lists again to gather feedback
- Link to v2: 
https://lore.kernel.org/r/20240323-sysctl-const-handler-v2-0-e80b178f1...@weissschuh.net

Changes in v2:
- Reduce recipient list
- Fix source formatting
- Rebase onto next-20240322
- Link to v1: 
https://lore.kernel.org/r/20240315-sysctl-const-handler-v1-0-1322ac7cb...@weissschuh.net

---
Thomas Weißschuh (11):
  stackleak: don't modify ctl_table argument
  cgroup: bpf: constify ctl_table arguments and fields
  hugetlb: constify ctl_table arguments of utility functions
  utsname: constify ctl_table arguments of utility function
  neighbour: constify ctl_table arguments of utility function
  ipv4/sysctl: constify ctl_table arguments of utility functions
  ipv6/addrconf: constify ctl_table arguments of utility functions
  ipv6/ndisc: constify ctl_table arguments of utility function
  ipvs: constify ctl_table arguments of utility functions
  sysctl: constify ctl_table arguments of utility function
  sysctl: treewide: constify the ctl_table argument of handlers

 arch/arm64/kernel/armv8_deprecated.c  |  2 +-
 arch/arm64/kernel/fpsimd.c|  2 +-
 arch/s390/appldata/appldata_base.c| 10 ++--
 arch/s390/kernel/debug.c  |  2 +-
 arch/s390/kernel/topology.c   |  2 +-
 arch/s390/mm/cmm.c|  6 +--
 arch/x86/kernel/itmt.c|  2 +-
 drivers/cdrom/cdrom.c |  4 +-
 drivers/char/random.c |  6 +--
 drivers/macintosh/mac_hid.c   |  2 +-
 drivers/net/vrf.c |  2 +-
 drivers/parport/procfs.c  | 12 ++---
 drivers/perf/arm_pmuv3.c  |  4 +-
 drivers/perf/riscv_pmu_sbi.c  |  2 +-
 fs/coredump.c |  2 +-
 fs/dcache.c   |  4 +-
 fs/drop_caches.c  |  2 +-
 fs/exec.c |  4 +-
 fs/file_table.c   |  4 +-
 fs/fs-writeback.c |  2 +-
 fs/inode.c|  4 +-
 fs/pipe.c |  2 +-
 fs/quota/dquot.c  |  2 +-
 fs/xfs/xfs_sysctl.c   |  6 +--
 include/linux/filter.h|  2 +-
 include/linux/ftrace.h|  4 +-
 include/linux/mm.h|  8 +--
 include/linux/perf_event.h|  6 +--
 include/linux/security.h  |  2 +-
 include/linux/sysctl.h| 36 ++---
 include/linux/vmstat.h|  6 +--
 include/linux/writeback.h |  2 +-
 include/net/ndisc.h   |  2 +-
 include/net/neighbour.h   |  6 +--
 include/net/netfilter/nf_hooks_lwtunnel.h |  2 +-
 ipc/ipc_sysctl.c  |  8 +--
 kernel/bpf/syscall.c  |  4 +-
 kernel/delayacct.c|  4 +-
 kernel/events/callchain.c |  2 +-
 kernel/events/core.c  |  4 +-
 kernel/fork.c |  2 +-
 kernel/hung_task.c|  6 +--
 kernel/kexec_core.c   |  2 +-
 kernel/kprobes.c  |  2 +-
 kernel/latencytop.c   |  4 +-
 kernel/pid_namespace.c|  2 +-
 kernel/pid_sysctl.h   |  2 +-
 kernel/printk/internal.h  |  2 +-
 kernel/printk/printk.c|  2 +-
 kernel/printk/sysctl.c|  5 +-
 kernel/sched/core.c   |  8 +--
 kernel/sched/rt.c | 16 +++---
 kernel/sched/topology.c   |  2 +-
 kernel/seccomp.c  | 10 ++--
 kernel/stackleak.c|  9 ++--
 kernel/sysctl.c   | 89 ---
 kernel/time/timer.c   |  2 +-
 kernel/trace/ftrace.c |  2 +-
 kernel/trace/trace.c 

[PATCH v3 03/11] hugetlb: constify ctl_table arguments of utility functions

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 mm/hugetlb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 3b7d5ddc32ad..8d12ce63a439 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4911,7 +4911,7 @@ static unsigned int allowed_mems_nr(struct hstate *h)
 }
 
 #ifdef CONFIG_SYSCTL
-static int proc_hugetlb_doulongvec_minmax(struct ctl_table *table, int write,
+static int proc_hugetlb_doulongvec_minmax(const struct ctl_table *table, int 
write,
  void *buffer, size_t *length,
  loff_t *ppos, unsigned long *out)
 {
@@ -4928,7 +4928,7 @@ static int proc_hugetlb_doulongvec_minmax(struct 
ctl_table *table, int write,
 }
 
 static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
-struct ctl_table *table, int write,
+const struct ctl_table *table, int write,
 void *buffer, size_t *length, loff_t *ppos)
 {
struct hstate *h = &default_hstate;

-- 
2.44.0




[PATCH v3 02/11] cgroup: bpf: constify ctl_table arguments and fields

2024-04-23 Thread Thomas Weißschuh
In a future commit the sysctl core will only use
"const struct ctl_table". As a preparation for that adapt the cgroup-bpf
code.

Signed-off-by: Thomas Weißschuh 
---
 include/linux/filter.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/filter.h b/include/linux/filter.h
index 7a27f19bf44d..4eada55a2df8 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1404,7 +1404,7 @@ struct bpf_sock_ops_kern {
 
 struct bpf_sysctl_kern {
struct ctl_table_header *head;
-   struct ctl_table *table;
+   const struct ctl_table *table;
void *cur_val;
size_t cur_len;
void *new_val;

-- 
2.44.0




[PATCH v3 11/11] sysctl: treewide: constify the ctl_table argument of handlers

2024-04-23 Thread Thomas Weißschuh
Adapt the proc_hander function signature to make it clear that handlers
are not supposed to modify their ctl_table argument.

This is a prerequisite to moving the static ctl_table structs into
.rodata.
By migrating all handlers at once a lengthy transition can be avoided.

The patch was mostly generated by coccinelle with the following script:

@@
identifier func, ctl, write, buffer, lenp, ppos;
@@

int func(
- struct ctl_table *ctl,
+ const struct ctl_table *ctl,
  int write, void *buffer, size_t *lenp, loff_t *ppos)
{ ... }

In addition to the scripted changes some other changes are done:

* the typedef proc_handler is adapted

* the prototypes of non-static handler are adapted

* kernel/seccomp.c:{read,write}_actions_logged() and
  kernel/watchdog.c:proc_watchdog_common() are adapted as they need to
  adapted together with the handlers for type-consistency reasons

Signed-off-by: Thomas Weißschuh 
---
 arch/arm64/kernel/armv8_deprecated.c  |  2 +-
 arch/arm64/kernel/fpsimd.c|  2 +-
 arch/s390/appldata/appldata_base.c| 10 ++---
 arch/s390/kernel/debug.c  |  2 +-
 arch/s390/kernel/topology.c   |  2 +-
 arch/s390/mm/cmm.c|  6 +--
 arch/x86/kernel/itmt.c|  2 +-
 drivers/cdrom/cdrom.c |  4 +-
 drivers/char/random.c |  6 +--
 drivers/macintosh/mac_hid.c   |  2 +-
 drivers/net/vrf.c |  2 +-
 drivers/parport/procfs.c  | 12 +++---
 drivers/perf/arm_pmuv3.c  |  4 +-
 drivers/perf/riscv_pmu_sbi.c  |  2 +-
 fs/coredump.c |  2 +-
 fs/dcache.c   |  4 +-
 fs/drop_caches.c  |  2 +-
 fs/exec.c |  4 +-
 fs/file_table.c   |  4 +-
 fs/fs-writeback.c |  2 +-
 fs/inode.c|  4 +-
 fs/pipe.c |  2 +-
 fs/quota/dquot.c  |  2 +-
 fs/xfs/xfs_sysctl.c   |  6 +--
 include/linux/ftrace.h|  4 +-
 include/linux/mm.h|  8 ++--
 include/linux/perf_event.h|  6 +--
 include/linux/security.h  |  2 +-
 include/linux/sysctl.h| 34 
 include/linux/vmstat.h|  6 +--
 include/linux/writeback.h |  2 +-
 include/net/ndisc.h   |  2 +-
 include/net/neighbour.h   |  6 +--
 include/net/netfilter/nf_hooks_lwtunnel.h |  2 +-
 ipc/ipc_sysctl.c  |  8 ++--
 kernel/bpf/syscall.c  |  4 +-
 kernel/delayacct.c|  4 +-
 kernel/events/callchain.c |  2 +-
 kernel/events/core.c  |  4 +-
 kernel/fork.c |  2 +-
 kernel/hung_task.c|  6 +--
 kernel/kexec_core.c   |  2 +-
 kernel/kprobes.c  |  2 +-
 kernel/latencytop.c   |  4 +-
 kernel/pid_namespace.c|  2 +-
 kernel/pid_sysctl.h   |  2 +-
 kernel/printk/internal.h  |  2 +-
 kernel/printk/printk.c|  2 +-
 kernel/printk/sysctl.c|  5 ++-
 kernel/sched/core.c   |  8 ++--
 kernel/sched/rt.c | 16 
 kernel/sched/topology.c   |  2 +-
 kernel/seccomp.c  | 10 ++---
 kernel/stackleak.c|  2 +-
 kernel/sysctl.c   | 68 +++
 kernel/time/timer.c   |  2 +-
 kernel/trace/ftrace.c |  2 +-
 kernel/trace/trace.c  |  2 +-
 kernel/trace/trace_events_user.c  |  2 +-
 kernel/trace/trace_stack.c|  2 +-
 kernel/umh.c  |  2 +-
 kernel/utsname_sysctl.c   |  2 +-
 kernel/watchdog.c | 12 +++---
 mm/compaction.c   |  6 +--
 mm/hugetlb.c  |  8 ++--
 mm/page-writeback.c   | 18 
 mm/page_alloc.c   | 14 +++
 mm/util.c | 12 +++---
 mm/vmstat.c   |  4 +-
 net/bridge/br_netfilter_hooks.c   |  2 +-
 net/core/neighbour.c  | 18 
 net/core/sysctl_net_core.c| 20 -
 net/ipv4/devinet.c|  6 +--
 net/ipv4/route.c  |  2 +-
 net/ipv4/sysctl_net_ipv4.c| 32 +++
 net/ipv6/addrconf.c   | 19 +
 net/ipv6/ndisc.c  |

[PATCH v3 10/11] sysctl: constify ctl_table arguments of utility function

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 include/linux/sysctl.h |  2 +-
 kernel/sysctl.c| 21 +++--
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 09db2f2e6488..54fbec062772 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -237,7 +237,7 @@ extern struct ctl_table_header 
*register_sysctl_mount_point(const char *path);
 
 void do_sysctl_args(void);
 bool sysctl_is_alias(char *param);
-int do_proc_douintvec(struct ctl_table *table, int write,
+int do_proc_douintvec(const struct ctl_table *table, int write,
  void *buffer, size_t *lenp, loff_t *ppos,
  int (*conv)(unsigned long *lvalp,
  unsigned int *valp,
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index e0b917328cf9..62dd27752960 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -205,7 +205,7 @@ static int _proc_do_string(char *data, int maxlen, int 
write,
return 0;
 }
 
-static void warn_sysctl_write(struct ctl_table *table)
+static void warn_sysctl_write(const struct ctl_table *table)
 {
pr_warn_once("%s wrote to %s when file position was not 0!\n"
"This will not be supported in the future. To silence this\n"
@@ -223,7 +223,7 @@ static void warn_sysctl_write(struct ctl_table *table)
  * handlers can ignore the return value.
  */
 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
-  struct ctl_table *table)
+  const struct ctl_table *table)
 {
if (!*ppos)
return false;
@@ -468,7 +468,7 @@ static int do_proc_douintvec_conv(unsigned long *lvalp,
 
 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
 
-static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
+static int __do_proc_dointvec(void *tbl_data, const struct ctl_table *table,
  int write, void *buffer,
  size_t *lenp, loff_t *ppos,
  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
@@ -541,7 +541,7 @@ static int __do_proc_dointvec(void *tbl_data, struct 
ctl_table *table,
return err;
 }
 
-static int do_proc_dointvec(struct ctl_table *table, int write,
+static int do_proc_dointvec(const struct ctl_table *table, int write,
  void *buffer, size_t *lenp, loff_t *ppos,
  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
  int write, void *data),
@@ -552,7 +552,7 @@ static int do_proc_dointvec(struct ctl_table *table, int 
write,
 }
 
 static int do_proc_douintvec_w(unsigned int *tbl_data,
-  struct ctl_table *table,
+  const struct ctl_table *table,
   void *buffer,
   size_t *lenp, loff_t *ppos,
   int (*conv)(unsigned long *lvalp,
@@ -639,7 +639,7 @@ static int do_proc_douintvec_r(unsigned int *tbl_data, void 
*buffer,
return err;
 }
 
-static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
+static int __do_proc_douintvec(void *tbl_data, const struct ctl_table *table,
   int write, void *buffer,
   size_t *lenp, loff_t *ppos,
   int (*conv)(unsigned long *lvalp,
@@ -675,7 +675,7 @@ static int __do_proc_douintvec(void *tbl_data, struct 
ctl_table *table,
return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
 }
 
-int do_proc_douintvec(struct ctl_table *table, int write,
+int do_proc_douintvec(const struct ctl_table *table, int write,
  void *buffer, size_t *lenp, loff_t *ppos,
  int (*conv)(unsigned long *lvalp,
  unsigned int *valp,
@@ -1023,8 +1023,9 @@ static int sysrq_sysctl_handler(struct ctl_table *table, 
int write,
 }
 #endif
 
-static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
-   int write, void *buffer, size_t *lenp, loff_t *ppos,
+static int __do_proc_doulongvec_minmax(void *data,
+   const struct ctl_table *table, int write,
+   void *buffer, size_t *lenp, loff_t *ppos,
unsigned long convmul, unsigned long convdiv)
 {
unsigned long *i, *min, *max;
@@ -1096,7 +1097,7 @@ static int __do_proc_doulongvec_minmax(void *data, struct 
ctl_table *table,
return err;
 }
 
-static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
+static int do_proc_doulongvec_minmax(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
unsigned long convdiv)
 {

-- 
2.44.0



[PATCH v3 07/11] ipv6/addrconf: constify ctl_table arguments of utility functions

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 net/ipv6/addrconf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 9aa0900abfa1..96ab349e8ba4 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -863,7 +863,7 @@ static void addrconf_forward_change(struct net *net, __s32 
newf)
}
 }
 
-static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int newf)
+static int addrconf_fixup_forwarding(const struct ctl_table *table, int *p, 
int newf)
 {
struct net *net;
int old;
@@ -931,7 +931,7 @@ static void addrconf_linkdown_change(struct net *net, __s32 
newf)
}
 }
 
-static int addrconf_fixup_linkdown(struct ctl_table *table, int *p, int newf)
+static int addrconf_fixup_linkdown(const struct ctl_table *table, int *p, int 
newf)
 {
struct net *net;
int old;
@@ -6378,7 +6378,7 @@ static void addrconf_disable_change(struct net *net, 
__s32 newf)
}
 }
 
-static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int newf)
+static int addrconf_disable_ipv6(const struct ctl_table *table, int *p, int 
newf)
 {
struct net *net = (struct net *)table->extra2;
int old;
@@ -6669,7 +6669,7 @@ void addrconf_disable_policy_idev(struct inet6_dev *idev, 
int val)
 }
 
 static
-int addrconf_disable_policy(struct ctl_table *ctl, int *valp, int val)
+int addrconf_disable_policy(const struct ctl_table *ctl, int *valp, int val)
 {
struct net *net = (struct net *)ctl->extra2;
struct inet6_dev *idev;

-- 
2.44.0




[PATCH v3 08/11] ipv6/ndisc: constify ctl_table arguments of utility function

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 net/ipv6/ndisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index ae134634c323..945d5f5ca039 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1936,7 +1936,7 @@ static struct notifier_block ndisc_netdev_notifier = {
 };
 
 #ifdef CONFIG_SYSCTL
-static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
+static void ndisc_warn_deprecated_sysctl(const struct ctl_table *ctl,
 const char *func, const char *dev_name)
 {
static char warncomm[TASK_COMM_LEN];

-- 
2.44.0




[PATCH v3 09/11] ipvs: constify ctl_table arguments of utility functions

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 net/netfilter/ipvs/ip_vs_ctl.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 143a341bbc0a..689ac521ea2d 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -1924,7 +1924,8 @@ proc_do_sync_ports(struct ctl_table *table, int write,
return rc;
 }
 
-static int ipvs_proc_est_cpumask_set(struct ctl_table *table, void *buffer)
+static int ipvs_proc_est_cpumask_set(const struct ctl_table *table,
+void *buffer)
 {
struct netns_ipvs *ipvs = table->extra2;
cpumask_var_t *valp = table->data;
@@ -1962,8 +1963,8 @@ static int ipvs_proc_est_cpumask_set(struct ctl_table 
*table, void *buffer)
return ret;
 }
 
-static int ipvs_proc_est_cpumask_get(struct ctl_table *table, void *buffer,
-size_t size)
+static int ipvs_proc_est_cpumask_get(const struct ctl_table *table,
+void *buffer, size_t size)
 {
struct netns_ipvs *ipvs = table->extra2;
cpumask_var_t *valp = table->data;

-- 
2.44.0




[PATCH v3 06/11] ipv4/sysctl: constify ctl_table arguments of utility functions

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helpers.

Signed-off-by: Thomas Weißschuh 
---
 net/ipv4/sysctl_net_ipv4.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index ce5d19978a26..fc4c001bf72a 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -130,7 +130,8 @@ static int ipv4_privileged_ports(struct ctl_table *table, 
int write,
return ret;
 }
 
-static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t 
*low, kgid_t *high)
+static void inet_get_ping_group_range_table(const struct ctl_table *table,
+   kgid_t *low, kgid_t *high)
 {
kgid_t *data = table->data;
struct net *net =
@@ -145,7 +146,8 @@ static void inet_get_ping_group_range_table(struct 
ctl_table *table, kgid_t *low
 }
 
 /* Update system visible IP port range */
-static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t 
high)
+static void set_ping_group_range(const struct ctl_table *table,
+kgid_t low, kgid_t high)
 {
kgid_t *data = table->data;
struct net *net =

-- 
2.44.0




[PATCH v3 05/11] neighbour: constify ctl_table arguments of utility function

2024-04-23 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to
"const struct ctl_table". As a preparation for that adapt the internal
helper.

Signed-off-by: Thomas Weißschuh 
---
 net/core/neighbour.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 0805c00c63d4..92a01664a723 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -3578,7 +3578,7 @@ static void neigh_copy_dflt_parms(struct net *net, struct 
neigh_parms *p,
rcu_read_unlock();
 }
 
-static void neigh_proc_update(struct ctl_table *ctl, int write)
+static void neigh_proc_update(const struct ctl_table *ctl, int write)
 {
struct net_device *dev = ctl->extra1;
struct neigh_parms *p = ctl->extra2;

-- 
2.44.0