sysctl: constify sysctl ctl_tables
Subsystems (54)
v2 cover sysctl: constify sysctl ctl_tables
Problem description:
The kernel contains a lot of struct ctl_table throught the tree. These are very often 'static' definitions.
It would be good to make the tables unmodifiable by marking them "const" to avoid accidental or malicious modifications.
This is in line with a general effort to move as much data as possible into .rodata. (See for example[0] and [1])
Unfortunately the tables can not be made const right now because the core registration functions expect mutable tables.
This is for two main reasons:
1) sysctl_{set,clear}_perm_empty_ctl_header in the sysctl core modify the table.
2) The table is passed to the handler function as a non-const pointer.
This series migrates the core and all handlers.
Structure of the series:
Patch 1-3: Cleanup patches Patch 4-7: Non-logic preparation patches Patch 8: Preparation patch changing a bit of logic Patch 9-12: Treewide changes to handler function signature Patch 13-14: Adaption of the sysctl core implementation Patch 15: Adaption of the sysctl core interface Patch 16: New entry for checkpatch Patch 17-18: Constification of existing "struct ctl_table"s
Tested by booting and with the sysctl selftests on x86.
Note:
This is intentionally sent only to a small number of people as I'd like to get some more sysctl core-maintainer feedback before sending this to essentially everybody.
[0] 43a7206b0963 ("driver core: class: make class_register() take a const *")
[1] https://lore.kernel.org/lkml/[email protected]/
---
Changes in v2:
- Migrate all handlers.
- Remove intermediate "proc_handler_new" step (Thanks Joel).
- Drop RFC status.
- Prepare other parts of the tree.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Thomas Weißschuh (18):
watchdog/core: remove sysctl handlers from public header
sysctl: delete unused define SYSCTL_PERM_EMPTY_DIR
sysctl: drop sysctl_is_perm_empty_ctl_table
cgroup: bpf: constify ctl_table arguments and fields
seccomp: constify ctl_table arguments of utility functions
hugetlb: constify ctl_table arguments of utility functions
utsname: constify ctl_table arguments of utility function
stackleak: don't modify ctl_table argument
sysctl: treewide: constify ctl_table_root::set_ownership
sysctl: treewide: constify ctl_table_root::permissions
sysctl: treewide: constify ctl_table_header::ctl_table_arg
sysctl: treewide: constify the ctl_table argument of handlers
sysctl: move sysctl type to ctl_table_header
sysctl: move internal interfaces to const struct ctl_table
sysctl: allow registration of const struct ctl_table const_structs.checkpatch: add ctl_table
sysctl: make ctl_table sysctl_mount_point const
sysctl: constify standard sysctl tables
arch/arm64/kernel/armv8_deprecated.c | 2 +- arch/arm64/kernel/fpsimd.c | 2 +- arch/s390/appldata/appldata_base.c | 8 +-- 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 | 4 +- drivers/macintosh/mac_hid.c | 2 +- drivers/net/vrf.c | 4 +- drivers/parport/procfs.c | 12 ++-- fs/coredump.c | 2 +- fs/dcache.c | 4 +- fs/drop_caches.c | 2 +- fs/exec.c | 4 +- fs/file_table.c | 2 +- fs/fs-writeback.c | 2 +- fs/inode.c | 4 +- fs/pipe.c | 2 +- fs/proc/internal.h | 2 +- fs/proc/proc_sysctl.c | 102 +++++++++++++++--------------- fs/quota/dquot.c | 2 +- fs/xfs/xfs_sysctl.c | 6 +- include/linux/bpf-cgroup.h | 2 +- include/linux/filter.h | 2 +- include/linux/ftrace.h | 4 +- include/linux/mm.h | 8 +-- include/linux/nmi.h | 7 -- include/linux/perf_event.h | 6 +- include/linux/security.h | 2 +- include/linux/sysctl.h | 78 +++++++++++------------ 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 | 12 ++-- ipc/mq_sysctl.c | 2 +- kernel/bpf/cgroup.c | 2 +- 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 | 4 +- 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 | 12 ++-- kernel/sched/topology.c | 2 +- kernel/seccomp.c | 8 +-- kernel/stackleak.c | 9 +-- kernel/sysctl.c | 84 ++++++++++++------------ 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/ucount.c | 4 +- kernel/umh.c | 2 +- kernel/utsname_sysctl.c | 4 +- kernel/watchdog.c | 15 +++-- mm/compaction.c | 8 +-- mm/hugetlb.c | 10 +-- mm/page-writeback.c | 18 +++--- mm/page_alloc.c | 22 +++---- mm/util.c | 12 ++-- mm/vmstat.c | 4 +- net/ax25/sysctl_net_ax25.c | 2 +- net/bridge/br_netfilter_hooks.c | 6 +- net/core/neighbour.c | 24 +++---- net/core/sysctl_net_core.c | 22 +++---- net/ieee802154/6lowpan/reassembly.c | 2 +- net/ipv4/devinet.c | 8 +-- net/ipv4/ip_fragment.c | 2 +- net/ipv4/route.c | 4 +- net/ipv4/sysctl_net_ipv4.c | 35 +++++----- net/ipv4/xfrm4_policy.c | 2 +- net/ipv6/addrconf.c | 29 +++++---- net/ipv6/ndisc.c | 4 +- net/ipv6/netfilter/nf_conntrack_reasm.c | 2 +- net/ipv6/reassembly.c | 2 +- net/ipv6/route.c | 2 +- net/ipv6/sysctl_net_ipv6.c | 10 +-- net/ipv6/xfrm6_policy.c | 2 +- net/mpls/af_mpls.c | 8 +-- net/mptcp/ctrl.c | 2 +- net/netfilter/ipvs/ip_vs_ctl.c | 16 ++--- net/netfilter/nf_conntrack_standalone.c | 4 +- net/netfilter/nf_hooks_lwtunnel.c | 2 +- net/netfilter/nf_log.c | 4 +- net/phonet/sysctl.c | 2 +- net/rds/tcp.c | 4 +- net/sctp/sysctl.c | 30 ++++----- net/smc/smc_sysctl.c | 2 +- net/sunrpc/sysctl.c | 6 +- net/sunrpc/xprtrdma/svc_rdma.c | 2 +- net/sysctl_net.c | 4 +- net/unix/sysctl_net_unix.c | 2 +- net/xfrm/xfrm_sysctl.c | 2 +- scripts/const_structs.checkpatch | 1 + security/apparmor/lsm.c | 2 +- security/min_addr.c | 2 +- security/yama/yama_lsm.c | 2 +- 111 files changed, 427 insertions(+), 428 deletions(-)
---
base-commit: 33cc938e65a98f1d29d0a18403dbbee050dcad9a
change-id: 20231116-const-sysctl-e14624f1295c
Best regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
PATCH v2 1/18 watchdog/core: remove sysctl handlers from public header
The functions are only used in the file where they are defined. Remove them from the header and make them static.
--- include/linux/nmi.h | 7 ------- kernel/watchdog.c | 10 +++++----- 2 files changed, 5 insertions(+), 12 deletions(-)
include/linux/nmi.h +0 -7
@@ -216,13 +216,6 @@ void watchdog_update_hrtimer_threshold(u64 period);static inline void watchdog_update_hrtimer_threshold (u64 period) { }#endif -struct ctl_table ; -int proc_watchdog (struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_nmi_watchdog (struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_soft_watchdog (struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_watchdog_thresh (struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_watchdog_cpumask (struct ctl_table *,int ,void *,size_t *,loff_t *); -#ifdef CONFIG_HAVE_ACPI_APEI_NMI #include <asm/nmi.h> #endif
kernel/watchdog.c +5 -5
@@ -772,7 +772,7 @@ static int proc_watchdog_common(int which, struct ctl_table *table, int write,/* * /proc/sys/kernel/watchdog */ -int proc_watchdog (struct ctl_table *table,int write, +static int proc_watchdog (struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { return proc_watchdog_common(WATCHDOG_HARDLOCKUP_ENABLED |
@@ -783,7 +783,7 @@ int proc_watchdog(struct ctl_table *table, int write,/* * /proc/sys/kernel/nmi_watchdog */ -int proc_nmi_watchdog (struct ctl_table *table,int write, +static int proc_nmi_watchdog (struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {if (!watchdog_hardlockup_available && write)
@@ -795,7 +795,7 @@ int proc_nmi_watchdog(struct ctl_table *table, int write,/* * /proc/sys/kernel/soft_watchdog */ -int proc_soft_watchdog (struct ctl_table *table,int write, +static int proc_soft_watchdog (struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { return proc_watchdog_common(WATCHDOG_SOFTOCKUP_ENABLED,
@@ -805,7 +805,7 @@ int proc_soft_watchdog(struct ctl_table *table, int write,/* * /proc/sys/kernel/watchdog_thresh */ -int proc_watchdog_thresh (struct ctl_table *table,int write, +static int proc_watchdog_thresh (struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int err, old;
@@ -828,7 +828,7 @@ int proc_watchdog_thresh(struct ctl_table *table, int write,* user to specify a mask that will include cpus that have not yet * been brought online, if desired. */ -int proc_watchdog_cpumask (struct ctl_table *table,int write, +static int proc_watchdog_cpumask (struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int err;
Signature · 1 line
2.43.0
PATCH v2 2/18 sysctl: delete unused define SYSCTL_PERM_EMPTY_DIR
In reply to Thomas WeißschuhIt seems it was never used.
--- include/linux/sysctl.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/sysctl.h +0 -2
@@ -255,8 +255,6 @@ extern int unaligned_enabled;extern int unaligned_dump_stack;extern int no_unaligned_warning; -#define SYSCTL_PERM_EMPTY_DIR (1 << 0) -#else /* CONFIG_SYSCTL */ static inline void register_sysctl_init (const char *path,struct ctl_table *table)
Signature · 1 line
2.43.0
PATCH v2 3/18 sysctl: drop sysctl_is_perm_empty_ctl_table
In reply to Thomas WeißschuhIt is used only once and that caller would be simpler with sysctl_is_perm_empty_ctl_header().
So use this sibling function.
--- fs/proc/proc_sysctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/proc/proc_sysctl.c +2 -4
@@ -48,10 +48,8 @@ struct ctl_table_header *register_sysctl_mount_point(const char *path) }EXPORT_SYMBOL (register_sysctl_mount_point); -#define sysctl_is_perm_empty_ctl_table (tptr) \ - (tptr[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY)#define sysctl_is_perm_empty_ctl_header (hptr) \ - (sysctl_is_perm_empty_ctl_table(hptr->ctl_table)) + (hptr->ctl_table[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY)#define sysctl_set_perm_empty_ctl_header (hptr) \ (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY)#define sysctl_clear_perm_empty_ctl_header (hptr) \
@@ -233,7 +231,7 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)return -EROFS ;/* Am I creating a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_table (header->ctl_table)) { +if (sysctl_is_perm_empty_ctl_header (header)) {if (!RB_EMPTY_ROOT (&dir->root))return -EINVAL ;sysctl_set_perm_empty_ctl_header (dir_h);
Signature · 1 line
2.43.0
Re: [PATCH v2 03/18] sysctl: drop sysctl_is_perm_empty_ctl_table
If you are separating the work for permanently empty directories, you can add this patch to that set. as well as 2/18
Best
Quoted 38 lines · Thomas Weißschuh
It is used only once and that caller would be simpler with
sysctl_is_perm_empty_ctl_header().
So use this sibling function.Signed-off-by Thomas Weißschuh <[email protected]>--- fs/proc/proc_sysctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/proc/proc_sysctl.c +2
-4@@ -48,10 +48,8 @@ struct ctl_table_header *register_sysctl_mount_point(const char *path) }EXPORT_SYMBOL (register_sysctl_mount_point); -#define sysctl_is_perm_empty_ctl_table (tptr) \ - (tptr[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY)#define sysctl_is_perm_empty_ctl_header (hptr) \ - (sysctl_is_perm_empty_ctl_table(hptr->ctl_table)) + (hptr->ctl_table[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY)#define sysctl_set_perm_empty_ctl_header (hptr) \ (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY)#define sysctl_clear_perm_empty_ctl_header (hptr) \@@ -233,7 +231,7 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)return -EROFS ;/* Am I creating a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_table (header->ctl_table)) { +if (sysctl_is_perm_empty_ctl_header (header)) {if (!RB_EMPTY_ROOT (&dir->root))return -EINVAL ;sysctl_set_perm_empty_ctl_header (dir_h);Signature · 2 lines
-- 2.43.0
Signature · 1 line
Joel Granados
PATCH v2 4/18 cgroup: bpf: constify ctl_table arguments and fields
In reply to Thomas WeißschuhIn a future commit the sysctl core will only use
"const struct ctl_table". As a preparation for that adapt the cgroup-bpf code.
--- include/linux/bpf-cgroup.h | 2 +- include/linux/filter.h | 2 +- kernel/bpf/cgroup.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
include/linux/bpf-cgroup.h +1 -1
@@ -138,7 +138,7 @@ int __cgroup_bpf_check_dev_permission(short dev_type, u32 major, u32 minor, short access, enum cgroup_bpf_attach_type atype);int __cgroup_bpf_run_filter_sysctl (struct ctl_table_header *head, -struct ctl_table *table,int write, +const struct ctl_table *table,int write,char **buf,size_t *pcount,loff_t *ppos,enum cgroup_bpf_attach_type atype);
include/linux/filter.h +1 -1
@@ -1358,7 +1358,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;
kernel/bpf/cgroup.c +1 -1
@@ -1694,7 +1694,7 @@ const struct bpf_verifier_ops cg_dev_verifier_ops = {* returned value != 1 during execution. In all other cases 0 is returned. */ int __cgroup_bpf_run_filter_sysctl (struct ctl_table_header *head, -struct ctl_table *table,int write, +const struct ctl_table *table,int write,char **buf,size_t *pcount,loff_t *ppos,enum cgroup_bpf_attach_type atype) {
Signature · 1 line
2.43.0
PATCH v2 5/18 seccomp: constify ctl_table arguments of utility functions
In reply to Thomas WeißschuhIn a future commit the proc_handlers themselves will change to "const struct ctl_table". As a preparation for that adapt the internal helpers.
--- kernel/seccomp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/seccomp.c +2 -2
@@ -2334,7 +2334,7 @@ static bool seccomp_actions_logged_from_names(u32 *actions_logged, char *names)return true; } -static int read_actions_logged (struct ctl_table *ro_table,void *buffer, +static int read_actions_logged (const struct ctl_table *ro_table,void *buffer,size_t *lenp,loff_t *ppos) {char names[sizeof (seccomp_actions_avail)];
@@ -2352,7 +2352,7 @@ static int read_actions_logged(struct ctl_table *ro_table, void *buffer,return proc_dostring (&table,0 , buffer, lenp, ppos); } -static int write_actions_logged (struct ctl_table *ro_table,void *buffer, +static int write_actions_logged (const struct ctl_table *ro_table,void *buffer,size_t *lenp,loff_t *ppos,u32 *actions_logged) {char names[sizeof (seccomp_actions_avail)];
Signature · 1 line
2.43.0
Re: [PATCH v2 05/18] seccomp: constify ctl_table arguments of utility functions
Quoted 5 lines · Thomas Weißschuh
In a future commit the
proc_handlersthemselves will change to "const structctl_table". As a preparation for that adapt the internal helpers.Signed-off-by Thomas Weißschuh <[email protected]>
Signature · 1 line
Kees Cook
PATCH v2 6/18 hugetlb: constify ctl_table arguments of utility functions
In reply to Thomas WeißschuhIn a future commit the proc_handlers themselves will change to "const struct ctl_table". As a preparation for that adapt the internal helpers.
--- mm/hugetlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/hugetlb.c +2 -2
@@ -4835,7 +4835,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) {
@@ -4852,7 +4852,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;
Signature · 1 line
2.43.0
PATCH v2 7/18 utsname: constify ctl_table arguments of utility function
In reply to Thomas WeißschuhIn a future commit the proc_handlers themselves will change to "const struct ctl_table". As a preparation for that adapt the internal helper.
--- kernel/utsname_sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/utsname_sysctl.c +1 -1
@@ -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;
Signature · 1 line
2.43.0
PATCH v2 8/18 stackleak: don't modify ctl_table argument
In reply to Thomas WeißschuhIn 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.
--- kernel/stackleak.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/stackleak.c +4 -3
@@ -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;
Signature · 1 line
2.43.0
Re: [PATCH v2 08/18] stackleak: don't modify ctl_table argument
Quoted 6 lines · Thomas Weißschuh
In a future commit the
proc_handlerswill change to "const structctl_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.Signed-off-by Thomas Weißschuh <[email protected]>
Looks good -- thanks for catching the table-modification cases.
Signature · 1 line
Kees Cook
PATCH v2 9/18 sysctl: treewide: constify ctl_table_root::set_ownership
In reply to Thomas WeißschuhIn a future commit the sysctl core will only use "const struct ctl_table". As a preparation for that adapt the set_ownership callbacks.
--- include/linux/sysctl.h | 2 +- net/sysctl_net.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/sysctl.h +1 -1
@@ -205,7 +205,7 @@ struct ctl_table_root {struct ctl_table_set default_set;struct ctl_table_set *(*lookup)(struct ctl_table_root *root);void (*set_ownership)(struct ctl_table_header *head, -struct ctl_table *table, +const struct ctl_table *table,kuid_t *uid,kgid_t *gid);int (*permissions)(struct ctl_table_header *head,struct ctl_table *table); };
net/sysctl_net.c +1 -1
@@ -54,7 +54,7 @@ static int net_ctl_permissions(struct ctl_table_header *head, }static void net_ctl_set_ownership (struct ctl_table_header *head, -struct ctl_table *table, +const struct ctl_table *table,kuid_t *uid,kgid_t *gid) { struct net *net = container_of(head->set, struct net, sysctls);
Signature · 1 line
2.43.0
PATCH v2 10/18 sysctl: treewide: constify ctl_table_root::permissions
In reply to Thomas WeißschuhIn a future commit the sysctl core will only use "const struct ctl_table". As a preparation for that adapt the permission callbacks.
--- include/linux/sysctl.h | 2 +- ipc/ipc_sysctl.c | 2 +- kernel/ucount.c | 2 +- net/sysctl_net.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
include/linux/sysctl.h +1 -1
@@ -207,7 +207,7 @@ struct ctl_table_root {void (*set_ownership)(struct ctl_table_header *head,const struct ctl_table *table,kuid_t *uid,kgid_t *gid); -int (*permissions)(struct ctl_table_header *head,struct ctl_table *table); +int (*permissions)(struct ctl_table_header *head,const struct ctl_table *table); };/* struct ctl_path describes where in the hierarchy a table is added */
ipc/ipc_sysctl.c +1 -1
@@ -190,7 +190,7 @@ static int set_is_seen(struct ctl_table_set *set)return ¤t->nsproxy->ipc_ns->ipc_set == set; } -static int ipc_permissions (struct ctl_table_header *head,struct ctl_table *table) +static int ipc_permissions (struct ctl_table_header *head,const struct ctl_table *table) {int mode = table->mode;
kernel/ucount.c +1 -1
@@ -38,7 +38,7 @@ static int set_is_seen(struct ctl_table_set *set) }static int set_permissions (struct ctl_table_header *head, -struct ctl_table *table) +const struct ctl_table *table) {struct user_namespace *user_ns = container_of(head->set, struct user_namespace, set);
net/sysctl_net.c +1 -1
@@ -40,7 +40,7 @@ static int is_seen(struct ctl_table_set *set)/* Return standard mode bits for table entry. */ static int net_ctl_permissions (struct ctl_table_header *head, -struct ctl_table *table) +const struct ctl_table *table) { struct net *net = container_of(head->set, struct net, sysctls);
Signature · 1 line
2.43.0
PATCH v2 11/18 sysctl: treewide: constify ctl_table_header::ctl_table_arg
In reply to Thomas WeißschuhIn a future commit the sysctl core will only use "const struct ctl_table". As a preparation for that adapt the ctl_table_arg member.
--- drivers/net/vrf.c | 2 +- include/linux/sysctl.h | 2 +- ipc/ipc_sysctl.c | 2 +- ipc/mq_sysctl.c | 2 +- kernel/ucount.c | 2 +- net/ax25/sysctl_net_ax25.c | 2 +- net/bridge/br_netfilter_hooks.c | 4 +++- net/core/sysctl_net_core.c | 2 +- net/ieee802154/6lowpan/reassembly.c | 2 +- net/ipv4/devinet.c | 2 +- net/ipv4/ip_fragment.c | 2 +- net/ipv4/route.c | 2 +- net/ipv4/sysctl_net_ipv4.c | 2 +- net/ipv4/xfrm4_policy.c | 2 +- net/ipv6/addrconf.c | 2 +- net/ipv6/netfilter/nf_conntrack_reasm.c | 2 +- net/ipv6/reassembly.c | 2 +- net/ipv6/sysctl_net_ipv6.c | 6 +++--- net/ipv6/xfrm6_policy.c | 2 +- net/mpls/af_mpls.c | 4 ++-- net/mptcp/ctrl.c | 2 +- net/netfilter/nf_conntrack_standalone.c | 2 +- net/netfilter/nf_log.c | 2 +- net/sctp/sysctl.c | 2 +- net/smc/smc_sysctl.c | 2 +- net/unix/sysctl_net_unix.c | 2 +- net/xfrm/xfrm_sysctl.c | 2 +- 27 files changed, 32 insertions(+), 30 deletions(-)
drivers/net/vrf.c +1 -1
@@ -1971,7 +1971,7 @@ static int vrf_netns_init_sysctl(struct net *net, struct netns_vrf *nn_vrf)static void vrf_netns_exit_sysctl (struct net *net) {struct netns_vrf *nn_vrf =net_generic (net, vrf_net_id); -struct ctl_table *table; +const struct ctl_table *table; table = nn_vrf->ctl_hdr->ctl_table_arg;unregister_net_sysctl_table (nn_vrf->ctl_hdr);
include/linux/sysctl.h +1 -1
@@ -182,7 +182,7 @@ struct ctl_table_header {struct rcu_head rcu; };struct completion *unregistering; -struct ctl_table *ctl_table_arg; +const struct ctl_table *ctl_table_arg;struct ctl_table_root *root;struct ctl_table_set *set;struct ctl_dir *parent;
ipc/ipc_sysctl.c +1 -1
@@ -274,7 +274,7 @@ bool setup_ipc_sysctls(struct ipc_namespace *ns)void retire_ipc_sysctls (struct ipc_namespace *ns) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->ipc_sysctls->ctl_table_arg;unregister_sysctl_table (ns->ipc_sysctls);
ipc/mq_sysctl.c +1 -1
@@ -124,7 +124,7 @@ bool setup_mq_sysctls(struct ipc_namespace *ns)void retire_mq_sysctls (struct ipc_namespace *ns) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->mq_sysctls->ctl_table_arg;unregister_sysctl_table (ns->mq_sysctls);
kernel/ucount.c +1 -1
@@ -119,7 +119,7 @@ bool setup_userns_sysctls(struct user_namespace *ns)void retire_userns_sysctls (struct user_namespace *ns) {#ifdef CONFIG_SYSCTL -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->sysctls->ctl_table_arg;unregister_sysctl_table (ns->sysctls);
net/ax25/sysctl_net_ax25.c +1 -1
@@ -171,7 +171,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)void ax25_unregister_dev_sysctl (ax25_dev *ax25_dev) {struct ctl_table_header *header = ax25_dev->sysheader; -struct ctl_table *table; +const struct ctl_table *table;if (header) { ax25_dev->sysheader =NULL ;
net/bridge/br_netfilter_hooks.c +3 -1
@@ -1146,7 +1146,9 @@ static int br_netfilter_sysctl_init_net(struct net *net)static void br_netfilter_sysctl_exit_net (struct net *net,struct brnf_net *brnet) { -struct ctl_table *table = brnet->ctl_hdr->ctl_table_arg; +const struct ctl_table *table; + + table = brnet->ctl_hdr->ctl_table_arg;unregister_net_sysctl_table (brnet->ctl_hdr);if (!net_eq (net, &init_net))
net/core/sysctl_net_core.c +1 -1
@@ -728,7 +728,7 @@ static __net_init int sysctl_core_net_init(struct net *net) static __net_exit void sysctl_core_net_exit(struct net *net) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->core.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->core.sysctl_hdr);
net/ieee802154/6lowpan/reassembly.c +1 -1
@@ -399,7 +399,7 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net) static void __net_exit lowpan_frags_ns_sysctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;struct netns_ieee802154_lowpan *ieee802154_lowpan =net_ieee802154_lowpan (net);
net/ipv4/devinet.c +1 -1
@@ -2767,7 +2767,7 @@ static __net_init int devinet_init_net(struct net *net) static __net_exit void devinet_exit_net(struct net *net) {#ifdef CONFIG_SYSCTL -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->ipv4.forw_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.forw_hdr);
net/ipv4/ip_fragment.c +1 -1
@@ -632,7 +632,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net) static void __net_exit ip4_frags_ns_ctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->ipv4.frags_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.frags_hdr);
net/ipv4/route.c +1 -1
@@ -3590,7 +3590,7 @@ static __net_init int sysctl_route_net_init(struct net *net) static __net_exit void sysctl_route_net_exit(struct net *net) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->ipv4.route_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.route_hdr);
net/ipv4/sysctl_net_ipv4.c +1 -1
@@ -1558,7 +1558,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net) static __net_exit void ipv4_sysctl_exit_net(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;kfree (net->ipv4.sysctl_local_reserved_ports); table = net->ipv4.ipv4_hdr->ctl_table_arg;
net/ipv4/xfrm4_policy.c +1 -1
@@ -186,7 +186,7 @@ static __net_init int xfrm4_net_sysctl_init(struct net *net) static __net_exit void xfrm4_net_sysctl_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;if (!net->ipv4.xfrm4_hdr)return ;
net/ipv6/addrconf.c +1 -1
@@ -7180,7 +7180,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,static void __addrconf_sysctl_unregister (struct net *net,struct ipv6_devconf *p,int ifindex) { -struct ctl_table *table; +const struct ctl_table *table;if (!p->sysctl_header)return ;
net/ipv6/netfilter/nf_conntrack_reasm.c +1 -1
@@ -105,7 +105,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net) static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net) {struct nft_ct_frag6_pernet *nf_frag =nf_frag_pernet (net); -struct ctl_table *table; +const struct ctl_table *table; table = nf_frag->nf_frag_frags_hdr->ctl_table_arg;unregister_net_sysctl_table (nf_frag->nf_frag_frags_hdr);
net/ipv6/reassembly.c +1 -1
@@ -487,7 +487,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net) static void __net_exit ip6_frags_ns_sysctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->ipv6.sysctl.frags_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv6.sysctl.frags_hdr);
net/ipv6/sysctl_net_ipv6.c +3 -3
@@ -313,9 +313,9 @@ static int __net_init ipv6_sysctl_net_init(struct net *net) static void __net_exit ipv6_sysctl_net_exit(struct net *net) { -struct ctl_table *ipv6_table; -struct ctl_table *ipv6_route_table; -struct ctl_table *ipv6_icmp_table; +const struct ctl_table *ipv6_table; +const struct ctl_table *ipv6_route_table; +const struct ctl_table *ipv6_icmp_table; ipv6_table = net->ipv6.sysctl.hdr->ctl_table_arg; ipv6_route_table = net->ipv6.sysctl.route_hdr->ctl_table_arg;
net/ipv6/xfrm6_policy.c +1 -1
@@ -218,7 +218,7 @@ static int __net_init xfrm6_net_sysctl_init(struct net *net) static void __net_exit xfrm6_net_sysctl_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;if (!net->ipv6.sysctl.xfrm6_hdr)return ;
net/mpls/af_mpls.c +2 -2
@@ -1438,7 +1438,7 @@ static void mpls_dev_sysctl_unregister(struct net_device *dev, struct mpls_dev *mdev) {struct net *net =dev_net (dev); -struct ctl_table *table; +const struct ctl_table *table;if (!mdev->sysctl)return ;
@@ -2704,7 +2704,7 @@ static void mpls_net_exit(struct net *net) {struct mpls_route __rcu **platform_label;size_t platform_labels; -struct ctl_table *table; +const struct ctl_table *table;unsigned int index; table = net->mpls.ctl->ctl_table_arg;
net/mptcp/ctrl.c +1 -1
@@ -198,7 +198,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)static void mptcp_pernet_del_table (struct mptcp_pernet *pernet) { -struct ctl_table *table = pernet->ctl_table_hdr->ctl_table_arg; +const struct ctl_table *table = pernet->ctl_table_hdr->ctl_table_arg;unregister_net_sysctl_table (pernet->ctl_table_hdr);
net/netfilter/nf_conntrack_standalone.c +1 -1
@@ -1122,7 +1122,7 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)static void nf_conntrack_standalone_fini_sysctl (struct net *net) {struct nf_conntrack_net *cnet =nf_ct_pernet (net); -struct ctl_table *table; +const struct ctl_table *table; table = cnet->sysctl_header->ctl_table_arg;unregister_net_sysctl_table (cnet->sysctl_header);
net/netfilter/nf_log.c +1 -1
@@ -508,7 +508,7 @@ static int netfilter_log_sysctl_init(struct net *net)static void netfilter_log_sysctl_exit (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->nf.nf_log_dir_header->ctl_table_arg;unregister_net_sysctl_table (net->nf.nf_log_dir_header);
net/sctp/sysctl.c +1 -1
@@ -624,7 +624,7 @@ int sctp_sysctl_net_register(struct net *net)void sctp_sysctl_net_unregister (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->sctp.sysctl_header->ctl_table_arg;unregister_net_sysctl_table (net->sctp.sysctl_header);
net/smc/smc_sysctl.c +1 -1
@@ -109,7 +109,7 @@ int __net_init smc_sysctl_net_init(struct net *net) void __net_exit smc_sysctl_net_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->smc.smc_hdr->ctl_table_arg;unregister_net_sysctl_table (net->smc.smc_hdr);
net/unix/sysctl_net_unix.c +1 -1
@@ -52,7 +52,7 @@ int __net_init unix_sysctl_register(struct net *net)void unix_sysctl_unregister (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->unx.ctl->ctl_table_arg;unregister_net_sysctl_table (net->unx.ctl);
net/xfrm/xfrm_sysctl.c +1 -1
@@ -76,7 +76,7 @@ int __net_init xfrm_sysctl_init(struct net *net) void __net_exit xfrm_sysctl_fini(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->xfrm.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->xfrm.sysctl_hdr);
Signature · 1 line
2.43.0
PATCH v2 12/18 sysctl: treewide: constify the ctl_table argument of handlers
In reply to Thomas WeißschuhIn a future commit the sysctl core will only use
"const struct ctl_table". As a preparation for that adapt all the proc handlers.
--- arch/arm64/kernel/armv8_deprecated.c | 2 +- arch/arm64/kernel/fpsimd.c | 2 +- arch/s390/appldata/appldata_base.c | 8 +-- 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 | 4 +- drivers/macintosh/mac_hid.c | 2 +- drivers/net/vrf.c | 2 +- drivers/parport/procfs.c | 12 ++--- fs/coredump.c | 2 +- fs/dcache.c | 4 +- fs/drop_caches.c | 2 +- fs/exec.c | 4 +- fs/file_table.c | 2 +- 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 | 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 | 4 +- 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 | 12 ++--- kernel/sched/topology.c | 2 +- kernel/seccomp.c | 4 +- kernel/stackleak.c | 2 +- kernel/sysctl.c | 82 +++++++++++++++---------------- 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 | 15 +++--- mm/compaction.c | 8 +-- mm/hugetlb.c | 6 +-- mm/page-writeback.c | 18 +++---- mm/page_alloc.c | 22 ++++----- mm/util.c | 12 ++--- mm/vmstat.c | 4 +- net/bridge/br_netfilter_hooks.c | 2 +- net/core/neighbour.c | 24 ++++----- net/core/sysctl_net_core.c | 20 ++++---- net/ipv4/devinet.c | 6 +-- net/ipv4/route.c | 2 +- net/ipv4/sysctl_net_ipv4.c | 33 +++++++------ net/ipv6/addrconf.c | 27 +++++----- net/ipv6/ndisc.c | 4 +- net/ipv6/route.c | 2 +- net/ipv6/sysctl_net_ipv6.c | 4 +- net/mpls/af_mpls.c | 4 +- net/netfilter/ipvs/ip_vs_ctl.c | 16 +++--- net/netfilter/nf_conntrack_standalone.c | 2 +- net/netfilter/nf_hooks_lwtunnel.c | 2 +- net/netfilter/nf_log.c | 2 +- net/phonet/sysctl.c | 2 +- net/rds/tcp.c | 4 +- net/sctp/sysctl.c | 28 +++++------ net/sunrpc/sysctl.c | 6 +-- net/sunrpc/xprtrdma/svc_rdma.c | 2 +- security/apparmor/lsm.c | 2 +- security/min_addr.c | 2 +- security/yama/yama_lsm.c | 2 +- 90 files changed, 306 insertions(+), 302 deletions(-)
arch/arm64/kernel/armv8_deprecated.c +1 -1
@@ -504,7 +504,7 @@ static int update_insn_emulation_mode(struct insn_emulation *insn,return ret; } -static int emulation_proc_handler (struct ctl_table *table,int write, +static int emulation_proc_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {
arch/arm64/kernel/fpsimd.c +1 -1
@@ -555,7 +555,7 @@ static unsigned int find_supported_vector_length(enum vec_type type,#if defined(CONFIG_ARM64_SVE ) && defined(CONFIG_SYSCTL ) -static int vec_proc_do_default_vl (struct ctl_table *table,int write, +static int vec_proc_do_default_vl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct vl_info *info = table->extra1;
arch/s390/appldata/appldata_base.c +4 -4
@@ -46,9 +46,9 @@* /proc entries (sysctl) */ static const char appldata_proc_name[APPLDATA_PROC_NAME_LENGTH ] ="appldata" ; -static int appldata_timer_handler (struct ctl_table *ctl,int write, +static int appldata_timer_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos); -static int appldata_interval_handler (struct ctl_table *ctl,int write, +static int appldata_interval_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos);static struct ctl_table_header *appldata_sysctl_header;
@@ -199,7 +199,7 @@ static void __appldata_vtimer_setup(int cmd)* Start/Stop timer, show status of timer (0 = not active, 1 = active) */ static int -appldata_timer_handler (struct ctl_table *ctl,int write, +appldata_timer_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int timer_active = appldata_timer_active;
@@ -232,7 +232,7 @@ appldata_timer_handler(struct ctl_table *ctl, int write,* current timer interval. */ static int -appldata_interval_handler (struct ctl_table *ctl,int write, +appldata_interval_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int interval = appldata_interval;
arch/s390/kernel/debug.c +1 -1
@@ -954,7 +954,7 @@ static int debug_active = 1;* always allow read, allow write only if debug_stoppable is set or * if debug_active is already off */ -static int s390dbf_procactive (struct ctl_table *table,int write, +static int s390dbf_procactive (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {if (!write || debug_stoppable || !debug_active)
arch/s390/kernel/topology.c +1 -1
@@ -600,7 +600,7 @@ static int __init topology_setup(char *str) }early_param ("topology" , topology_setup); -static int topology_ctl_handler (struct ctl_table *ctl,int write, +static int topology_ctl_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int enabled =topology_is_enabled ();
arch/s390/mm/cmm.c +3 -3
@@ -243,7 +243,7 @@ static int cmm_skip_blanks(char *cp, char **endp)return str != cp; } -static int cmm_pages_handler (struct ctl_table *ctl,int write, +static int cmm_pages_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {long nr =cmm_get_pages ();
@@ -262,7 +262,7 @@ static int cmm_pages_handler(struct ctl_table *ctl, int write,return 0 ; } -static int cmm_timed_pages_handler (struct ctl_table *ctl,int write, +static int cmm_timed_pages_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -282,7 +282,7 @@ static int cmm_timed_pages_handler(struct ctl_table *ctl, int write,return 0 ; } -static int cmm_timeout_handler (struct ctl_table *ctl,int write, +static int cmm_timeout_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {char buf[64 ], *p;
arch/x86/kernel/itmt.c +1 -1
@@ -38,7 +38,7 @@ static bool __read_mostly sched_itmt_capable;*/ unsigned int __read_mostly sysctl_sched_itmt_enabled; -static int sched_itmt_update_handler (struct ctl_table *table,int write, +static int sched_itmt_update_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {unsigned int old_sysctl;
drivers/cdrom/cdrom.c +2 -2
@@ -3473,7 +3473,7 @@ static int cdrom_print_info(const char *header, int val, char *info,return 0 ; } -static int cdrom_sysctl_info (struct ctl_table *ctl,int write, +static int cdrom_sysctl_info (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int pos;
@@ -3586,7 +3586,7 @@ static void cdrom_update_settings(void)mutex_unlock (&cdrom_mutex); } -static int cdrom_sysctl_handler (struct ctl_table *ctl,int write, +static int cdrom_sysctl_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
drivers/char/random.c +2 -2
@@ -1606,7 +1606,7 @@ static u8 sysctl_bootid[UUID_SIZE];* UUID. The difference is in whether table->data is NULL; if it is, * then a new UUID is generated and returned to the user. */ -static int proc_do_uuid (struct ctl_table *table,int write,void *buf, +static int proc_do_uuid (const struct ctl_table *table,int write,void *buf,size_t *lenp,loff_t *ppos) {u8 tmp_uuid[UUID_SIZE ], *uuid;
@@ -1637,7 +1637,7 @@ static int proc_do_uuid(struct ctl_table *table, int write, void *buf, }/* The same as proc_dointvec, but writes don't change anything. */ -static int proc_do_rointvec (struct ctl_table *table,int write,void *buf, +static int proc_do_rointvec (const struct ctl_table *table,int write,void *buf,size_t *lenp,loff_t *ppos) {return write ?0 :proc_dointvec (table,0 , buf, lenp, ppos);
drivers/macintosh/mac_hid.c +1 -1
@@ -182,7 +182,7 @@ static void mac_hid_stop_emulation(void)mac_hid_destroy_emumouse (); } -static int mac_hid_toggle_emumouse (struct ctl_table *table,int write, +static int mac_hid_toggle_emumouse (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int *valp = table->data;
drivers/net/vrf.c +1 -1
@@ -1908,7 +1908,7 @@ static int vrf_strict_mode_change(struct vrf_map *vmap, bool new_mode)return res; } -static int vrf_shared_table_handler (struct ctl_table *table,int write, +static int vrf_shared_table_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net = (struct net *)table->extra1;
drivers/parport/procfs.c +6 -6
@@ -33,7 +33,7 @@#define PARPORT_MIN_SPINTIME_VALUE 1#define PARPORT_MAX_SPINTIME_VALUE 1000 -static int do_active_device (struct ctl_table *table,int write, +static int do_active_device (const struct ctl_table *table,int write,void *result,size_t *lenp,loff_t *ppos) {struct parport *port = (struct parport *)table->extra1;
@@ -70,7 +70,7 @@ static int do_active_device(struct ctl_table *table, int write, }#ifdef CONFIG_PARPORT_1284 -static int do_autoprobe (struct ctl_table *table,int write, +static int do_autoprobe (const struct ctl_table *table,int write,void *result,size_t *lenp,loff_t *ppos) {struct parport_device_info *info = table->extra2;
@@ -113,7 +113,7 @@ static int do_autoprobe(struct ctl_table *table, int write, }#endif /* IEEE1284.3 support. */ -static int do_hardware_base_addr (struct ctl_table *table,int write, +static int do_hardware_base_addr (const struct ctl_table *table,int write,void *result,size_t *lenp,loff_t *ppos) {struct parport *port = (struct parport *)table->extra1;
@@ -140,7 +140,7 @@ static int do_hardware_base_addr(struct ctl_table *table, int write,return 0 ; } -static int do_hardware_irq (struct ctl_table *table,int write, +static int do_hardware_irq (const struct ctl_table *table,int write,void *result,size_t *lenp,loff_t *ppos) {struct parport *port = (struct parport *)table->extra1;
@@ -167,7 +167,7 @@ static int do_hardware_irq(struct ctl_table *table, int write,return 0 ; } -static int do_hardware_dma (struct ctl_table *table,int write, +static int do_hardware_dma (const struct ctl_table *table,int write,void *result,size_t *lenp,loff_t *ppos) {struct parport *port = (struct parport *)table->extra1;
@@ -194,7 +194,7 @@ static int do_hardware_dma(struct ctl_table *table, int write,return 0 ; } -static int do_hardware_modes (struct ctl_table *table,int write, +static int do_hardware_modes (const struct ctl_table *table,int write,void *result,size_t *lenp,loff_t *ppos) {struct parport *port = (struct parport *)table->extra1;
fs/coredump.c +1 -1
@@ -949,7 +949,7 @@ void validate_coredump_safety(void) } } -static int proc_dostring_coredump (struct ctl_table *table,int write, +static int proc_dostring_coredump (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int error =proc_dostring (table, write, buffer, lenp, ppos);
fs/dcache.c +2 -2
@@ -174,8 +174,8 @@ static long get_nr_dentry_negative(void)return sum <0 ?0 : sum; } -static int proc_nr_dentry (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +static int proc_nr_dentry (const struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) { dentry_stat.nr_dentry =get_nr_dentry (); dentry_stat.nr_unused =get_nr_dentry_unused ();
fs/drop_caches.c +1 -1
@@ -48,7 +48,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)iput (toput_inode); } -int drop_caches_sysctl_handler (struct ctl_table *table,int write, +int drop_caches_sysctl_handler (const struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {int ret;
fs/exec.c +2 -2
@@ -2145,8 +2145,8 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd,#ifdef CONFIG_SYSCTL -static int proc_dointvec_minmax_coredump (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +static int proc_dointvec_minmax_coredump (const struct ctl_table *table, +int write,void *buffer,size_t *lenp,loff_t *ppos) {int error =proc_dointvec_minmax (table, write, buffer, lenp, ppos);
fs/file_table.c +1 -1
@@ -109,7 +109,7 @@ EXPORT_SYMBOL_GPL(get_max_files);/* * Handle nr_files sysctl */ -static int proc_nr_files (struct ctl_table *table,int write,void *buffer, +static int proc_nr_files (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { files_stat.nr_files =get_nr_files ();
fs/fs-writeback.c +1 -1
@@ -2379,7 +2379,7 @@ static int __init start_dirtytime_writeback(void) }__initcall (start_dirtytime_writeback); -int dirtytime_interval_handler (struct ctl_table *table,int write, +int dirtytime_interval_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
fs/inode.c +2 -2
@@ -106,8 +106,8 @@ long get_nr_dirty_inodes(void)*/ static struct inodes_stat_t inodes_stat; -static int proc_nr_inodes (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +static int proc_nr_inodes (const struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) { inodes_stat.nr_inodes =get_nr_inodes (); inodes_stat.nr_unused =get_nr_inodes_unused ();
fs/pipe.c +1 -1
@@ -1468,7 +1468,7 @@ static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,return 0 ; } -static int proc_dopipe_max_size (struct ctl_table *table,int write, +static int proc_dopipe_max_size (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { return do_proc_douintvec(table, write, buffer, lenp, ppos,
fs/quota/dquot.c +1 -1
@@ -2887,7 +2887,7 @@ const struct quotactl_ops dquot_quotactl_sysfile_ops = { };EXPORT_SYMBOL (dquot_quotactl_sysfile_ops); -static int do_proc_dqstats (struct ctl_table *table,int write, +static int do_proc_dqstats (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {unsigned int type = (unsigned long *)table->data - dqstats.stat;
fs/xfs/xfs_sysctl.c +3 -3
@@ -11,7 +11,7 @@ static struct ctl_table_header *xfs_table_header;#ifdef CONFIG_PROC_FS STATIC int xfs_stats_clear_proc_handler( - struct ctl_table *ctl, + const struct ctl_table *ctl, int write, void *buffer, size_t *lenp,
@@ -31,7 +31,7 @@ xfs_stats_clear_proc_handler( STATIC int xfs_panic_mask_proc_handler( - struct ctl_table *ctl, + const struct ctl_table *ctl, int write, void *buffer, size_t *lenp,
@@ -52,7 +52,7 @@ xfs_panic_mask_proc_handler( STATIC int xfs_deprecated_dointvec_minmax( - struct ctl_table *ctl, + const struct ctl_table *ctl, int write, void *buffer, size_t *lenp,
include/linux/ftrace.h +2 -2
@@ -470,7 +470,7 @@ static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs,extern int stack_tracer_enabled; -int stack_trace_sysctl (struct ctl_table *table,int write,void *buffer, +int stack_trace_sysctl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos);/* DO NOT MODIFY THIS VARIABLE DIRECTLY! */
@@ -1157,7 +1157,7 @@ extern int tracepoint_printk;extern void disable_trace_on_warning (void );extern int __disable_trace_on_warning; -int tracepoint_printk_sysctl (struct ctl_table *table,int write, +int tracepoint_printk_sysctl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos);#else /* CONFIG_TRACING */
include/linux/mm.h +4 -4
@@ -202,11 +202,11 @@ extern int sysctl_overcommit_memory;extern int sysctl_overcommit_ratio;extern unsigned long sysctl_overcommit_kbytes; -int overcommit_ratio_handler (struct ctl_table *,int ,void *,size_t *, +int overcommit_ratio_handler (const struct ctl_table *,int ,void *,size_t *,loff_t *); -int overcommit_kbytes_handler (struct ctl_table *,int ,void *,size_t *, +int overcommit_kbytes_handler (const struct ctl_table *,int ,void *,size_t *,loff_t *); -int overcommit_policy_handler (struct ctl_table *,int ,void *,size_t *, +int overcommit_policy_handler (const struct ctl_table *,int ,void *,size_t *,loff_t *);#if defined(CONFIG_SPARSEMEM ) && !defined(CONFIG_SPARSEMEM_VMEMMAP )
@@ -3805,7 +3805,7 @@ extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm);#ifdef CONFIG_SYSCTL extern int sysctl_drop_caches; -int drop_caches_sysctl_handler (struct ctl_table *,int ,void *,size_t *, +int drop_caches_sysctl_handler (const struct ctl_table *,int ,void *,size_t *,loff_t *);#endif
include/linux/perf_event.h +3 -3
@@ -1578,11 +1578,11 @@ extern int sysctl_perf_cpu_time_max_percent;extern void perf_sample_event_took (u64 sample_len_ns); -int perf_event_max_sample_rate_handler (struct ctl_table *table,int write, +int perf_event_max_sample_rate_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos); -int perf_cpu_time_max_percent_handler (struct ctl_table *table,int write, +int perf_cpu_time_max_percent_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos); -int perf_event_max_stack_handler (struct ctl_table *table,int write, +int perf_event_max_stack_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos);/* Access to perf_event_open(2) syscall. */
include/linux/security.h +1 -1
@@ -223,7 +223,7 @@ struct request_sock;#define LSM_UNSAFE_NO_NEW_PRIVS 4#ifdef CONFIG_MMU -extern int mmap_min_addr_handler (struct ctl_table *table,int write, +extern int mmap_min_addr_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos);#endif
include/linux/sysctl.h +18 -18
@@ -61,31 +61,31 @@ extern const int sysctl_vals[];extern const unsigned long sysctl_long_vals[]; -typedef int proc_handler (struct ctl_table *ctl,int write,void *buffer, +typedef int proc_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos); -int proc_dostring (struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_dobool (struct ctl_table *table,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 (struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_douintvec (struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_dointvec_minmax (struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_douintvec_minmax (struct ctl_table *table,int write,void *buffer, +int proc_dointvec (const struct ctl_table *,int ,void *,size_t *,loff_t *); +int proc_douintvec (const struct ctl_table *,int ,void *,size_t *,loff_t *); +int proc_dointvec_minmax (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); -int proc_dou8vec_minmax (struct ctl_table *table,int write,void *buffer, +int proc_dou8vec_minmax (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos); -int proc_dointvec_jiffies (struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_dointvec_ms_jiffies_minmax (struct ctl_table *table,int write, +int proc_dointvec_jiffies (const struct ctl_table *,int ,void *,size_t *,loff_t *); +int proc_dointvec_ms_jiffies_minmax (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos); -int proc_dointvec_userhz_jiffies (struct ctl_table *,int ,void *,size_t *, +int proc_dointvec_userhz_jiffies (const struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_dointvec_ms_jiffies (struct ctl_table *,int ,void *,size_t *, +int proc_dointvec_ms_jiffies (const struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_doulongvec_minmax (struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_doulongvec_ms_jiffies_minmax (struct ctl_table *table,int ,void *, +int proc_doulongvec_minmax (const struct ctl_table *,int ,void *,size_t *,loff_t *); +int proc_doulongvec_ms_jiffies_minmax (const struct ctl_table *table,int ,void *,size_t *,loff_t *); -int proc_do_large_bitmap (struct ctl_table *,int ,void *,size_t *,loff_t *); -int proc_do_static_key (struct ctl_table *table,int write,void *buffer, +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);/*
@@ -243,7 +243,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,
@@ -293,7 +293,7 @@ static inline bool sysctl_is_alias(char *param) }#endif /* CONFIG_SYSCTL */ -int sysctl_max_threads (struct ctl_table *table,int write,void *buffer, +int sysctl_max_threads (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos);#endif /* _LINUX_SYSCTL_H */
include/linux/vmstat.h +3 -3
@@ -17,7 +17,7 @@ extern int sysctl_stat_interval;#define DISABLE_NUMA_STAT 0extern int sysctl_vm_numa_stat;DECLARE_STATIC_KEY_TRUE (vm_numa_stat_key); -int sysctl_vm_numa_stat_handler (struct ctl_table *table,int write, +int sysctl_vm_numa_stat_handler (const struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos);#endif
@@ -301,8 +301,8 @@ void cpu_vm_stats_fold(int cpu);void refresh_zone_stat_thresholds (void );struct ctl_table ; -int vmstat_refresh (struct ctl_table *,int write,void *buffer,size_t *lenp, -loff_t *ppos); +int vmstat_refresh (const struct ctl_table *,int write,void *buffer, +size_t *lenp,loff_t *ppos);void drain_zonestat (struct zone *zone,struct per_cpu_zonestat *);
include/linux/writeback.h +1 -1
@@ -344,7 +344,7 @@ extern unsigned int dirty_expire_interval;extern unsigned int dirtytime_expire_interval;extern int laptop_mode; -int dirtytime_interval_handler (struct ctl_table *table,int write, +int dirtytime_interval_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos);void global_dirty_limits (unsigned long *pbackground,unsigned long *pdirty);
include/net/ndisc.h +1 -1
@@ -486,7 +486,7 @@ void igmp6_event_report(struct sk_buff *skb);#ifdef CONFIG_SYSCTL -int ndisc_ifinfo_sysctl_change (struct ctl_table *ctl,int write, +int ndisc_ifinfo_sysctl_change (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos);#endif
include/net/neighbour.h +3 -3
@@ -412,12 +412,12 @@ void *neigh_seq_start(struct seq_file *, loff_t *, struct neigh_table *,void *neigh_seq_next (struct seq_file *,void *,loff_t *);void neigh_seq_stop (struct seq_file *,void *); -int neigh_proc_dointvec (struct ctl_table *ctl,int write, +int neigh_proc_dointvec (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos); -int neigh_proc_dointvec_jiffies (struct ctl_table *ctl,int write, +int neigh_proc_dointvec_jiffies (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos); -int neigh_proc_dointvec_ms_jiffies (struct ctl_table *ctl,int write, +int neigh_proc_dointvec_ms_jiffies (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos); int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
include/net/netfilter/nf_hooks_lwtunnel.h +1 -1
@@ -2,6 +2,6 @@#include <linux/types.h> #ifdef CONFIG_SYSCTL -int nf_hooks_lwtunnel_sysctl_handler (struct ctl_table *table,int write, +int nf_hooks_lwtunnel_sysctl_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos);#endif
ipc/ipc_sysctl.c +4 -4
@@ -16,8 +16,8 @@#include <linux/slab.h> #include "util.h" -static int proc_ipc_dointvec_minmax_orphans (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +static int proc_ipc_dointvec_minmax_orphans (const struct ctl_table *table, +int write,void *buffer,size_t *lenp,loff_t *ppos) {struct ipc_namespace *ns = container_of(table->data, struct ipc_namespace, shm_rmid_forced);
@@ -32,7 +32,7 @@ static int proc_ipc_dointvec_minmax_orphans(struct ctl_table *table, int write,return err; } -static int proc_ipc_auto_msgmni (struct ctl_table *table,int write, +static int proc_ipc_auto_msgmni (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct ctl_table ipc_table;
@@ -47,7 +47,7 @@ static int proc_ipc_auto_msgmni(struct ctl_table *table, int write,return proc_dointvec_minmax (&ipc_table, write, buffer, lenp, ppos); } -static int proc_ipc_sem_dointvec (struct ctl_table *table,int write, +static int proc_ipc_sem_dointvec (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { struct ipc_namespace *ns =
kernel/bpf/syscall.c +2 -2
@@ -5652,7 +5652,7 @@ const struct bpf_prog_ops bpf_syscall_prog_ops = { };#ifdef CONFIG_SYSCTL -static int bpf_stats_handler (struct ctl_table *table,int write, +static int bpf_stats_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct static_key *key = (struct static_key *)table->data;
@@ -5687,7 +5687,7 @@ void __weak unpriv_ebpf_notify(int new_state) { } -static int bpf_unpriv_handler (struct ctl_table *table,int write, +static int bpf_unpriv_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret, unpriv_enable = *(int *)table->data;
kernel/delayacct.c +2 -2
@@ -44,8 +44,8 @@ void delayacct_init(void) }#ifdef CONFIG_PROC_SYSCTL -static int sysctl_delayacct (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +static int sysctl_delayacct (const struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) {int state = delayacct_on;struct ctl_table t;
kernel/events/callchain.c +1 -1
@@ -229,7 +229,7 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,* Used for sysctl_perf_event_max_stack and * sysctl_perf_event_max_contexts_per_stack. */ -int perf_event_max_stack_handler (struct ctl_table *table,int write, +int perf_event_max_stack_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int *value = table->data;
kernel/events/core.c +2 -2
@@ -450,7 +450,7 @@ static void update_perf_cpu_limits(void)static bool perf_rotate_context (struct perf_cpu_pmu_context *cpc); -int perf_event_max_sample_rate_handler (struct ctl_table *table,int write, +int perf_event_max_sample_rate_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
@@ -474,7 +474,7 @@ int perf_event_max_sample_rate_handler(struct ctl_table *table, int write,int sysctl_perf_cpu_time_max_percent__read_mostly =DEFAULT_CPU_TIME_MAX_PERCENT ; -int perf_cpu_time_max_percent_handler (struct ctl_table *table,int write, +int perf_cpu_time_max_percent_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret =proc_dointvec_minmax (table, write, buffer, lenp, ppos);
kernel/fork.c +1 -1
@@ -3528,7 +3528,7 @@ int unshare_files(void)return 0 ; } -int sysctl_max_threads (struct ctl_table *table,int write, +int sysctl_max_threads (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct ctl_table t;
kernel/hung_task.c +2 -2
@@ -238,8 +238,8 @@ static long hung_timeout_jiffies(unsigned long last_checked,/* * Process updating of timeout sysctl */ -static int proc_dohung_task_timeout_secs (struct ctl_table *table,int write, -void *buffer, +static int proc_dohung_task_timeout_secs (const struct ctl_table *table, +int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
kernel/kexec_core.c +1 -1
@@ -928,7 +928,7 @@ struct kimage *kexec_crash_image;static int kexec_load_disabled;#ifdef CONFIG_SYSCTL -static int kexec_limit_handler (struct ctl_table *table,int write, +static int kexec_limit_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct kexec_load_limit *limit = table->data;
kernel/kprobes.c +1 -1
@@ -939,7 +939,7 @@ static void unoptimize_all_kprobes(void)static DEFINE_MUTEX (kprobe_sysctl_mutex);static int sysctl_kprobes_optimization; -static int proc_kprobes_optimization_handler (struct ctl_table *table, +static int proc_kprobes_optimization_handler (const struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {
kernel/latencytop.c +2 -2
@@ -65,8 +65,8 @@ static struct latency_record latency_record[MAXLR];int latencytop_enabled;#ifdef CONFIG_SYSCTL -static int sysctl_latencytop (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +static int sysctl_latencytop (const struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) {int err;
kernel/pid_namespace.c +1 -1
@@ -276,7 +276,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns) }#ifdef CONFIG_CHECKPOINT_RESTORE -static int pid_ns_ctl_handler (struct ctl_table *table,int write, +static int pid_ns_ctl_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct pid_namespace *pid_ns =task_active_pid_ns (current);
kernel/pid_sysctl.h +1 -1
@@ -5,7 +5,7 @@#include <linux/pid_namespace.h> #if defined(CONFIG_SYSCTL ) && defined(CONFIG_MEMFD_CREATE ) -static int pid_mfd_noexec_dointvec_minmax (struct ctl_table *table, +static int pid_mfd_noexec_dointvec_minmax (const struct ctl_table *table,int write,void *buf,size_t *lenp,loff_t *ppos) {struct pid_namespace *ns =task_active_pid_ns (current);
kernel/printk/internal.h +1 -1
@@ -8,7 +8,7 @@#if defined(CONFIG_PRINTK ) && defined(CONFIG_SYSCTL )void __init printk_sysctl_init (void ); -int devkmsg_sysctl_set_loglvl (struct ctl_table *table,int write, +int devkmsg_sysctl_set_loglvl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos);#else #define printk_sysctl_init () do { } while (0)
kernel/printk/printk.c +1 -1
@@ -197,7 +197,7 @@ __setup("printk.devkmsg=", control_devkmsg);char devkmsg_log_str[DEVKMSG_STR_MAX_SIZE ] ="ratelimit" ;#if defined(CONFIG_PRINTK ) && defined(CONFIG_SYSCTL ) -int devkmsg_sysctl_set_loglvl (struct ctl_table *table,int write, +int devkmsg_sysctl_set_loglvl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {char old_str[DEVKMSG_STR_MAX_SIZE ];
kernel/printk/sysctl.c +3 -2
@@ -11,8 +11,9 @@static const int ten_thousand =10000 ; -static int proc_dointvec_minmax_sysadmin (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +static int proc_dointvec_minmax_sysadmin (const struct ctl_table *table, +int write,void *buffer,size_t *lenp, +loff_t *ppos) {if (write && !capable (CAP_SYS_ADMIN ))return -EPERM ;
kernel/sched/core.c +4 -4
@@ -1813,7 +1813,7 @@ static void uclamp_sync_util_min_rt_default(void)uclamp_update_util_min_rt_default (p); } -static int sysctl_sched_uclamp_handler (struct ctl_table *table,int write, +static int sysctl_sched_uclamp_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {bool update_root_tg = false;
@@ -4570,7 +4570,7 @@ static void reset_memory_tiering(void) } } -static int sysctl_numa_balancing (struct ctl_table *table,int write, +static int sysctl_numa_balancing (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct ctl_table t;
@@ -4639,8 +4639,8 @@ static int __init setup_schedstats(char *str)__setup ("schedstats=" , setup_schedstats);#ifdef CONFIG_PROC_SYSCTL -static int sysctl_schedstats (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +static int sysctl_schedstats (const struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) {struct ctl_table t;int err;
kernel/sched/rt.c +6 -6
@@ -26,9 +26,9 @@ int sysctl_sched_rt_runtime = 950000; #ifdef CONFIG_SYSCTL static int sysctl_sched_rr_timeslice = (MSEC_PER_SEC * RR_TIMESLICE) / HZ; -static int sched_rt_handler(struct ctl_table *table, int write, void *buffer, +static int sched_rt_handler(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos); -static int sched_rr_handler(struct ctl_table *table, int write, void *buffer, +static int sched_rr_handler(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos); static struct ctl_table sched_rt_sysctls[] = { {
@@ -2962,8 +2962,8 @@ static void sched_rt_do_global(void)raw_spin_unlock_irqrestore (&def_rt_bandwidth.rt_runtime_lock, flags); } -static int sched_rt_handler (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +static int sched_rt_handler (const struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) {int old_period, old_runtime;static DEFINE_MUTEX (mutex);
@@ -3001,8 +3001,8 @@ static int sched_rt_handler(struct ctl_table *table, int write, void *buffer,return ret; } -static int sched_rr_handler (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +static int sched_rr_handler (const struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) {int ret;static DEFINE_MUTEX (mutex);
kernel/sched/topology.c +1 -1
@@ -285,7 +285,7 @@ void rebuild_sched_domains_energy(void) }#ifdef CONFIG_PROC_SYSCTL -static int sched_energy_aware_handler (struct ctl_table *table,int write, +static int sched_energy_aware_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret, state;
kernel/seccomp.c +2 -2
@@ -2413,8 +2413,8 @@ static void audit_actions_logged(u32 actions_logged, u32 old_actions_logged,return audit_seccomp_actions_logged (new, old, !ret); } -static int seccomp_actions_logged_handler (struct ctl_table *ro_table,int write, -void *buffer,size_t *lenp, +static int seccomp_actions_logged_handler (const struct ctl_table *ro_table, +int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
kernel/stackleak.c +1 -1
@@ -21,7 +21,7 @@static DEFINE_STATIC_KEY_FALSE (stack_erasing_bypass);#ifdef CONFIG_SYSCTL -static int stack_erasing_sysctl (struct ctl_table *table,int write, +static int stack_erasing_sysctl (const struct ctl_table *table,int write,void __user *buffer,size_t *lenp,loff_t *ppos) {int ret =0 ;
kernel/sysctl.c +41 -41
315 lines not on this page · raw message
kernel/time/timer.c +1 -1
@@ -237,7 +237,7 @@ static void timers_update_migration(void) }#ifdef CONFIG_SYSCTL -static int timer_migration_handler (struct ctl_table *table,int write, +static int timer_migration_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
kernel/trace/ftrace.c +1 -1
@@ -8213,7 +8213,7 @@ static bool is_permanent_ops_registered(void) }static int -ftrace_enable_sysctl (struct ctl_table *table,int write, +ftrace_enable_sysctl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret = -ENODEV ;
kernel/trace/trace.c +1 -1
@@ -2972,7 +2972,7 @@ static void output_printk(struct trace_event_buffer *fbuffer)raw_spin_unlock_irqrestore (&tracepoint_iter_lock, flags); } -int tracepoint_printk_sysctl (struct ctl_table *table,int write, +int tracepoint_printk_sysctl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {
kernel/trace/trace_events_user.c +1 -1
@@ -2724,7 +2724,7 @@ static int create_user_tracefs(void)return -ENODEV ; } -static int set_max_user_events_sysctl (struct ctl_table *table,int write, +static int set_max_user_events_sysctl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
kernel/trace/trace_stack.c +1 -1
@@ -514,7 +514,7 @@ static const struct file_operations stack_trace_filter_fops = {#endif /* CONFIG_DYNAMIC_FTRACE */ int -stack_trace_sysctl (struct ctl_table *table,int write,void *buffer, +stack_trace_sysctl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int was_enabled;
kernel/umh.c +1 -1
@@ -495,7 +495,7 @@ int call_usermodehelper(const char *path, char **argv, char **envp, int wait)EXPORT_SYMBOL (call_usermodehelper);#if defined(CONFIG_SYSCTL ) -static int proc_cap_handler (struct ctl_table *table,int write, +static int proc_cap_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct ctl_table t;
kernel/utsname_sysctl.c +1 -1
@@ -30,7 +30,7 @@ static void *get_uts(const struct ctl_table *table)* Special case of dostring for the UTS structure. This has locks * to observe. Should this be in kernel/sys.c ???? */ -static int proc_do_uts_string (struct ctl_table *table,int write, +static int proc_do_uts_string (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct ctl_table uts_table;
kernel/watchdog.c +8 -7
@@ -745,8 +745,9 @@ static void proc_watchdog_update(void)* -------------------|----------------------------------|------------------------------- * proc_soft_watchdog | watchdog_softlockup_user_enabled | WATCHDOG_SOFTOCKUP_ENABLED */ -static int proc_watchdog_common (int which,struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +static int proc_watchdog_common (int which,const struct ctl_table *table, +int write,void *buffer,size_t *lenp, +loff_t *ppos) {int err, old, *param = table->data;
@@ -772,7 +773,7 @@ static int proc_watchdog_common(int which, struct ctl_table *table, int write,/* * /proc/sys/kernel/watchdog */ -static int proc_watchdog (struct ctl_table *table,int write, +static int proc_watchdog (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { return proc_watchdog_common(WATCHDOG_HARDLOCKUP_ENABLED |
@@ -783,7 +784,7 @@ static int proc_watchdog(struct ctl_table *table, int write,/* * /proc/sys/kernel/nmi_watchdog */ -static int proc_nmi_watchdog (struct ctl_table *table,int write, +static int proc_nmi_watchdog (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {if (!watchdog_hardlockup_available && write)
@@ -795,7 +796,7 @@ static int proc_nmi_watchdog(struct ctl_table *table, int write,/* * /proc/sys/kernel/soft_watchdog */ -static int proc_soft_watchdog (struct ctl_table *table,int write, +static int proc_soft_watchdog (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { return proc_watchdog_common(WATCHDOG_SOFTOCKUP_ENABLED,
@@ -805,7 +806,7 @@ static int proc_soft_watchdog(struct ctl_table *table, int write,/* * /proc/sys/kernel/watchdog_thresh */ -static int proc_watchdog_thresh (struct ctl_table *table,int write, +static int proc_watchdog_thresh (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int err, old;
@@ -828,7 +829,7 @@ static int proc_watchdog_thresh(struct ctl_table *table, int write,* user to specify a mask that will include cpus that have not yet * been brought online, if desired. */ -static int proc_watchdog_cpumask (struct ctl_table *table,int write, +static int proc_watchdog_cpumask (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int err;
mm/compaction.c +4 -4
@@ -2842,8 +2842,8 @@ static void compact_nodes(void)compact_node (nid); } -static int compaction_proactiveness_sysctl_handler (struct ctl_table *table,int write, -void *buffer,size_t *length,loff_t *ppos) +static int compaction_proactiveness_sysctl_handler (const struct ctl_table *table, +int write,void *buffer,size_t *length,loff_t *ppos) {int rc, nid;
@@ -2872,7 +2872,7 @@ static int compaction_proactiveness_sysctl_handler(struct ctl_table *table, int* This is the entry point for compacting all nodes via * /proc/sys/vm/compact_memory */ -static int sysctl_compaction_handler (struct ctl_table *table,int write, +static int sysctl_compaction_handler (const struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {int ret;
@@ -3183,7 +3183,7 @@ static int kcompactd_cpu_online(unsigned int cpu)return 0 ; } -static int proc_dointvec_minmax_warn_RT_change (struct ctl_table *table, +static int proc_dointvec_minmax_warn_RT_change (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret, old;
mm/hugetlb.c +3 -3
@@ -4874,7 +4874,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,return ret; } -static int hugetlb_sysctl_handler (struct ctl_table *table,int write, +static int hugetlb_sysctl_handler (const struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {
@@ -4883,7 +4883,7 @@ static int hugetlb_sysctl_handler(struct ctl_table *table, int write, }#ifdef CONFIG_NUMA -static int hugetlb_mempolicy_sysctl_handler (struct ctl_table *table,int write, +static int hugetlb_mempolicy_sysctl_handler (const struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) { return hugetlb_sysctl_handler_common(true, table, write,
@@ -4891,7 +4891,7 @@ static int hugetlb_mempolicy_sysctl_handler(struct ctl_table *table, int write, }#endif /* CONFIG_NUMA */ -static int hugetlb_overcommit_handler (struct ctl_table *table,int write, +static int hugetlb_overcommit_handler (const struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {struct hstate *h = &default_hstate;
mm/page-writeback.c +9 -9
@@ -493,8 +493,8 @@ bool node_dirty_ok(struct pglist_data *pgdat) }#ifdef CONFIG_SYSCTL -static int dirty_background_ratio_handler (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +static int dirty_background_ratio_handler (const struct ctl_table *table, +int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
@@ -504,8 +504,8 @@ static int dirty_background_ratio_handler(struct ctl_table *table, int write,return ret; } -static int dirty_background_bytes_handler (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +static int dirty_background_bytes_handler (const struct ctl_table *table, +int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
@@ -515,8 +515,8 @@ static int dirty_background_bytes_handler(struct ctl_table *table, int write,return ret; } -static int dirty_ratio_handler (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +static int dirty_ratio_handler (const struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) {int old_ratio = vm_dirty_ratio;int ret;
@@ -529,7 +529,7 @@ static int dirty_ratio_handler(struct ctl_table *table, int write, void *buffer,return ret; } -static int dirty_bytes_handler (struct ctl_table *table,int write, +static int dirty_bytes_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {unsigned long old_bytes = vm_dirty_bytes;
@@ -2132,8 +2132,8 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb)/* * sysctl handler for /proc/sys/vm/dirty_writeback_centisecs */ -static int dirty_writeback_centisecs_handler (struct ctl_table *table,int write, -void *buffer,size_t *length,loff_t *ppos) +static int dirty_writeback_centisecs_handler (const struct ctl_table *table, +int write,void *buffer,size_t *length,loff_t *ppos) {unsigned int old_interval = dirty_writeback_interval;int ret;
mm/page_alloc.c +11 -11
@@ -4985,7 +4985,7 @@ static char numa_zonelist_order[] = "Node";/* * sysctl handler for numa_zonelist_order */ -static int numa_zonelist_order_handler (struct ctl_table *table,int write, +static int numa_zonelist_order_handler (const struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {if (write)
@@ -5978,8 +5978,8 @@ postcore_initcall(init_per_zone_wmark_min)* that we can call two helper functions whenever min_free_kbytes * changes. */ -static int min_free_kbytes_sysctl_handler (struct ctl_table *table,int write, -void *buffer,size_t *length,loff_t *ppos) +static int min_free_kbytes_sysctl_handler (const struct ctl_table *table, +int write,void *buffer,size_t *length,loff_t *ppos) {int rc;
@@ -5994,8 +5994,8 @@ static int min_free_kbytes_sysctl_handler(struct ctl_table *table, int write,return 0 ; } -static int watermark_scale_factor_sysctl_handler (struct ctl_table *table,int write, -void *buffer,size_t *length,loff_t *ppos) +static int watermark_scale_factor_sysctl_handler (const struct ctl_table *table, +int write,void *buffer,size_t *length,loff_t *ppos) {int rc;
@@ -6024,8 +6024,8 @@ static void setup_min_unmapped_ratio(void) } -static int sysctl_min_unmapped_ratio_sysctl_handler (struct ctl_table *table,int write, -void *buffer,size_t *length,loff_t *ppos) +static int sysctl_min_unmapped_ratio_sysctl_handler (const struct ctl_table *table, +int write,void *buffer,size_t *length,loff_t *ppos) {int rc;
@@ -6051,8 +6051,8 @@ static void setup_min_slab_ratio(void) sysctl_min_slab_ratio) / 100; } -static int sysctl_min_slab_ratio_sysctl_handler (struct ctl_table *table,int write, -void *buffer,size_t *length,loff_t *ppos) +static int sysctl_min_slab_ratio_sysctl_handler (const struct ctl_table *table, +int write,void *buffer,size_t *length,loff_t *ppos) {int rc;
@@ -6075,7 +6075,7 @@ static int sysctl_min_slab_ratio_sysctl_handler(struct ctl_table *table, int wri* minimum watermarks. The lowmem reserve ratio can only make sense * if in function of the boot time zone sizes. */ -static int lowmem_reserve_ratio_sysctl_handler (struct ctl_table *table, +static int lowmem_reserve_ratio_sysctl_handler (const struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {int i;
@@ -6096,7 +6096,7 @@ static int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *table,* cpu. It is the fraction of total pages in each zone that a hot per cpu * pagelist can have before it gets flushed back to buddy allocator. */ -static int percpu_pagelist_high_fraction_sysctl_handler (struct ctl_table *table, +static int percpu_pagelist_high_fraction_sysctl_handler (const struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {struct zone *zone;
mm/util.c +6 -6
@@ -818,8 +818,8 @@ int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;unsigned long sysctl_user_reserve_kbytes__read_mostly =1UL <<17 ;/* 128MB */ unsigned long sysctl_admin_reserve_kbytes__read_mostly =1UL <<13 ;/* 8MB */ -int overcommit_ratio_handler (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +int overcommit_ratio_handler (const struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) {int ret;
@@ -834,8 +834,8 @@ static void sync_overcommit_as(struct work_struct *dummy)percpu_counter_sync (&vm_committed_as); } -int overcommit_policy_handler (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +int overcommit_policy_handler (const struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) {struct ctl_table t;int new_policy =-1 ;
@@ -870,8 +870,8 @@ int overcommit_policy_handler(struct ctl_table *table, int write, void *buffer,return ret; } -int overcommit_kbytes_handler (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +int overcommit_kbytes_handler (const struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) {int ret;
mm/vmstat.c +2 -2
@@ -74,7 +74,7 @@ static void invalid_numa_statistics(void)static DEFINE_MUTEX (vm_numa_stat_lock); -int sysctl_vm_numa_stat_handler (struct ctl_table *table,int write, +int sysctl_vm_numa_stat_handler (const struct ctl_table *table,int write,void *buffer,size_t *length,loff_t *ppos) {int ret, oldval;
@@ -1883,7 +1883,7 @@ static void refresh_vm_stats(struct work_struct *work)refresh_cpu_vm_stats (true); } -int vmstat_refresh (struct ctl_table *table,int write, +int vmstat_refresh (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {long val;
net/bridge/br_netfilter_hooks.c +1 -1
@@ -1048,7 +1048,7 @@ int br_nf_hook_thresh(unsigned int hook, struct net *net,#ifdef CONFIG_SYSCTL static -int brnf_sysctl_call_tables (struct ctl_table *ctl,int write, +int brnf_sysctl_call_tables (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
net/core/neighbour.c +12 -12
@@ -3531,7 +3531,7 @@ EXPORT_SYMBOL(neigh_app_ns);#ifdef CONFIG_SYSCTL static int unres_qlen_max =INT_MAX /SKB_TRUESIZE (ETH_FRAME_LEN ); -static int proc_unres_qlen (struct ctl_table *ctl,int write, +static int proc_unres_qlen (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int size, ret;
@@ -3566,7 +3566,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;
@@ -3583,9 +3583,9 @@ static void neigh_proc_update(struct ctl_table *ctl, int write)neigh_copy_dflt_parms (net, p, index); } -static int neigh_proc_dointvec_zero_intmax (struct ctl_table *ctl,int write, -void *buffer,size_t *lenp, -loff_t *ppos) +static int neigh_proc_dointvec_zero_intmax (const struct ctl_table *ctl, +int write,void *buffer, +size_t *lenp,loff_t *ppos) {struct ctl_table tmp = *ctl;int ret;
@@ -3598,7 +3598,7 @@ static int neigh_proc_dointvec_zero_intmax(struct ctl_table *ctl, int write,return ret; } -static int neigh_proc_dointvec_ms_jiffies_positive (struct ctl_table *ctl,int write, +static int neigh_proc_dointvec_ms_jiffies_positive (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct ctl_table tmp = *ctl;
@@ -3614,7 +3614,7 @@ static int neigh_proc_dointvec_ms_jiffies_positive(struct ctl_table *ctl, int wrreturn ret; } -int neigh_proc_dointvec (struct ctl_table *ctl,int write,void *buffer, +int neigh_proc_dointvec (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret =proc_dointvec (ctl, write, buffer, lenp, ppos);
@@ -3624,7 +3624,7 @@ int neigh_proc_dointvec(struct ctl_table *ctl, int write, void *buffer, }EXPORT_SYMBOL (neigh_proc_dointvec); -int neigh_proc_dointvec_jiffies (struct ctl_table *ctl,int write,void *buffer, +int neigh_proc_dointvec_jiffies (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret =proc_dointvec_jiffies (ctl, write, buffer, lenp, ppos);
@@ -3634,7 +3634,7 @@ int neigh_proc_dointvec_jiffies(struct ctl_table *ctl, int write, void *buffer, }EXPORT_SYMBOL (neigh_proc_dointvec_jiffies); -static int neigh_proc_dointvec_userhz_jiffies (struct ctl_table *ctl,int write, +static int neigh_proc_dointvec_userhz_jiffies (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -3644,7 +3644,7 @@ static int neigh_proc_dointvec_userhz_jiffies(struct ctl_table *ctl, int write,return ret; } -int neigh_proc_dointvec_ms_jiffies (struct ctl_table *ctl,int write, +int neigh_proc_dointvec_ms_jiffies (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret =proc_dointvec_ms_jiffies (ctl, write, buffer, lenp, ppos);
@@ -3654,7 +3654,7 @@ int neigh_proc_dointvec_ms_jiffies(struct ctl_table *ctl, int write, }EXPORT_SYMBOL (neigh_proc_dointvec_ms_jiffies); -static int neigh_proc_dointvec_unres_qlen (struct ctl_table *ctl,int write, +static int neigh_proc_dointvec_unres_qlen (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -3664,7 +3664,7 @@ static int neigh_proc_dointvec_unres_qlen(struct ctl_table *ctl, int write,return ret; } -static int neigh_proc_base_reachable_time (struct ctl_table *ctl,int write, +static int neigh_proc_base_reachable_time (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {
net/core/sysctl_net_core.c +10 -10
@@ -91,7 +91,7 @@ static struct cpumask *rps_default_mask_cow_alloc(struct net *net)return rps_default_mask; } -static int rps_default_mask_sysctl (struct ctl_table *table,int write, +static int rps_default_mask_sysctl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net = (struct net *)table->data;
@@ -122,7 +122,7 @@ static int rps_default_mask_sysctl(struct ctl_table *table, int write,return err; } -static int rps_sock_flow_sysctl (struct ctl_table *table,int write, +static int rps_sock_flow_sysctl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {unsigned int orig_size, size;
@@ -191,7 +191,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,#ifdef CONFIG_NET_FLOW_LIMIT static DEFINE_MUTEX (flow_limit_update_mutex); -static int flow_limit_cpu_sysctl (struct ctl_table *table,int write, +static int flow_limit_cpu_sysctl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct sd_flow_limit *cur;
@@ -248,7 +248,7 @@ static int flow_limit_cpu_sysctl(struct ctl_table *table, int write,return ret; } -static int flow_limit_table_len_sysctl (struct ctl_table *table,int write, +static int flow_limit_table_len_sysctl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {unsigned int old, *ptr;
@@ -270,7 +270,7 @@ static int flow_limit_table_len_sysctl(struct ctl_table *table, int write,#endif /* CONFIG_NET_FLOW_LIMIT */ #ifdef CONFIG_NET_SCHED -static int set_default_qdisc (struct ctl_table *table,int write, +static int set_default_qdisc (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {char id[IFNAMSIZ ];
@@ -289,7 +289,7 @@ static int set_default_qdisc(struct ctl_table *table, int write, }#endif -static int proc_do_dev_weight (struct ctl_table *table,int write, +static int proc_do_dev_weight (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {static DEFINE_MUTEX (dev_weight_mutex);
@@ -307,7 +307,7 @@ static int proc_do_dev_weight(struct ctl_table *table, int write,return ret; } -static int proc_do_rss_key (struct ctl_table *table,int write, +static int proc_do_rss_key (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct ctl_table fake_table;
@@ -320,7 +320,7 @@ static int proc_do_rss_key(struct ctl_table *table, int write, }#ifdef CONFIG_BPF_JIT -static int proc_dointvec_minmax_bpf_enable (struct ctl_table *table,int write, +static int proc_dointvec_minmax_bpf_enable (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -353,7 +353,7 @@ static int proc_dointvec_minmax_bpf_enable(struct ctl_table *table, int write,# ifdef CONFIG_HAVE_EBPF_JIT static int -proc_dointvec_minmax_bpf_restricted (struct ctl_table *table,int write, +proc_dointvec_minmax_bpf_restricted (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {if (!capable (CAP_SYS_ADMIN ))
@@ -364,7 +364,7 @@ proc_dointvec_minmax_bpf_restricted(struct ctl_table *table, int write,# endif /* CONFIG_HAVE_EBPF_JIT */ static int -proc_dolongvec_minmax_bpf_restricted (struct ctl_table *table,int write, +proc_dolongvec_minmax_bpf_restricted (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {if (!capable (CAP_SYS_ADMIN ))
net/ipv4/devinet.c +3 -3
@@ -2395,7 +2395,7 @@ static int devinet_conf_ifindex(struct net *net, struct ipv4_devconf *cnf) } } -static int devinet_conf_proc (struct ctl_table *ctl,int write, +static int devinet_conf_proc (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int old_value = *(int *)ctl->data;
@@ -2447,7 +2447,7 @@ static int devinet_conf_proc(struct ctl_table *ctl, int write,return ret; } -static int devinet_sysctl_forward (struct ctl_table *ctl,int write, +static int devinet_sysctl_forward (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int *valp = ctl->data;
@@ -2494,7 +2494,7 @@ static int devinet_sysctl_forward(struct ctl_table *ctl, int write,return ret; } -static int ipv4_doint_and_flush (struct ctl_table *ctl,int write, +static int ipv4_doint_and_flush (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int *valp = ctl->data;
net/ipv4/route.c +1 -1
@@ -3408,7 +3408,7 @@ static int ip_rt_gc_min_interval __read_mostly = HZ / 2;static int ip_rt_gc_elasticity__read_mostly =8 ;static int ip_min_valid_pmtu__read_mostly =IPV4_MIN_MTU ; -static int ipv4_sysctl_rtcache_flush (struct ctl_table *__ctl,int write, +static int ipv4_sysctl_rtcache_flush (const struct ctl_table *__ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net = (struct net *)__ctl->extra1;
net/ipv4/sysctl_net_ipv4.c +17 -16
@@ -65,7 +65,7 @@ static void set_local_port_range(struct net *net, int range[2]) }/* Validate changes from /proc interface. */ -static int ipv4_local_port_range (struct ctl_table *table,int write, +static int ipv4_local_port_range (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { struct net *net =
@@ -100,7 +100,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write, }/* Validate changes from /proc interface. */ -static int ipv4_privileged_ports (struct ctl_table *table,int write, +static int ipv4_privileged_ports (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { struct net *net = container_of(table->data, struct net,
@@ -134,7 +134,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 =
@@ -149,7 +150,7 @@ 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 =
@@ -161,7 +162,7 @@ static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t hig }/* Validate changes from /proc interface. */ -static int ipv4_ping_group_range (struct ctl_table *table,int write, +static int ipv4_ping_group_range (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct user_namespace *user_ns =current_user_ns ();
@@ -196,7 +197,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,return ret; } -static int ipv4_fwd_update_priority (struct ctl_table *table,int write, +static int ipv4_fwd_update_priority (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net;
@@ -212,7 +213,7 @@ static int ipv4_fwd_update_priority(struct ctl_table *table, int write,return ret; } -static int proc_tcp_congestion_control (struct ctl_table *ctl,int write, +static int proc_tcp_congestion_control (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) { struct net *net = container_of(ctl->data, struct net,
@@ -232,7 +233,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,return ret; } -static int proc_tcp_available_congestion_control (struct ctl_table *ctl, +static int proc_tcp_available_congestion_control (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -248,7 +249,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,return ret; } -static int proc_allowed_congestion_control (struct ctl_table *ctl, +static int proc_allowed_congestion_control (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -285,7 +286,7 @@ static int sscanf_key(char *buf, __le32 *key)return ret; } -static int proc_tcp_fastopen_key (struct ctl_table *table,int write, +static int proc_tcp_fastopen_key (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { struct net *net = container_of(table->data, struct net,
@@ -356,7 +357,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *table, int write,return ret; } -static int proc_tfo_blackhole_detect_timeout (struct ctl_table *table, +static int proc_tfo_blackhole_detect_timeout (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -371,7 +372,7 @@ static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table,return ret; } -static int proc_tcp_available_ulp (struct ctl_table *ctl, +static int proc_tcp_available_ulp (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -388,7 +389,7 @@ static int proc_tcp_available_ulp(struct ctl_table *ctl,return ret; } -static int proc_tcp_ehash_entries (struct ctl_table *table,int write, +static int proc_tcp_ehash_entries (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { struct net *net = container_of(table->data, struct net,
@@ -412,7 +413,7 @@ static int proc_tcp_ehash_entries(struct ctl_table *table, int write,return proc_dointvec (&tbl, write, buffer, lenp, ppos); } -static int proc_udp_hash_entries (struct ctl_table *table,int write, +static int proc_udp_hash_entries (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) { struct net *net = container_of(table->data, struct net,
@@ -436,7 +437,7 @@ static int proc_udp_hash_entries(struct ctl_table *table, int write, }#ifdef CONFIG_IP_ROUTE_MULTIPATH -static int proc_fib_multipath_hash_policy (struct ctl_table *table,int write, +static int proc_fib_multipath_hash_policy (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -451,7 +452,7 @@ static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write,return ret; } -static int proc_fib_multipath_hash_fields (struct ctl_table *table,int write, +static int proc_fib_multipath_hash_fields (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {
net/ipv6/addrconf.c +14 -13
@@ -859,7 +859,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;
@@ -927,7 +927,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;
@@ -6258,7 +6258,7 @@ static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)#ifdef CONFIG_SYSCTL -static int addrconf_sysctl_forward (struct ctl_table *ctl,int write, +static int addrconf_sysctl_forward (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int *valp = ctl->data;
@@ -6283,7 +6283,7 @@ static int addrconf_sysctl_forward(struct ctl_table *ctl, int write,return ret; } -static int addrconf_sysctl_mtu (struct ctl_table *ctl,int write, +static int addrconf_sysctl_mtu (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct inet6_dev *idev = ctl->extra1;
@@ -6327,7 +6327,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;int old;
@@ -6354,7 +6354,7 @@ static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int newf)return 0 ; } -static int addrconf_sysctl_disable (struct ctl_table *ctl,int write, +static int addrconf_sysctl_disable (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int *valp = ctl->data;
@@ -6379,7 +6379,7 @@ static int addrconf_sysctl_disable(struct ctl_table *ctl, int write,return ret; } -static int addrconf_sysctl_proxy_ndp (struct ctl_table *ctl,int write, +static int addrconf_sysctl_proxy_ndp (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int *valp = ctl->data;
@@ -6420,7 +6420,7 @@ static int addrconf_sysctl_proxy_ndp(struct ctl_table *ctl, int write,return ret; } -static int addrconf_sysctl_addr_gen_mode (struct ctl_table *ctl,int write, +static int addrconf_sysctl_addr_gen_mode (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -6482,7 +6482,7 @@ static int addrconf_sysctl_addr_gen_mode(struct ctl_table *ctl, int write,return ret; } -static int addrconf_sysctl_stable_secret (struct ctl_table *ctl,int write, +static int addrconf_sysctl_stable_secret (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -6549,7 +6549,7 @@ static int addrconf_sysctl_stable_secret(struct ctl_table *ctl, int write, }static -int addrconf_sysctl_ignore_routes_with_linkdown (struct ctl_table *ctl, +int addrconf_sysctl_ignore_routes_with_linkdown (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos)
@@ -6617,7 +6617,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 inet6_dev *idev;struct net *net;
@@ -6650,8 +6650,9 @@ int addrconf_disable_policy(struct ctl_table *ctl, int *valp, int val)return 0 ; } -static int addrconf_sysctl_disable_policy (struct ctl_table *ctl,int write, -void *buffer,size_t *lenp,loff_t *ppos) +static int addrconf_sysctl_disable_policy (const struct ctl_table *ctl, +int write,void *buffer,size_t *lenp, +loff_t *ppos) {int *valp = ctl->data;int val = *valp;
net/ipv6/ndisc.c +2 -2
@@ -1922,7 +1922,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 ];
@@ -1937,7 +1937,7 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl, } } -int ndisc_ifinfo_sysctl_change (struct ctl_table *ctl,int write,void *buffer, +int ndisc_ifinfo_sysctl_change (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net_device *dev = ctl->extra1;
net/ipv6/route.c +1 -1
@@ -6325,7 +6325,7 @@ static int rt6_stats_seq_show(struct seq_file *seq, void *v)#ifdef CONFIG_SYSCTL -static int ipv6_sysctl_rtcache_flush (struct ctl_table *ctl,int write, +static int ipv6_sysctl_rtcache_flush (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net;
net/ipv6/sysctl_net_ipv6.c +2 -2
@@ -30,7 +30,7 @@ static u32 rt6_multipath_hash_fields_all_mask =static u32 ioam6_id_max =IOAM6_DEFAULT_ID ;static u64 ioam6_id_wide_max =IOAM6_DEFAULT_ID_WIDE ; -static int proc_rt6_multipath_hash_policy (struct ctl_table *table,int write, +static int proc_rt6_multipath_hash_policy (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net;
@@ -46,7 +46,7 @@ static int proc_rt6_multipath_hash_policy(struct ctl_table *table, int write, }static int -proc_rt6_multipath_hash_fields (struct ctl_table *table,int write,void *buffer, +proc_rt6_multipath_hash_fields (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net;
net/mpls/af_mpls.c +2 -2
@@ -1363,7 +1363,7 @@ static int mpls_netconf_dump_devconf(struct sk_buff *skb,#define MPLS_PERDEV_SYSCTL_OFFSET (field) \ (&((struct mpls_dev *)0)->field) -static int mpls_conf_proc (struct ctl_table *ctl,int write, +static int mpls_conf_proc (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {int oval = *(int *)ctl->data;
@@ -2615,7 +2615,7 @@ static int resize_platform_label_table(struct net *net, size_t limit)return -ENOMEM ; } -static int mpls_platform_labels (struct ctl_table *table,int write, +static int mpls_platform_labels (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net = table->data;
net/netfilter/ipvs/ip_vs_ctl.c +8 -8
@@ -1846,7 +1846,7 @@ static int ip_vs_zero_all(struct netns_ipvs *ipvs)#ifdef CONFIG_SYSCTL static int -proc_do_defense_mode (struct ctl_table *table,int write, +proc_do_defense_mode (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct netns_ipvs *ipvs = table->extra2;
@@ -1873,7 +1873,7 @@ proc_do_defense_mode(struct ctl_table *table, int write, }static int -proc_do_sync_threshold (struct ctl_table *table,int write, +proc_do_sync_threshold (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct netns_ipvs *ipvs = table->extra2;
@@ -1901,7 +1901,7 @@ proc_do_sync_threshold(struct ctl_table *table, int write, }static int -proc_do_sync_ports (struct ctl_table *table,int write, +proc_do_sync_ports (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int *valp = table->data;
@@ -1924,7 +1924,7 @@ 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,7 +1962,7 @@ 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, +static int ipvs_proc_est_cpumask_get (const struct ctl_table *table,void *buffer,size_t size) {struct netns_ipvs *ipvs = table->extra2;
@@ -1983,7 +1983,7 @@ static int ipvs_proc_est_cpumask_get(struct ctl_table *table, void *buffer,return ret; } -static int ipvs_proc_est_cpulist (struct ctl_table *table,int write, +static int ipvs_proc_est_cpulist (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
@@ -2010,7 +2010,7 @@ static int ipvs_proc_est_cpulist(struct ctl_table *table, int write,return ret; } -static int ipvs_proc_est_nice (struct ctl_table *table,int write, +static int ipvs_proc_est_nice (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct netns_ipvs *ipvs = table->extra2;
@@ -2040,7 +2040,7 @@ static int ipvs_proc_est_nice(struct ctl_table *table, int write,return ret; } -static int ipvs_proc_run_estimation (struct ctl_table *table,int write, +static int ipvs_proc_run_estimation (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct netns_ipvs *ipvs = table->extra2;
net/netfilter/nf_conntrack_standalone.c +1 -1
@@ -527,7 +527,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_count);static unsigned int nf_conntrack_htable_size_user__read_mostly ;static int -nf_conntrack_hash_sysctl (struct ctl_table *table,int write, +nf_conntrack_hash_sysctl (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
net/netfilter/nf_hooks_lwtunnel.c +1 -1
@@ -25,7 +25,7 @@ static inline int nf_hooks_lwtunnel_set(int enable) }#ifdef CONFIG_SYSCTL -int nf_hooks_lwtunnel_sysctl_handler (struct ctl_table *table,int write, +int nf_hooks_lwtunnel_sysctl_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int proc_nf_hooks_lwtunnel_enabled =0 ;
net/netfilter/nf_log.c +1 -1
@@ -403,7 +403,7 @@ static struct ctl_table nf_log_sysctl_ftable[] = { { } }; -static int nf_log_proc_dostring (struct ctl_table *table,int write, +static int nf_log_proc_dostring (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {const struct nf_logger *logger;
net/phonet/sysctl.c +1 -1
@@ -48,7 +48,7 @@ void phonet_get_local_port_range(int *min, int *max) }while (read_seqretry (&local_port_range_lock, seq)); } -static int proc_local_port_range (struct ctl_table *table,int write, +static int proc_local_port_range (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
net/rds/tcp.c +2 -2
@@ -61,7 +61,7 @@ static atomic_t rds_tcp_unloading = ATOMIC_INIT(0);static struct kmem_cache *rds_tcp_conn_slab; -static int rds_tcp_skbuf_handler (struct ctl_table *ctl,int write, +static int rds_tcp_skbuf_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *fpos);static int rds_tcp_min_sndbuf =SOCK_MIN_SNDBUF ;
@@ -683,7 +683,7 @@ static void rds_tcp_sysctl_reset(struct net *net)spin_unlock_irq (&rds_tcp_conn_lock); } -static int rds_tcp_skbuf_handler (struct ctl_table *ctl,int write, +static int rds_tcp_skbuf_handler (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *fpos) {struct net *net = current->nsproxy->net_ns;
net/sctp/sysctl.c +14 -14
@@ -43,19 +43,19 @@ static unsigned long max_autoclose_max = (MAX_SCHEDULE_TIMEOUT /HZ >UINT_MAX ) ?UINT_MAX :MAX_SCHEDULE_TIMEOUT /HZ ; -static int proc_sctp_do_hmac_alg (struct ctl_table *ctl,int write, +static int proc_sctp_do_hmac_alg (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos); -static int proc_sctp_do_rto_min (struct ctl_table *ctl,int write, +static int proc_sctp_do_rto_min (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos); -static int proc_sctp_do_rto_max (struct ctl_table *ctl,int write,void *buffer, +static int proc_sctp_do_rto_max (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos); -static int proc_sctp_do_udp_port (struct ctl_table *ctl,int write,void *buffer, +static int proc_sctp_do_udp_port (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos); -static int proc_sctp_do_alpha_beta (struct ctl_table *ctl,int write, +static int proc_sctp_do_alpha_beta (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos); -static int proc_sctp_do_auth (struct ctl_table *ctl,int write, +static int proc_sctp_do_auth (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos); -static int proc_sctp_do_probe_interval (struct ctl_table *ctl,int write, +static int proc_sctp_do_probe_interval (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos);static struct ctl_table sctp_table[] = {
@@ -388,7 +388,7 @@ static struct ctl_table sctp_net_table[] = { {/* sentinel */ } }; -static int proc_sctp_do_hmac_alg (struct ctl_table *ctl,int write, +static int proc_sctp_do_hmac_alg (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net = current->nsproxy->net_ns;
@@ -433,7 +433,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,return ret; } -static int proc_sctp_do_rto_min (struct ctl_table *ctl,int write, +static int proc_sctp_do_rto_min (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net = current->nsproxy->net_ns;
@@ -461,7 +461,7 @@ static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,return ret; } -static int proc_sctp_do_rto_max (struct ctl_table *ctl,int write, +static int proc_sctp_do_rto_max (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net = current->nsproxy->net_ns;
@@ -489,7 +489,7 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,return ret; } -static int proc_sctp_do_alpha_beta (struct ctl_table *ctl,int write, +static int proc_sctp_do_alpha_beta (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {if (write)
@@ -499,7 +499,7 @@ static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,return proc_dointvec_minmax (ctl, write, buffer, lenp, ppos); } -static int proc_sctp_do_auth (struct ctl_table *ctl,int write, +static int proc_sctp_do_auth (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net = current->nsproxy->net_ns;
@@ -528,7 +528,7 @@ static int proc_sctp_do_auth(struct ctl_table *ctl, int write,return ret; } -static int proc_sctp_do_udp_port (struct ctl_table *ctl,int write, +static int proc_sctp_do_udp_port (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net = current->nsproxy->net_ns;
@@ -569,7 +569,7 @@ static int proc_sctp_do_udp_port(struct ctl_table *ctl, int write,return ret; } -static int proc_sctp_do_probe_interval (struct ctl_table *ctl,int write, +static int proc_sctp_do_probe_interval (const struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct net *net = current->nsproxy->net_ns;
net/sunrpc/sysctl.c +3 -3
@@ -40,7 +40,7 @@ EXPORT_SYMBOL_GPL(nlm_debug);#if IS_ENABLED (CONFIG_SUNRPC_DEBUG ) -static int proc_do_xprt (struct ctl_table *table,int write, +static int proc_do_xprt (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {char tmpbuf[256 ];
@@ -62,8 +62,8 @@ static int proc_do_xprt(struct ctl_table *table, int write, }static int -proc_dodebug (struct ctl_table *table,int write,void *buffer,size_t *lenp, -loff_t *ppos) +proc_dodebug (const struct ctl_table *table,int write,void *buffer, +size_t *lenp,loff_t *ppos) {char tmpbuf[20 ], *s =NULL ;char *p;
net/sunrpc/xprtrdma/svc_rdma.c +1 -1
@@ -74,7 +74,7 @@ enum { SVCRDMA_COUNTER_BUFSIZ = sizeof(unsigned long long), }; -static int svcrdma_counter_handler (struct ctl_table *table,int write, +static int svcrdma_counter_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct percpu_counter *stat = (struct percpu_counter *)table->data;
security/apparmor/lsm.c +1 -1
@@ -1980,7 +1980,7 @@ static int __init alloc_buffers(void) }#ifdef CONFIG_SYSCTL -static int apparmor_dointvec (struct ctl_table *table,int write, +static int apparmor_dointvec (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {if (!aa_current_policy_admin_capable (NULL ))
security/min_addr.c +1 -1
@@ -29,7 +29,7 @@ static void update_mmap_min_addr(void)* sysctl handler which just sets dac_mmap_min_addr = the new value and then * calls update_mmap_min_addr() so non MAP_FIXED hints get rounded properly */ -int mmap_min_addr_handler (struct ctl_table *table,int write, +int mmap_min_addr_handler (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {int ret;
security/yama/yama_lsm.c +1 -1
@@ -429,7 +429,7 @@ static struct security_hook_list yama_hooks[] __ro_after_init = { };#ifdef CONFIG_SYSCTL -static int yama_dointvec_minmax (struct ctl_table *table,int write, +static int yama_dointvec_minmax (const struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {struct ctl_table table_copy;
Signature · 1 line
2.43.0
Re: [PATCH v2 12/18] sysctl: treewide: constify the ctl_table argument of handlers
Quoted 5 lines · Thomas Weißschuh
In a future commit the sysctl core will only use
"const structctl_table". As a preparation for that adapt all the proc handlers.Signed-off-by Thomas Weißschuh <[email protected]>
Signature · 1 line
Kees Cook
kernel test robot
build botRe: [PATCH v2 12/18] sysctl: treewide: constify the ctl_table argument of handlers
In reply to Thomas Weißschuhkernel test robot noticed the following build errors:
Hi Thomas,
kernel test robot noticed the following build errors:
[auto build test ERROR on netfilter-nf/main]
[also build test ERROR on akpm-mm/mm-everything linus/master v6.7-rc4] [cannot apply to nf-next/master next-20231205]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Thomas-Wei-schuh/sysctl-delete-unused-define-SYSCTL_PERM_EMPTY_DIR/20231204-165306 base: git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git main patch link: https://lore.kernel.org/r/20231204-const-sysctl-v2-12-7a5060b11447%40weissschuh.net patch subject: [PATCH v2 12/18] sysctl: treewide: constify the ctl_table argument of handlers config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20231205/[email protected]/config) compiler: s390-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231205/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
arch/s390/appldata/appldata_base.c: In function 'appldata_register_ops':
>> arch/s390/appldata/appldata_base.c:363:40: error: assignment to 'int (*)(const struct ctl_table *, int, void *, size_t *, loff_t *)' {aka 'int (*)(const struct ctl_table *, int, void *, long unsigned int *, long long int *)'} from incompatible pointer type 'int (*)(struct ctl_table *, int, void *, size_t *, loff_t *)' {aka 'int (*)(struct ctl_table *, int, void *, long unsigned int *, long long int *)'} [-Werror=incompatible-pointer-types]
363 | ops->ctl_table[0].proc_handler = appldata_generic_handler;
| ^cc1: some warnings being treated as errors
vim +363 arch/s390/appldata/appldata_base.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 340
^1da177e4c3f41 Linus Torvalds 2005-04-16 341
^1da177e4c3f41 Linus Torvalds 2005-04-16 342 /************************* module-ops management *****************************/
^1da177e4c3f41 Linus Torvalds 2005-04-16 343 /*
^1da177e4c3f41 Linus Torvalds 2005-04-16 344 * appldata_register_ops()
^1da177e4c3f41 Linus Torvalds 2005-04-16 345 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 346 * update ops list, register /proc/sys entries
^1da177e4c3f41 Linus Torvalds 2005-04-16 347 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 348 int appldata_register_ops(struct appldata_ops *ops)
^1da177e4c3f41 Linus Torvalds 2005-04-16 349 {
13f8b7c5e6fa13 Roel Kluin 2008-10-28 350 if (ops->size > APPLDATA_MAX_REC_SIZE)
37e3a6ac5a3046 Heiko Carstens 2007-11-20 351 return -EINVAL;
^1da177e4c3f41 Linus Torvalds 2005-04-16 352
fdd9da76e2dec0 Joel Granados 2023-10-02 353 ops->ctl_table = kcalloc(1, sizeof(struct ctl_table), GFP_KERNEL);
37e3a6ac5a3046 Heiko Carstens 2007-11-20 354 if (!ops->ctl_table)
^1da177e4c3f41 Linus Torvalds 2005-04-16 355 return -ENOMEM;
^1da177e4c3f41 Linus Torvalds 2005-04-16 356
b1ad171efa089a Gerald Schaefer 2009-04-23 357 mutex_lock(&appldata_ops_mutex);
^1da177e4c3f41 Linus Torvalds 2005-04-16 358 list_add(&ops->list, &appldata_ops_list);
b1ad171efa089a Gerald Schaefer 2009-04-23 359 mutex_unlock(&appldata_ops_mutex);
^1da177e4c3f41 Linus Torvalds 2005-04-16 360
7db12246306ea6 Luis Chamberlain 2023-03-10 361 ops->ctl_table[0].procname = ops->name;
7db12246306ea6 Luis Chamberlain 2023-03-10 362 ops->ctl_table[0].mode = S_IRUGO | S_IWUSR;
7db12246306ea6 Luis Chamberlain 2023-03-10 @363 ops->ctl_table[0].proc_handler = appldata_generic_handler;
7db12246306ea6 Luis Chamberlain 2023-03-10 364 ops->ctl_table[0].data = ops;
^1da177e4c3f41 Linus Torvalds 2005-04-16 365
9edbfe92a0a135 Joel Granados 2023-08-09 366 ops->sysctl_header = register_sysctl_sz(appldata_proc_name, ops->ctl_table, 1);
37e3a6ac5a3046 Heiko Carstens 2007-11-20 367 if (!ops->sysctl_header)
37e3a6ac5a3046 Heiko Carstens 2007-11-20 368 goto out;
^1da177e4c3f41 Linus Torvalds 2005-04-16 369 return 0;
37e3a6ac5a3046 Heiko Carstens 2007-11-20 370 out:
b1ad171efa089a Gerald Schaefer 2009-04-23 371 mutex_lock(&appldata_ops_mutex);
37e3a6ac5a3046 Heiko Carstens 2007-11-20 372 list_del(&ops->list);
b1ad171efa089a Gerald Schaefer 2009-04-23 373 mutex_unlock(&appldata_ops_mutex);
37e3a6ac5a3046 Heiko Carstens 2007-11-20 374 kfree(ops->ctl_table);
37e3a6ac5a3046 Heiko Carstens 2007-11-20 375 return -ENOMEM;
^1da177e4c3f41 Linus Torvalds 2005-04-16 376 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 377 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v2 12/18] sysctl: treewide: constify the ctl_table argument of handlers
In reply to Thomas Weißschuhkernel test robot noticed the following build errors:
Hi Thomas,
kernel test robot noticed the following build errors:
[auto build test ERROR on netfilter-nf/main]
[also build test ERROR on akpm-mm/mm-everything linus/master v6.7-rc4] [cannot apply to nf-next/master next-20231205]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Thomas-Wei-schuh/sysctl-delete-unused-define-SYSCTL_PERM_EMPTY_DIR/20231204-165306 base: git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git main patch link: https://lore.kernel.org/r/20231204-const-sysctl-v2-12-7a5060b11447%40weissschuh.net patch subject: [PATCH v2 12/18] sysctl: treewide: constify the ctl_table argument of handlers config: arm64-defconfig (https://download.01.org/0day-ci/archive/20231205/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231205/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
| ^~~~~~
drivers/perf/arm_pmuv3.c:144:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_RD'
144 | [C(L1D)][C(OP_READ)][C(RESULT_MISS)] = ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_RD,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:122:65: warning: initialized field overwritten [-Woverride-init]
122 | #define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WR 0x0041
| ^~~~~~
drivers/perf/arm_pmuv3.c:145:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WR'
145 | [C(L1D)][C(OP_WRITE)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WR,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:122:65: note: (near initialization for 'armv8_vulcan_perf_cache_map[0][1][0]')
122 | #define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WR 0x0041
| ^~~~~~
drivers/perf/arm_pmuv3.c:145:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WR'
145 | [C(L1D)][C(OP_WRITE)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_L1D_CACHE_WR,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:124:65: warning: initialized field overwritten [-Woverride-init]
124 | #define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_WR 0x0043
| ^~~~~~
drivers/perf/arm_pmuv3.c:146:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_WR'
146 | [C(L1D)][C(OP_WRITE)][C(RESULT_MISS)] = ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_WR,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:124:65: note: (near initialization for 'armv8_vulcan_perf_cache_map[0][1][1]')
124 | #define ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_WR 0x0043
| ^~~~~~
drivers/perf/arm_pmuv3.c:146:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_WR'
146 | [C(L1D)][C(OP_WRITE)][C(RESULT_MISS)] = ARMV8_IMPDEF_PERFCTR_L1D_CACHE_REFILL_WR,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:133:65: warning: initialized field overwritten [-Woverride-init]
133 | #define ARMV8_IMPDEF_PERFCTR_L1D_TLB_RD 0x004E
| ^~~~~~
drivers/perf/arm_pmuv3.c:148:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_TLB_RD'
148 | [C(DTLB)][C(OP_READ)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_L1D_TLB_RD,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:133:65: note: (near initialization for 'armv8_vulcan_perf_cache_map[3][0][0]')
133 | #define ARMV8_IMPDEF_PERFCTR_L1D_TLB_RD 0x004E
| ^~~~~~
drivers/perf/arm_pmuv3.c:148:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_TLB_RD'
148 | [C(DTLB)][C(OP_READ)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_L1D_TLB_RD,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:134:65: warning: initialized field overwritten [-Woverride-init]
134 | #define ARMV8_IMPDEF_PERFCTR_L1D_TLB_WR 0x004F
| ^~~~~~
drivers/perf/arm_pmuv3.c:149:52: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_TLB_WR'
149 | [C(DTLB)][C(OP_WRITE)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_L1D_TLB_WR,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:134:65: note: (near initialization for 'armv8_vulcan_perf_cache_map[3][1][0]')
134 | #define ARMV8_IMPDEF_PERFCTR_L1D_TLB_WR 0x004F
| ^~~~~~
drivers/perf/arm_pmuv3.c:149:52: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_TLB_WR'
149 | [C(DTLB)][C(OP_WRITE)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_L1D_TLB_WR,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:131:65: warning: initialized field overwritten [-Woverride-init]
131 | #define ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_RD 0x004C
| ^~~~~~
drivers/perf/arm_pmuv3.c:150:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_RD'
150 | [C(DTLB)][C(OP_READ)][C(RESULT_MISS)] = ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_RD,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:131:65: note: (near initialization for 'armv8_vulcan_perf_cache_map[3][0][1]')
131 | #define ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_RD 0x004C
| ^~~~~~
drivers/perf/arm_pmuv3.c:150:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_RD'
150 | [C(DTLB)][C(OP_READ)][C(RESULT_MISS)] = ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_RD,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:132:65: warning: initialized field overwritten [-Woverride-init]
132 | #define ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_WR 0x004D
| ^~~~~~
drivers/perf/arm_pmuv3.c:151:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_WR'
151 | [C(DTLB)][C(OP_WRITE)][C(RESULT_MISS)] = ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_WR,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:132:65: note: (near initialization for 'armv8_vulcan_perf_cache_map[3][1][1]')
132 | #define ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_WR 0x004D
| ^~~~~~
drivers/perf/arm_pmuv3.c:151:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_WR'
151 | [C(DTLB)][C(OP_WRITE)][C(RESULT_MISS)] = ARMV8_IMPDEF_PERFCTR_L1D_TLB_REFILL_WR,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:148:65: warning: initialized field overwritten [-Woverride-init]
148 | #define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_RD 0x0060
| ^~~~~~
drivers/perf/arm_pmuv3.c:153:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_RD'
153 | [C(NODE)][C(OP_READ)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_RD,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:148:65: note: (near initialization for 'armv8_vulcan_perf_cache_map[6][0][0]')
148 | #define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_RD 0x0060
| ^~~~~~
drivers/perf/arm_pmuv3.c:153:51: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_RD'
153 | [C(NODE)][C(OP_READ)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_RD,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:149:65: warning: initialized field overwritten [-Woverride-init]
149 | #define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_WR 0x0061
| ^~~~~~
drivers/perf/arm_pmuv3.c:154:52: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_WR'
154 | [C(NODE)][C(OP_WRITE)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_WR,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/perf/arm_pmuv3.h:149:65: note: (near initialization for 'armv8_vulcan_perf_cache_map[6][1][0]')
149 | #define ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_WR 0x0061
| ^~~~~~
drivers/perf/arm_pmuv3.c:154:52: note: in expansion of macro 'ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_WR'
154 | [C(NODE)][C(OP_WRITE)][C(RESULT_ACCESS)] = ARMV8_IMPDEF_PERFCTR_BUS_ACCESS_WR,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/perf/arm_pmuv3.c:1174:35: error: initialization of 'int (*)(const struct ctl_table *, int, void *, size_t *, loff_t *)' {aka 'int (*)(const struct ctl_table *, int, void *, long unsigned int *, long long int *)'} from incompatible pointer type 'int (*)(struct ctl_table *, int, void *, size_t *, loff_t *)' {aka 'int (*)(struct ctl_table *, int, void *, long unsigned int *, long long int *)'} [-Werror=incompatible-pointer-types] 1174 | .proc_handler = armv8pmu_proc_user_access_handler,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/perf/arm_pmuv3.c:1174:35: note: (near initialization for 'armv8_pmu_sysctl_table[0].proc_handler')
cc1: some warnings being treated as errors
vim +1174 drivers/perf/arm_pmuv3.c
83a7a4d643d33a arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1167
e2012600810c9d arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1168 static struct ctl_table armv8_pmu_sysctl_table[] = {
e2012600810c9d arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1169 {
e2012600810c9d arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1170 .procname = "perf_user_access",
e2012600810c9d arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1171 .data = &sysctl_perf_user_access,
e2012600810c9d arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1172 .maxlen = sizeof(unsigned int),
e2012600810c9d arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1173 .mode = 0644,
83a7a4d643d33a arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 @1174 .proc_handler = armv8pmu_proc_user_access_handler,
e2012600810c9d arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1175 .extra1 = SYSCTL_ZERO,
e2012600810c9d arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1176 .extra2 = SYSCTL_ONE,
e2012600810c9d arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1177 },
e2012600810c9d arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1178 };e2012600810c9d arch/arm64/kernel/perf_event.c Rob Herring 2021-12-08 1179
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v2 13/18 sysctl: move sysctl type to ctl_table_header
In reply to Thomas WeißschuhIn a future commit the sysctl core will only use
"const struct ctl_table". As a preparation for that move this mutable field from "struct ctl_table" to "struct ctl_table_header".
This is also more correct in general as this is in fact a property of the header and not the table itself.
--- fs/proc/proc_sysctl.c | 11 ++++++----- include/linux/sysctl.h | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-)
fs/proc/proc_sysctl.c +6 -5
@@ -31,7 +31,7 @@ static const struct inode_operations proc_sys_dir_operations;/* Support for permanently empty directories */ static struct ctl_table sysctl_mount_point[] = { - {.type =SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY } + { } };/**
@@ -49,11 +49,11 @@ struct ctl_table_header *register_sysctl_mount_point(const char *path)EXPORT_SYMBOL (register_sysctl_mount_point);#define sysctl_is_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) + (hptr->type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY)#define sysctl_set_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) + (hptr->type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY)#define sysctl_clear_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_DEFAULT) + (hptr->type = SYSCTL_TABLE_TYPE_DEFAULT)void proc_sys_poll_notify (struct ctl_table_poll *poll) {
@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)return -EROFS ;/* Am I creating a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (header)) { +if (header->ctl_table == sysctl_mount_point || +sysctl_is_perm_empty_ctl_header (header)) {if (!RB_EMPTY_ROOT (&dir->root))return -EINVAL ;sysctl_set_perm_empty_ctl_header (dir_h);
include/linux/sysctl.h +11 -11
@@ -137,17 +137,6 @@ struct ctl_table {void *data;int maxlen;umode_t mode; -/** -* enum type - Enumeration to differentiate between ctl target types -* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations -* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently -* empty directory target to serve -* as mount point. -*/ -enum { -SYSCTL_TABLE_TYPE_DEFAULT , -SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY - } type;proc_handler *proc_handler;/* Callback for text formatting */ struct ctl_table_poll *poll;void *extra1;
@@ -188,6 +177,17 @@ struct ctl_table_header {struct ctl_dir *parent;struct ctl_node *node;struct hlist_head inodes;/* head for proc_inode->sysctl_inodes */ +/** +* enum type - Enumeration to differentiate between ctl target types +* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations +* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently +* empty directory target to serve +* as mount point. +*/ +enum { +SYSCTL_TABLE_TYPE_DEFAULT , +SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY + } type; };struct ctl_dir {
Signature · 1 line
2.43.0
Luis Chamberlain
maintainerRe: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header
fs/proc/proc_sysctl.c static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) · line 238
Quoted 10 lines · Thomas Weißschuh
fs/proc/proc_sysctl.c +2
-1@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)return -EROFS ;/* Am I creating a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (header)) { +if (header->ctl_table == sysctl_mount_point || +sysctl_is_perm_empty_ctl_header (header)) {if (!RB_EMPTY_ROOT (&dir->root))return -EINVAL ;sysctl_set_perm_empty_ctl_header (dir_h);
While you're at it.
This just made me cringe, and curious if some other changes could be done to make this obviously clear during patch review that this is safe.
Luis
Re: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header
Quoted 4 lines · Luis Chamberlain
Quoted 3 lines · Thomas Weißschuh
fs/proc/proc_sysctl.c +0
-0@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)return -EROFS ;
Quoted 9 lines
fs/proc/proc_sysctl.c static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) · line 238
Quoted 7 lines
fs/proc/proc_sysctl.c +2
-1/* Am I creating a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (header)) { +if (header->ctl_table == sysctl_mount_point || +sysctl_is_perm_empty_ctl_header (header)) {if (!RB_EMPTY_ROOT (&dir->root))return -EINVAL ;sysctl_set_perm_empty_ctl_header (dir_h);While you're at it.
This hunk is completely gone in v3/the code that you merged.
Quoted 3 lines
This just made me cringe, and curious if some other changes could be done to make this obviously clear during patch review that this is safe.
Which kind of unsafety do you envision here?
Luis Chamberlain
maintainerRe: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header
Quoted 16 lines · Thomas Weißschuh
Quoted 4 lines · Luis Chamberlain
Quoted 3 lines · Thomas Weißschuh
fs/proc/proc_sysctl.c +0
-0@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)return -EROFS ;Quoted 9 lines
fs/proc/proc_sysctl.c static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) · line 238
Quoted 7 lines
fs/proc/proc_sysctl.c +2
-1/* Am I creating a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (header)) { +if (header->ctl_table == sysctl_mount_point || +sysctl_is_perm_empty_ctl_header (header)) {if (!RB_EMPTY_ROOT (&dir->root))return -EINVAL ;sysctl_set_perm_empty_ctl_header (dir_h);While you're at it.
Quoted 1 line
This hunk is completely gone in v3/the code that you merged.
It is worse in that it is not obvious:
+ if (table == sysctl_mount_point)
+ sysctl_set_perm_empty_ctl_header(head);
Quoted 1 line
Which kind of unsafety do you envision here?
Making the code obvious during patch review hy this is needed / special, and if we special case this, why not remove enum, and make it specific to only that one table. The catch is that it is not immediately obvious that we actually call sysctl_set_perm_empty_ctl_header() in other places, and it begs the question if this can be cleaned up somehow.
Luis
Re: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header
Quoted 24 lines · Luis Chamberlain
Quoted 16 lines · Thomas Weißschuh
Quoted 4 lines · Luis Chamberlain
Quoted 3 lines · Thomas Weißschuh
(quoted diff) +0
-0@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) return -EROFS;Quoted 9 lines
Review static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) · line 238
Quoted 7 lines
(quoted diff) +2
-1/* Am I creating a permanently empty directory? */ - if (sysctl_is_perm_empty_ctl_header(header)) { + if (header->ctl_table == sysctl_mount_point || + sysctl_is_perm_empty_ctl_header(header)) { if (!RB_EMPTY_ROOT(&dir->root)) return -EINVAL; sysctl_set_perm_empty_ctl_header(dir_h);While you're at it.
Quoted 1 line
This hunk is completely gone in v3/the code that you merged.
It is worse in that it is not obvious:
(quoted diff) +2
-0+ if (table == sysctl_mount_point) + sysctl_set_perm_empty_ctl_header(head);
Quoted 8 lines
Quoted 1 line
Which kind of unsafety do you envision here?
Making the code obvious during patch review hy this is needed / special, and if we special case this, why not remove enum, and make it specific to only that one table. The catch is that it is not immediately obvious that we actually call
sysctl_set_perm_empty_ctl_header()in other places, and it begs the question if this can be cleaned up somehow.
Making it specific won't work because the flag needs to be transferred from the leaf table to the table representing the directory.
What do you think of the aproach taken in the attached patch? (On top of current sysctl-next, including my series)
Note: Current sysctl-next ist still based on v6.6.
From 2fb9887fb2a5024c2620f2d694bc6dcc32afde67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <[email protected]>
Date: Wed, 6 Dec 2023 06:17:22 +0100
Subject: [PATCH] sysctl: simplify handling of permanently empty directories
--- fs/proc/proc_sysctl.c | 76 +++++++++++++++++++----------------------- include/linux/sysctl.h | 13 ++------ 2 files changed, 36 insertions(+), 53 deletions(-)
fs/proc/proc_sysctl.c +34 -42
@@ -17,6 +17,7 @@#include <linux/bpf-cgroup.h> #include <linux/mount.h> #include <linux/kmemleak.h> +#include <linux/cleanup.h> #include "internal.h" #define list_for_each_table_entry (entry, header) \
@@ -29,32 +30,6 @@ static const struct inode_operations proc_sys_inode_operations;static const struct file_operations proc_sys_dir_file_operations;static const struct inode_operations proc_sys_dir_operations; -/* Support for permanently empty directories */ -static const struct ctl_table sysctl_mount_point[] = { - { } -}; - -/** -* register_sysctl_mount_point() - registers a sysctl mount point -* @path: path for the mount point -* -* Used to create a permanently empty directory to serve as mount point. -* There are some subtle but important permission checks this allows in the -* case of unprivileged mounts. -*/ -struct ctl_table_header *register_sysctl_mount_point (const char *path) -{ -return register_sysctl (path, sysctl_mount_point); -} -EXPORT_SYMBOL (register_sysctl_mount_point); - -#define sysctl_is_perm_empty_ctl_header (hptr) \ - (hptr->type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_set_perm_empty_ctl_header (hptr) \ - (hptr->type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_clear_perm_empty_ctl_header (hptr) \ - (hptr->type = SYSCTL_TABLE_TYPE_DEFAULT) -void proc_sys_poll_notify (struct ctl_table_poll *poll) {if (!poll)
@@ -199,8 +174,6 @@ static void init_header(struct ctl_table_header *head, head->set = set; head->parent =NULL ; head->node = node; -if (table == sysctl_mount_point) -sysctl_set_perm_empty_ctl_header (head);INIT_HLIST_HEAD (&head->inodes);if (node) {const struct ctl_table *entry;
@@ -228,17 +201,9 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)/* Is this a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (dir_h)) +if (dir->permanently_empty)return -EROFS ; -/* Am I creating a permanently empty directory? */ -if (header->ctl_table_size >0 && -sysctl_is_perm_empty_ctl_header (header)) { -if (!RB_EMPTY_ROOT (&dir->root)) -return -EINVAL ; -sysctl_set_perm_empty_ctl_header (dir_h); - } - dir_h->nreg++; header->parent = dir; err =insert_links (header);
@@ -254,8 +219,6 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)erase_header (header);put_links (header); fail_links: -if (header->ctl_table == sysctl_mount_point) -sysctl_clear_perm_empty_ctl_header (dir_h); header->parent =NULL ;drop_sysctl_table (dir_h);return err;
@@ -442,6 +405,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, struct ctl_table_header *head, const struct ctl_table *table) { struct ctl_table_root *root = head->root; +struct ctl_dir *ctl_dir;struct inode *inode;struct proc_inode *ei;
@@ -475,7 +439,9 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, inode->i_mode |=S_IFDIR ; inode->i_op = &proc_sys_dir_operations; inode->i_fop = &proc_sys_dir_file_operations; -if (sysctl_is_perm_empty_ctl_header (head)) + + ctl_dir = container_of(head, struct ctl_dir, header); +if (ctl_dir->permanently_empty)make_empty_dir_inode (inode); }
@@ -1214,8 +1180,7 @@ static bool get_links(struct ctl_dir *dir,struct ctl_table_header *tmp_head;const struct ctl_table *entry, *link; -if (header->ctl_table_size ==0 || -sysctl_is_perm_empty_ctl_header (header)) +if (header->ctl_table_size ==0 || dir->permanently_empty)return true;/* Are there links available for every entry in table? */
@@ -1536,6 +1501,33 @@ void unregister_sysctl_table(struct ctl_table_header * header) }EXPORT_SYMBOL (unregister_sysctl_table); +/** +* register_sysctl_mount_point() - registers a sysctl mount point +* @path: path for the mount point +* +* Used to create a permanently empty directory to serve as mount point. +* There are some subtle but important permission checks this allows in the +* case of unprivileged mounts. +*/ +struct ctl_table_header *register_sysctl_mount_point (const char *path) +{ +struct ctl_dir *dir =sysctl_mkdir_p (&sysctl_table_root.default_set.dir, path); + +if (IS_ERR (dir)) +return NULL ; + +guard (spinlock)(&sysctl_lock); + +if (!RB_EMPTY_ROOT (&dir->root)) { +drop_sysctl_table (&dir->header); +return NULL ; + } + + dir->permanently_empty = true; +return &dir->header; +} +EXPORT_SYMBOL (register_sysctl_mount_point); +void setup_sysctl_set (struct ctl_table_set *set,struct ctl_table_root *root,int (*is_seen)(struct ctl_table_set *))
include/linux/sysctl.h +2 -11
@@ -177,23 +177,14 @@ struct ctl_table_header {struct ctl_dir *parent;struct ctl_node *node;struct hlist_head inodes;/* head for proc_inode->sysctl_inodes */ -/** -* enum type - Enumeration to differentiate between ctl target types -* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations -* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently -* empty directory target to serve -* as mount point. -*/ -enum { -SYSCTL_TABLE_TYPE_DEFAULT , -SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY - } type; };struct ctl_dir {/* Header must be at the start of ctl_dir */ struct ctl_table_header header;struct rb_root root; +/* Permanently empty directory target to serve as mount point. */ +bool permanently_empty; };struct ctl_table_set {
base-commit: a6fd07f80ab7bd94edb4d56c35e61117ffb9957e
prerequisite-patch-id: 0000000000000000000000000000000000000000
prerequisite-patch-id: 13932e9add940cb65c71e04b5efdfcd3622fd27e
prerequisite-patch-id: 2e4d88f7b8aaa805598f0e87a3ea726825bb4264
prerequisite-patch-id: 674a680d9cb138cd34cfd0e1a4ec3a5d1c220078
prerequisite-patch-id: e27c92582aa20b1dfb122c172b336dbaf9d6508a
prerequisite-patch-id: 9b409a34ab6a4d8d8c5225ba9a72db3116e3c8b3
prerequisite-patch-id: 86ff15a81d850ebda16bb707491251f4b705e4fd
prerequisite-patch-id: b7ab65512ac9acfb2dd482b0271b399467afc56d
prerequisite-patch-id: 0354922fbf2508a89f3e9d9a4e274fc98deb2e93
prerequisite-patch-id: b71389e82026ffc19cbb717bba1a014ad6cab6da
prerequisite-patch-id: fbb0201f89bf6c41d0585af867bdeec8d51649b2
prerequisite-patch-id: e3b4b5b69b4eadf87ed97beb8c03a471e7628cb9
prerequisite-patch-id: 3fbc9745cf3f28872b3e63f6d1f6e2fd7598be8a
prerequisite-patch-id: ba2b190c2e54cfb505a282e688c2222712f0acd7
prerequisite-patch-id: 47e5ca730748bb7bf9248a9e711045d8c1028199
prerequisite-patch-id: dcd9f87f00290d2f9be83e404f8883eb90c5fb1c
prerequisite-patch-id: d4629be1a61585ab821da2d2850f246761f72f25
prerequisite-patch-id: f740190f4b94e57cbf3659f220d94483713341a1
prerequisite-patch-id: 301c2e530e2af4568267e19247d4a49ac2a9871d
Signature · 1 line
2.43.0
Re: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header
Quoted 34 lines · Thomas Weißschuh
Quoted 24 lines · Luis Chamberlain
Quoted 16 lines · Thomas Weißschuh
Quoted 4 lines · Luis Chamberlain
Quoted 3 lines · Thomas Weißschuh
fs/proc/proc_sysctl.c +0
-0@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)return -EROFS ;Quoted 9 lines
Review static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) · line 238
Quoted 7 lines
(quoted diff) +2
-1/* Am I creating a permanently empty directory? */ - if (sysctl_is_perm_empty_ctl_header(header)) { + if (header->ctl_table == sysctl_mount_point || + sysctl_is_perm_empty_ctl_header(header)) { if (!RB_EMPTY_ROOT(&dir->root)) return -EINVAL; sysctl_set_perm_empty_ctl_header(dir_h);While you're at it.
Quoted 1 line
This hunk is completely gone in v3/the code that you merged.
It is worse in that it is not obvious:
(quoted diff) +2
-0+ if (table == sysctl_mount_point) + sysctl_set_perm_empty_ctl_header(head);Quoted 8 lines
Quoted 1 line
Which kind of unsafety do you envision here?
Making the code obvious during patch review hy this is needed / special, and if we special case this, why not remove enum, and make it specific to only that one table. The catch is that it is not immediately obvious that we actually call
sysctl_set_perm_empty_ctl_header()in other places, and it begs the question if this can be cleaned up somehow.
Quoted 5 lines
Making it specific won't work because the flag needs to be transferred from the leaf table to the table representing the directory.
What do you think of the aproach taken in the attached patch? (On top of current sysctl-next, including my series)
What would this new patch be fixing again? I could not follow ?
Additionally, this might be another reason to set this patch aside :)
Quoted 212 lines
Note: Current sysctl-next ist still based on v6.6.
From
2fb9887fb2a5024c2620f2d694bc6dcc32afde67Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <[email protected]>
Date: Wed, 6 Dec 2023 06:17:22 +0100
Subject: [PATCH] sysctl: simplify handling of permanently empty directories--- fs/proc/proc_sysctl.c | 76 +++++++++++++++++++----------------------- include/linux/sysctl.h | 13 ++------ 2 files changed, 36 insertions(+), 53 deletions(-)fs/proc/proc_sysctl.c +34
-42@@ -17,6 +17,7 @@#include <linux/bpf-cgroup.h> #include <linux/mount.h> #include <linux/kmemleak.h> +#include <linux/cleanup.h> #include "internal.h" #define list_for_each_table_entry (entry, header) \@@ -29,32 +30,6 @@ static const struct inode_operations proc_sys_inode_operations;static const struct file_operations proc_sys_dir_file_operations;static const struct inode_operations proc_sys_dir_operations; -/* Support for permanently empty directories */ -static const struct ctl_table sysctl_mount_point[] = { - { } -}; - -/** -* register_sysctl_mount_point() - registers a sysctl mount point -* @path: path for the mount point -* -* Used to create a permanently empty directory to serve as mount point. -* There are some subtle but important permission checks this allows in the -* case of unprivileged mounts. -*/ -struct ctl_table_header *register_sysctl_mount_point (const char *path) -{ -return register_sysctl (path, sysctl_mount_point); -} -EXPORT_SYMBOL (register_sysctl_mount_point); - -#define sysctl_is_perm_empty_ctl_header (hptr) \ - (hptr->type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_set_perm_empty_ctl_header (hptr) \ - (hptr->type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_clear_perm_empty_ctl_header (hptr) \ - (hptr->type = SYSCTL_TABLE_TYPE_DEFAULT) -void proc_sys_poll_notify (struct ctl_table_poll *poll) {if (!poll)@@ -199,8 +174,6 @@ static void init_header(struct ctl_table_header *head, head->set = set; head->parent =NULL ; head->node = node; -if (table == sysctl_mount_point) -sysctl_set_perm_empty_ctl_header (head);INIT_HLIST_HEAD (&head->inodes);if (node) {const struct ctl_table *entry;@@ -228,17 +201,9 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)/* Is this a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (dir_h)) +if (dir->permanently_empty)return -EROFS ; -/* Am I creating a permanently empty directory? */ -if (header->ctl_table_size >0 && -sysctl_is_perm_empty_ctl_header (header)) { -if (!RB_EMPTY_ROOT (&dir->root)) -return -EINVAL ; -sysctl_set_perm_empty_ctl_header (dir_h); - } - dir_h->nreg++; header->parent = dir; err =insert_links (header);@@ -254,8 +219,6 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)erase_header (header);put_links (header); fail_links: -if (header->ctl_table == sysctl_mount_point) -sysctl_clear_perm_empty_ctl_header (dir_h); header->parent =NULL ;drop_sysctl_table (dir_h);return err;@@ -442,6 +405,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, struct ctl_table_header *head, const struct ctl_table *table) { struct ctl_table_root *root = head->root; +struct ctl_dir *ctl_dir;struct inode *inode;struct proc_inode *ei;@@ -475,7 +439,9 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, inode->i_mode |=S_IFDIR ; inode->i_op = &proc_sys_dir_operations; inode->i_fop = &proc_sys_dir_file_operations; -if (sysctl_is_perm_empty_ctl_header (head)) + + ctl_dir = container_of(head, struct ctl_dir, header); +if (ctl_dir->permanently_empty)make_empty_dir_inode (inode); }@@ -1214,8 +1180,7 @@ static bool get_links(struct ctl_dir *dir,struct ctl_table_header *tmp_head;const struct ctl_table *entry, *link; -if (header->ctl_table_size ==0 || -sysctl_is_perm_empty_ctl_header (header)) +if (header->ctl_table_size ==0 || dir->permanently_empty)return true;/* Are there links available for every entry in table? */ @@ -1536,6 +1501,33 @@ void unregister_sysctl_table(struct ctl_table_header * header) }EXPORT_SYMBOL (unregister_sysctl_table); +/** +* register_sysctl_mount_point() - registers a sysctl mount point +* @path: path for the mount point +* +* Used to create a permanently empty directory to serve as mount point. +* There are some subtle but important permission checks this allows in the +* case of unprivileged mounts. +*/ +struct ctl_table_header *register_sysctl_mount_point (const char *path) +{ +struct ctl_dir *dir =sysctl_mkdir_p (&sysctl_table_root.default_set.dir, path); + +if (IS_ERR (dir)) +return NULL ; + +guard (spinlock)(&sysctl_lock); + +if (!RB_EMPTY_ROOT (&dir->root)) { +drop_sysctl_table (&dir->header); +return NULL ; + } + + dir->permanently_empty = true; +return &dir->header; +} +EXPORT_SYMBOL (register_sysctl_mount_point); +void setup_sysctl_set (struct ctl_table_set *set,struct ctl_table_root *root,int (*is_seen)(struct ctl_table_set *))include/linux/sysctl.h +2
-11@@ -177,23 +177,14 @@ struct ctl_table_header {struct ctl_dir *parent;struct ctl_node *node;struct hlist_head inodes;/* head for proc_inode->sysctl_inodes */ -/** -* enum type - Enumeration to differentiate between ctl target types -* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations -* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently -* empty directory target to serve -* as mount point. -*/ -enum { -SYSCTL_TABLE_TYPE_DEFAULT , -SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY - } type; };struct ctl_dir {/* Header must be at the start of ctl_dir */ struct ctl_table_header header;struct rb_root root; +/* Permanently empty directory target to serve as mount point. */ +bool permanently_empty; };struct ctl_table_set {base-commit:
a6fd07f80ab7bd94edb4d56c35e61117ffb9957e
prerequisite-patch-id: 0000000000000000000000000000000000000000
prerequisite-patch-id:13932e9add940cb65c71e04b5efdfcd3622fd27e
prerequisite-patch-id:2e4d88f7b8aaa805598f0e87a3ea726825bb4264
prerequisite-patch-id:674a680d9cb138cd34cfd0e1a4ec3a5d1c220078
prerequisite-patch-id:e27c92582aa20b1dfb122c172b336dbaf9d6508a
prerequisite-patch-id:9b409a34ab6a4d8d8c5225ba9a72db3116e3c8b3
prerequisite-patch-id:86ff15a81d850ebda16bb707491251f4b705e4fd
prerequisite-patch-id:b7ab65512ac9acfb2dd482b0271b399467afc56d
prerequisite-patch-id:0354922fbf2508a89f3e9d9a4e274fc98deb2e93
prerequisite-patch-id:b71389e82026ffc19cbb717bba1a014ad6cab6da
prerequisite-patch-id:fbb0201f89bf6c41d0585af867bdeec8d51649b2
prerequisite-patch-id:e3b4b5b69b4eadf87ed97beb8c03a471e7628cb9
prerequisite-patch-id:3fbc9745cf3f28872b3e63f6d1f6e2fd7598be8a
prerequisite-patch-id:ba2b190c2e54cfb505a282e688c2222712f0acd7
prerequisite-patch-id:47e5ca730748bb7bf9248a9e711045d8c1028199
prerequisite-patch-id:dcd9f87f00290d2f9be83e404f8883eb90c5fb1c
prerequisite-patch-id:d4629be1a61585ab821da2d2850f246761f72f25
prerequisite-patch-id:f740190f4b94e57cbf3659f220d94483713341a1
prerequisite-patch-id:301c2e530e2af4568267e19247d4a49ac2a9871dSignature · 1 line
2.43.0
Signature · 1 line
Joel Granados
Re: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header
Quoted 35 lines · Joel Granados
Quoted 34 lines · Thomas Weißschuh
Quoted 32 lines · Luis Chamberlain
Quoted 16 lines · Thomas Weißschuh
Quoted 4 lines · Luis Chamberlain
Quoted 3 lines · Thomas Weißschuh
fs/proc/proc_sysctl.c +0
-0@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)return -EROFS ;Quoted 9 lines
Review static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) · line 238
Quoted 7 lines
(quoted diff) +2
-1/* Am I creating a permanently empty directory? */ - if (sysctl_is_perm_empty_ctl_header(header)) { + if (header->ctl_table == sysctl_mount_point || + sysctl_is_perm_empty_ctl_header(header)) { if (!RB_EMPTY_ROOT(&dir->root)) return -EINVAL; sysctl_set_perm_empty_ctl_header(dir_h);While you're at it.
Quoted 1 line
This hunk is completely gone in v3/the code that you merged.
It is worse in that it is not obvious:
(quoted diff) +2
-0+ if (table == sysctl_mount_point) + sysctl_set_perm_empty_ctl_header(head);Quoted 2 lines
Which kind of unsafety do you envision here?
Making the code obvious during patch review hy this is needed / special, and if we special case this, why not remove enum, and make it specific to only that one table. The catch is that it is not immediately obvious that we actually call
sysctl_set_perm_empty_ctl_header()in other places, and it begs the question if this can be cleaned up somehow.
Quoted 7 lines
Quoted 5 lines
Making it specific won't work because the flag needs to be transferred from the leaf table to the table representing the directory.
What do you think of the aproach taken in the attached patch? (On top of current sysctl-next, including my series)
What would this new patch be fixing again? I could not follow ?
This patch improves upon and replaces the patch you asked to submit on its own: "sysctl: move sysctl type to ctl_table_header".
The current code and my original patch have to work around the fact that the "empty" flag is first registered on a *leaf* ctl_table and from there has to be transferred to the *directory* ctl_table somehow. Which is confusing, at least it was for me and evidently also Luis.
The new code just directly sets the flag on the directory ctl_table and gets rid of some now-dead code.
I should have written a proper changelog...
Quoted 1 line
Additionally, this might be another reason to set this patch aside :)
I hope we get this one in, it seems cleaner now.
If you agree I can send it as a proper standalone preparation patch.
Quoted 14 lines
Quoted 12 lines
Note: Current sysctl-next ist still based on v6.6.
From
2fb9887fb2a5024c2620f2d694bc6dcc32afde67Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <[email protected]>
Date: Wed, 6 Dec 2023 06:17:22 +0100
Subject: [PATCH] sysctl: simplify handling of permanently empty directories--- fs/proc/proc_sysctl.c | 76 +++++++++++++++++++----------------------- include/linux/sysctl.h | 13 ++------ 2 files changed, 36 insertions(+), 53 deletions(-)[..]
Re: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header
In reply to Thomas WeißschuhHey Thomas.
I had some available cycles today and wanted to look at the patch that you sent. I could not apply it on top of 6.7-rc6. Have you thought about taking this out of your "constification" series and posting it as something that comes before the const stuff?
Best
Quoted 251 lines · Thomas Weißschuh
Quoted 24 lines · Luis Chamberlain
Quoted 16 lines · Thomas Weißschuh
Quoted 4 lines · Luis Chamberlain
Quoted 3 lines · Thomas Weißschuh
fs/proc/proc_sysctl.c +0
-0@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)return -EROFS ;Quoted 9 lines
Review static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) · line 238
Quoted 7 lines
(quoted diff) +2
-1/* Am I creating a permanently empty directory? */ - if (sysctl_is_perm_empty_ctl_header(header)) { + if (header->ctl_table == sysctl_mount_point || + sysctl_is_perm_empty_ctl_header(header)) { if (!RB_EMPTY_ROOT(&dir->root)) return -EINVAL; sysctl_set_perm_empty_ctl_header(dir_h);While you're at it.
Quoted 1 line
This hunk is completely gone in v3/the code that you merged.
It is worse in that it is not obvious:
(quoted diff) +2
-0+ if (table == sysctl_mount_point) + sysctl_set_perm_empty_ctl_header(head);Quoted 8 lines
Quoted 1 line
Which kind of unsafety do you envision here?
Making the code obvious during patch review hy this is needed / special, and if we special case this, why not remove enum, and make it specific to only that one table. The catch is that it is not immediately obvious that we actually call
sysctl_set_perm_empty_ctl_header()in other places, and it begs the question if this can be cleaned up somehow.Making it specific won't work because the flag needs to be transferred from the leaf table to the table representing the directory.
What do you think of the aproach taken in the attached patch? (On top of current sysctl-next, including my series)
Note: Current sysctl-next ist still based on v6.6.
From
2fb9887fb2a5024c2620f2d694bc6dcc32afde67Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <[email protected]>
Date: Wed, 6 Dec 2023 06:17:22 +0100
Subject: [PATCH] sysctl: simplify handling of permanently empty directories--- fs/proc/proc_sysctl.c | 76 +++++++++++++++++++----------------------- include/linux/sysctl.h | 13 ++------ 2 files changed, 36 insertions(+), 53 deletions(-)fs/proc/proc_sysctl.c +34
-42@@ -17,6 +17,7 @@#include <linux/bpf-cgroup.h> #include <linux/mount.h> #include <linux/kmemleak.h> +#include <linux/cleanup.h> #include "internal.h" #define list_for_each_table_entry (entry, header) \@@ -29,32 +30,6 @@ static const struct inode_operations proc_sys_inode_operations;static const struct file_operations proc_sys_dir_file_operations;static const struct inode_operations proc_sys_dir_operations; -/* Support for permanently empty directories */ -static const struct ctl_table sysctl_mount_point[] = { - { } -}; - -/** -* register_sysctl_mount_point() - registers a sysctl mount point -* @path: path for the mount point -* -* Used to create a permanently empty directory to serve as mount point. -* There are some subtle but important permission checks this allows in the -* case of unprivileged mounts. -*/ -struct ctl_table_header *register_sysctl_mount_point (const char *path) -{ -return register_sysctl (path, sysctl_mount_point); -} -EXPORT_SYMBOL (register_sysctl_mount_point); - -#define sysctl_is_perm_empty_ctl_header (hptr) \ - (hptr->type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_set_perm_empty_ctl_header (hptr) \ - (hptr->type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_clear_perm_empty_ctl_header (hptr) \ - (hptr->type = SYSCTL_TABLE_TYPE_DEFAULT) -void proc_sys_poll_notify (struct ctl_table_poll *poll) {if (!poll)@@ -199,8 +174,6 @@ static void init_header(struct ctl_table_header *head, head->set = set; head->parent =NULL ; head->node = node; -if (table == sysctl_mount_point) -sysctl_set_perm_empty_ctl_header (head);INIT_HLIST_HEAD (&head->inodes);if (node) {const struct ctl_table *entry;@@ -228,17 +201,9 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)/* Is this a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (dir_h)) +if (dir->permanently_empty)return -EROFS ; -/* Am I creating a permanently empty directory? */ -if (header->ctl_table_size >0 && -sysctl_is_perm_empty_ctl_header (header)) { -if (!RB_EMPTY_ROOT (&dir->root)) -return -EINVAL ; -sysctl_set_perm_empty_ctl_header (dir_h); - } - dir_h->nreg++; header->parent = dir; err =insert_links (header);@@ -254,8 +219,6 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)erase_header (header);put_links (header); fail_links: -if (header->ctl_table == sysctl_mount_point) -sysctl_clear_perm_empty_ctl_header (dir_h); header->parent =NULL ;drop_sysctl_table (dir_h);return err;@@ -442,6 +405,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, struct ctl_table_header *head, const struct ctl_table *table) { struct ctl_table_root *root = head->root; +struct ctl_dir *ctl_dir;struct inode *inode;struct proc_inode *ei;@@ -475,7 +439,9 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, inode->i_mode |=S_IFDIR ; inode->i_op = &proc_sys_dir_operations; inode->i_fop = &proc_sys_dir_file_operations; -if (sysctl_is_perm_empty_ctl_header (head)) + + ctl_dir = container_of(head, struct ctl_dir, header); +if (ctl_dir->permanently_empty)make_empty_dir_inode (inode); }@@ -1214,8 +1180,7 @@ static bool get_links(struct ctl_dir *dir,struct ctl_table_header *tmp_head;const struct ctl_table *entry, *link; -if (header->ctl_table_size ==0 || -sysctl_is_perm_empty_ctl_header (header)) +if (header->ctl_table_size ==0 || dir->permanently_empty)return true;/* Are there links available for every entry in table? */ @@ -1536,6 +1501,33 @@ void unregister_sysctl_table(struct ctl_table_header * header) }EXPORT_SYMBOL (unregister_sysctl_table); +/** +* register_sysctl_mount_point() - registers a sysctl mount point +* @path: path for the mount point +* +* Used to create a permanently empty directory to serve as mount point. +* There are some subtle but important permission checks this allows in the +* case of unprivileged mounts. +*/ +struct ctl_table_header *register_sysctl_mount_point (const char *path) +{ +struct ctl_dir *dir =sysctl_mkdir_p (&sysctl_table_root.default_set.dir, path); + +if (IS_ERR (dir)) +return NULL ; + +guard (spinlock)(&sysctl_lock); + +if (!RB_EMPTY_ROOT (&dir->root)) { +drop_sysctl_table (&dir->header); +return NULL ; + } + + dir->permanently_empty = true; +return &dir->header; +} +EXPORT_SYMBOL (register_sysctl_mount_point); +void setup_sysctl_set (struct ctl_table_set *set,struct ctl_table_root *root,int (*is_seen)(struct ctl_table_set *))include/linux/sysctl.h +2
-11@@ -177,23 +177,14 @@ struct ctl_table_header {struct ctl_dir *parent;struct ctl_node *node;struct hlist_head inodes;/* head for proc_inode->sysctl_inodes */ -/** -* enum type - Enumeration to differentiate between ctl target types -* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations -* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently -* empty directory target to serve -* as mount point. -*/ -enum { -SYSCTL_TABLE_TYPE_DEFAULT , -SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY - } type; };struct ctl_dir {/* Header must be at the start of ctl_dir */ struct ctl_table_header header;struct rb_root root; +/* Permanently empty directory target to serve as mount point. */ +bool permanently_empty; };struct ctl_table_set {base-commit:
a6fd07f80ab7bd94edb4d56c35e61117ffb9957e
prerequisite-patch-id: 0000000000000000000000000000000000000000
prerequisite-patch-id:13932e9add940cb65c71e04b5efdfcd3622fd27e
prerequisite-patch-id:2e4d88f7b8aaa805598f0e87a3ea726825bb4264
prerequisite-patch-id:674a680d9cb138cd34cfd0e1a4ec3a5d1c220078
prerequisite-patch-id:e27c92582aa20b1dfb122c172b336dbaf9d6508a
prerequisite-patch-id:9b409a34ab6a4d8d8c5225ba9a72db3116e3c8b3
prerequisite-patch-id:86ff15a81d850ebda16bb707491251f4b705e4fd
prerequisite-patch-id:b7ab65512ac9acfb2dd482b0271b399467afc56d
prerequisite-patch-id:0354922fbf2508a89f3e9d9a4e274fc98deb2e93
prerequisite-patch-id:b71389e82026ffc19cbb717bba1a014ad6cab6da
prerequisite-patch-id:fbb0201f89bf6c41d0585af867bdeec8d51649b2
prerequisite-patch-id:e3b4b5b69b4eadf87ed97beb8c03a471e7628cb9
prerequisite-patch-id:3fbc9745cf3f28872b3e63f6d1f6e2fd7598be8a
prerequisite-patch-id:ba2b190c2e54cfb505a282e688c2222712f0acd7
prerequisite-patch-id:47e5ca730748bb7bf9248a9e711045d8c1028199
prerequisite-patch-id:dcd9f87f00290d2f9be83e404f8883eb90c5fb1c
prerequisite-patch-id:d4629be1a61585ab821da2d2850f246761f72f25
prerequisite-patch-id:f740190f4b94e57cbf3659f220d94483713341a1
prerequisite-patch-id:301c2e530e2af4568267e19247d4a49ac2a9871dSignature · 1 line
2.43.0
Signature · 1 line
Joel Granados
Re: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header
Hi Joel,
Quoted 4 lines · Joel Granados
I had some available cycles today and wanted to look at the patch that you sent. I could not apply it on top of 6.7-rc6. Have you thought about taking this out of your "constification" series and posting it as something that comes before the const stuff?
Yes, I am planning to submit this standalone. But I need to do some more investigation to properly handle the existing comments.
FYI this out-of-series patch is meant to be applied on top of the rest of the series.
Another question:
When did you write this mail?
The Date header says it's from the 21st but I only received it today (the 23rd). All other mail headers also say that it was only sent on 23rd. The same seems to happen with your other mails, too.
Thomas
Quoted 257 lines · Thomas Weißschuh
Quoted 251 lines · Luis Chamberlain
Quoted 24 lines · Thomas Weißschuh
Quoted 16 lines · Luis Chamberlain
Quoted 13 lines · Thomas Weißschuh
Review static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) · line 238
Quoted 10 lines
(quoted diff) +2
-1@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) return -EROFS; /* Am I creating a permanently empty directory? */ - if (sysctl_is_perm_empty_ctl_header(header)) { + if (header->ctl_table == sysctl_mount_point || + sysctl_is_perm_empty_ctl_header(header)) { if (!RB_EMPTY_ROOT(&dir->root)) return -EINVAL; sysctl_set_perm_empty_ctl_header(dir_h);While you're at it.
Quoted 1 line
This hunk is completely gone in v3/the code that you merged.
It is worse in that it is not obvious:
(quoted diff) +2
-0+ if (table == sysctl_mount_point) + sysctl_set_perm_empty_ctl_header(head);Quoted 8 lines
Quoted 1 line
Which kind of unsafety do you envision here?
Making the code obvious during patch review hy this is needed / special, and if we special case this, why not remove enum, and make it specific to only that one table. The catch is that it is not immediately obvious that we actually call
sysctl_set_perm_empty_ctl_header()in other places, and it begs the question if this can be cleaned up somehow.Making it specific won't work because the flag needs to be transferred from the leaf table to the table representing the directory.
What do you think of the aproach taken in the attached patch? (On top of current sysctl-next, including my series)
Note: Current sysctl-next ist still based on v6.6.
From
2fb9887fb2a5024c2620f2d694bc6dcc32afde67Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <[email protected]>
Date: Wed, 6 Dec 2023 06:17:22 +0100
Subject: [PATCH] sysctl: simplify handling of permanently empty directories--- fs/proc/proc_sysctl.c | 76 +++++++++++++++++++----------------------- include/linux/sysctl.h | 13 ++------ 2 files changed, 36 insertions(+), 53 deletions(-)fs/proc/proc_sysctl.c +34
-42@@ -17,6 +17,7 @@#include <linux/bpf-cgroup.h> #include <linux/mount.h> #include <linux/kmemleak.h> +#include <linux/cleanup.h> #include "internal.h" #define list_for_each_table_entry (entry, header) \@@ -29,32 +30,6 @@ static const struct inode_operations proc_sys_inode_operations;static const struct file_operations proc_sys_dir_file_operations;static const struct inode_operations proc_sys_dir_operations; -/* Support for permanently empty directories */ -static const struct ctl_table sysctl_mount_point[] = { - { } -}; - -/** -* register_sysctl_mount_point() - registers a sysctl mount point -* @path: path for the mount point -* -* Used to create a permanently empty directory to serve as mount point. -* There are some subtle but important permission checks this allows in the -* case of unprivileged mounts. -*/ -struct ctl_table_header *register_sysctl_mount_point (const char *path) -{ -return register_sysctl (path, sysctl_mount_point); -} -EXPORT_SYMBOL (register_sysctl_mount_point); - -#define sysctl_is_perm_empty_ctl_header (hptr) \ - (hptr->type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_set_perm_empty_ctl_header (hptr) \ - (hptr->type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_clear_perm_empty_ctl_header (hptr) \ - (hptr->type = SYSCTL_TABLE_TYPE_DEFAULT) -void proc_sys_poll_notify (struct ctl_table_poll *poll) {if (!poll)@@ -199,8 +174,6 @@ static void init_header(struct ctl_table_header *head, head->set = set; head->parent =NULL ; head->node = node; -if (table == sysctl_mount_point) -sysctl_set_perm_empty_ctl_header (head);INIT_HLIST_HEAD (&head->inodes);if (node) {const struct ctl_table *entry;@@ -228,17 +201,9 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)/* Is this a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (dir_h)) +if (dir->permanently_empty)return -EROFS ; -/* Am I creating a permanently empty directory? */ -if (header->ctl_table_size >0 && -sysctl_is_perm_empty_ctl_header (header)) { -if (!RB_EMPTY_ROOT (&dir->root)) -return -EINVAL ; -sysctl_set_perm_empty_ctl_header (dir_h); - } - dir_h->nreg++; header->parent = dir; err =insert_links (header);@@ -254,8 +219,6 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)erase_header (header);put_links (header); fail_links: -if (header->ctl_table == sysctl_mount_point) -sysctl_clear_perm_empty_ctl_header (dir_h); header->parent =NULL ;drop_sysctl_table (dir_h);return err;@@ -442,6 +405,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, struct ctl_table_header *head, const struct ctl_table *table) { struct ctl_table_root *root = head->root; +struct ctl_dir *ctl_dir;struct inode *inode;struct proc_inode *ei;@@ -475,7 +439,9 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, inode->i_mode |=S_IFDIR ; inode->i_op = &proc_sys_dir_operations; inode->i_fop = &proc_sys_dir_file_operations; -if (sysctl_is_perm_empty_ctl_header (head)) + + ctl_dir = container_of(head, struct ctl_dir, header); +if (ctl_dir->permanently_empty)make_empty_dir_inode (inode); }@@ -1214,8 +1180,7 @@ static bool get_links(struct ctl_dir *dir,struct ctl_table_header *tmp_head;const struct ctl_table *entry, *link; -if (header->ctl_table_size ==0 || -sysctl_is_perm_empty_ctl_header (header)) +if (header->ctl_table_size ==0 || dir->permanently_empty)return true;/* Are there links available for every entry in table? */ @@ -1536,6 +1501,33 @@ void unregister_sysctl_table(struct ctl_table_header * header) }EXPORT_SYMBOL (unregister_sysctl_table); +/** +* register_sysctl_mount_point() - registers a sysctl mount point +* @path: path for the mount point +* +* Used to create a permanently empty directory to serve as mount point. +* There are some subtle but important permission checks this allows in the +* case of unprivileged mounts. +*/ +struct ctl_table_header *register_sysctl_mount_point (const char *path) +{ +struct ctl_dir *dir =sysctl_mkdir_p (&sysctl_table_root.default_set.dir, path); + +if (IS_ERR (dir)) +return NULL ; + +guard (spinlock)(&sysctl_lock); + +if (!RB_EMPTY_ROOT (&dir->root)) { +drop_sysctl_table (&dir->header); +return NULL ; + } + + dir->permanently_empty = true; +return &dir->header; +} +EXPORT_SYMBOL (register_sysctl_mount_point); +void setup_sysctl_set (struct ctl_table_set *set,struct ctl_table_root *root,int (*is_seen)(struct ctl_table_set *))include/linux/sysctl.h +2
-11@@ -177,23 +177,14 @@ struct ctl_table_header {struct ctl_dir *parent;struct ctl_node *node;struct hlist_head inodes;/* head for proc_inode->sysctl_inodes */ -/** -* enum type - Enumeration to differentiate between ctl target types -* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations -* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently -* empty directory target to serve -* as mount point. -*/ -enum { -SYSCTL_TABLE_TYPE_DEFAULT , -SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY - } type; };struct ctl_dir {/* Header must be at the start of ctl_dir */ struct ctl_table_header header;struct rb_root root; +/* Permanently empty directory target to serve as mount point. */ +bool permanently_empty; };struct ctl_table_set {base-commit:
a6fd07f80ab7bd94edb4d56c35e61117ffb9957e
prerequisite-patch-id: 0000000000000000000000000000000000000000
prerequisite-patch-id:13932e9add940cb65c71e04b5efdfcd3622fd27e
prerequisite-patch-id:2e4d88f7b8aaa805598f0e87a3ea726825bb4264
prerequisite-patch-id:674a680d9cb138cd34cfd0e1a4ec3a5d1c220078
prerequisite-patch-id:e27c92582aa20b1dfb122c172b336dbaf9d6508a
prerequisite-patch-id:9b409a34ab6a4d8d8c5225ba9a72db3116e3c8b3
prerequisite-patch-id:86ff15a81d850ebda16bb707491251f4b705e4fd
prerequisite-patch-id:b7ab65512ac9acfb2dd482b0271b399467afc56d
prerequisite-patch-id:0354922fbf2508a89f3e9d9a4e274fc98deb2e93
prerequisite-patch-id:b71389e82026ffc19cbb717bba1a014ad6cab6da
prerequisite-patch-id:fbb0201f89bf6c41d0585af867bdeec8d51649b2
prerequisite-patch-id:e3b4b5b69b4eadf87ed97beb8c03a471e7628cb9
prerequisite-patch-id:3fbc9745cf3f28872b3e63f6d1f6e2fd7598be8a
prerequisite-patch-id:ba2b190c2e54cfb505a282e688c2222712f0acd7
prerequisite-patch-id:47e5ca730748bb7bf9248a9e711045d8c1028199
prerequisite-patch-id:dcd9f87f00290d2f9be83e404f8883eb90c5fb1c
prerequisite-patch-id:d4629be1a61585ab821da2d2850f246761f72f25
prerequisite-patch-id:f740190f4b94e57cbf3659f220d94483713341a1
prerequisite-patch-id:301c2e530e2af4568267e19247d4a49ac2a9871dSignature · 1 line
2.43.0Signature · 1 line
Joel Granados
Re: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header
Quoted 10 lines · Thomas Weißschuh
Hi Joel,
Quoted 4 lines · Joel Granados
I had some available cycles today and wanted to look at the patch that you sent. I could not apply it on top of 6.7-rc6. Have you thought about taking this out of your "constification" series and posting it as something that comes before the const stuff?
Yes, I am planning to submit this standalone. But I need to do some more investigation to properly handle the existing comments.
Understood.
Quoted 3 lines
FYI this out-of-series patch is meant to be applied on top of the rest of the series.
Ok.
Quoted 9 lines
Another question:
When did you write this mail?
The Date header says it's from the 21st but I only received it today (the 23rd). All other mail headers also say that it was only sent on 23rd. The same seems to happen with your other mails, too.
Sometimes I do the review even if I don't have connection. Everything goes out once I get back on the network.
So there is the timestamp of when I "sent" but was on standby in my outgoing mails 21st. And then the actual sending occurred some days later when I was back on the network.
Quoted 262 lines
Thomas
Quoted 257 lines · Thomas Weißschuh
Quoted 251 lines · Luis Chamberlain
Quoted 24 lines · Thomas Weißschuh
Quoted 16 lines · Luis Chamberlain
Quoted 13 lines · Thomas Weißschuh
Review static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) · line 238
Quoted 10 lines
(quoted diff) +2
-1@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) return -EROFS; /* Am I creating a permanently empty directory? */ - if (sysctl_is_perm_empty_ctl_header(header)) { + if (header->ctl_table == sysctl_mount_point || + sysctl_is_perm_empty_ctl_header(header)) { if (!RB_EMPTY_ROOT(&dir->root)) return -EINVAL; sysctl_set_perm_empty_ctl_header(dir_h);While you're at it.
Quoted 1 line
This hunk is completely gone in v3/the code that you merged.
It is worse in that it is not obvious:
(quoted diff) +2
-0+ if (table == sysctl_mount_point) + sysctl_set_perm_empty_ctl_header(head);Quoted 8 lines
Quoted 1 line
Which kind of unsafety do you envision here?
Making the code obvious during patch review hy this is needed / special, and if we special case this, why not remove enum, and make it specific to only that one table. The catch is that it is not immediately obvious that we actually call
sysctl_set_perm_empty_ctl_header()in other places, and it begs the question if this can be cleaned up somehow.Making it specific won't work because the flag needs to be transferred from the leaf table to the table representing the directory.
What do you think of the aproach taken in the attached patch? (On top of current sysctl-next, including my series)
Note: Current sysctl-next ist still based on v6.6.
From
2fb9887fb2a5024c2620f2d694bc6dcc32afde67Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <[email protected]>
Date: Wed, 6 Dec 2023 06:17:22 +0100
Subject: [PATCH] sysctl: simplify handling of permanently empty directories--- fs/proc/proc_sysctl.c | 76 +++++++++++++++++++----------------------- include/linux/sysctl.h | 13 ++------ 2 files changed, 36 insertions(+), 53 deletions(-)fs/proc/proc_sysctl.c +34
-42@@ -17,6 +17,7 @@#include <linux/bpf-cgroup.h> #include <linux/mount.h> #include <linux/kmemleak.h> +#include <linux/cleanup.h> #include "internal.h" #define list_for_each_table_entry (entry, header) \@@ -29,32 +30,6 @@ static const struct inode_operations proc_sys_inode_operations;static const struct file_operations proc_sys_dir_file_operations;static const struct inode_operations proc_sys_dir_operations; -/* Support for permanently empty directories */ -static const struct ctl_table sysctl_mount_point[] = { - { } -}; - -/** -* register_sysctl_mount_point() - registers a sysctl mount point -* @path: path for the mount point -* -* Used to create a permanently empty directory to serve as mount point. -* There are some subtle but important permission checks this allows in the -* case of unprivileged mounts. -*/ -struct ctl_table_header *register_sysctl_mount_point (const char *path) -{ -return register_sysctl (path, sysctl_mount_point); -} -EXPORT_SYMBOL (register_sysctl_mount_point); - -#define sysctl_is_perm_empty_ctl_header (hptr) \ - (hptr->type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_set_perm_empty_ctl_header (hptr) \ - (hptr->type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_clear_perm_empty_ctl_header (hptr) \ - (hptr->type = SYSCTL_TABLE_TYPE_DEFAULT) -void proc_sys_poll_notify (struct ctl_table_poll *poll) {if (!poll)@@ -199,8 +174,6 @@ static void init_header(struct ctl_table_header *head, head->set = set; head->parent =NULL ; head->node = node; -if (table == sysctl_mount_point) -sysctl_set_perm_empty_ctl_header (head);INIT_HLIST_HEAD (&head->inodes);if (node) {const struct ctl_table *entry;@@ -228,17 +201,9 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)/* Is this a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (dir_h)) +if (dir->permanently_empty)return -EROFS ; -/* Am I creating a permanently empty directory? */ -if (header->ctl_table_size >0 && -sysctl_is_perm_empty_ctl_header (header)) { -if (!RB_EMPTY_ROOT (&dir->root)) -return -EINVAL ; -sysctl_set_perm_empty_ctl_header (dir_h); - } - dir_h->nreg++; header->parent = dir; err =insert_links (header);@@ -254,8 +219,6 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)erase_header (header);put_links (header); fail_links: -if (header->ctl_table == sysctl_mount_point) -sysctl_clear_perm_empty_ctl_header (dir_h); header->parent =NULL ;drop_sysctl_table (dir_h);return err;@@ -442,6 +405,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, struct ctl_table_header *head, const struct ctl_table *table) { struct ctl_table_root *root = head->root; +struct ctl_dir *ctl_dir;struct inode *inode;struct proc_inode *ei;@@ -475,7 +439,9 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, inode->i_mode |=S_IFDIR ; inode->i_op = &proc_sys_dir_operations; inode->i_fop = &proc_sys_dir_file_operations; -if (sysctl_is_perm_empty_ctl_header (head)) + + ctl_dir = container_of(head, struct ctl_dir, header); +if (ctl_dir->permanently_empty)make_empty_dir_inode (inode); }@@ -1214,8 +1180,7 @@ static bool get_links(struct ctl_dir *dir,struct ctl_table_header *tmp_head;const struct ctl_table *entry, *link; -if (header->ctl_table_size ==0 || -sysctl_is_perm_empty_ctl_header (header)) +if (header->ctl_table_size ==0 || dir->permanently_empty)return true;/* Are there links available for every entry in table? */ @@ -1536,6 +1501,33 @@ void unregister_sysctl_table(struct ctl_table_header * header) }EXPORT_SYMBOL (unregister_sysctl_table); +/** +* register_sysctl_mount_point() - registers a sysctl mount point +* @path: path for the mount point +* +* Used to create a permanently empty directory to serve as mount point. +* There are some subtle but important permission checks this allows in the +* case of unprivileged mounts. +*/ +struct ctl_table_header *register_sysctl_mount_point (const char *path) +{ +struct ctl_dir *dir =sysctl_mkdir_p (&sysctl_table_root.default_set.dir, path); + +if (IS_ERR (dir)) +return NULL ; + +guard (spinlock)(&sysctl_lock); + +if (!RB_EMPTY_ROOT (&dir->root)) { +drop_sysctl_table (&dir->header); +return NULL ; + } + + dir->permanently_empty = true; +return &dir->header; +} +EXPORT_SYMBOL (register_sysctl_mount_point); +void setup_sysctl_set (struct ctl_table_set *set,struct ctl_table_root *root,int (*is_seen)(struct ctl_table_set *))include/linux/sysctl.h +2
-11@@ -177,23 +177,14 @@ struct ctl_table_header {struct ctl_dir *parent;struct ctl_node *node;struct hlist_head inodes;/* head for proc_inode->sysctl_inodes */ -/** -* enum type - Enumeration to differentiate between ctl target types -* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations -* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently -* empty directory target to serve -* as mount point. -*/ -enum { -SYSCTL_TABLE_TYPE_DEFAULT , -SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY - } type; };struct ctl_dir {/* Header must be at the start of ctl_dir */ struct ctl_table_header header;struct rb_root root; +/* Permanently empty directory target to serve as mount point. */ +bool permanently_empty; };struct ctl_table_set {base-commit:
a6fd07f80ab7bd94edb4d56c35e61117ffb9957e
prerequisite-patch-id: 0000000000000000000000000000000000000000
prerequisite-patch-id:13932e9add940cb65c71e04b5efdfcd3622fd27e
prerequisite-patch-id:2e4d88f7b8aaa805598f0e87a3ea726825bb4264
prerequisite-patch-id:674a680d9cb138cd34cfd0e1a4ec3a5d1c220078
prerequisite-patch-id:e27c92582aa20b1dfb122c172b336dbaf9d6508a
prerequisite-patch-id:9b409a34ab6a4d8d8c5225ba9a72db3116e3c8b3
prerequisite-patch-id:86ff15a81d850ebda16bb707491251f4b705e4fd
prerequisite-patch-id:b7ab65512ac9acfb2dd482b0271b399467afc56d
prerequisite-patch-id:0354922fbf2508a89f3e9d9a4e274fc98deb2e93
prerequisite-patch-id:b71389e82026ffc19cbb717bba1a014ad6cab6da
prerequisite-patch-id:fbb0201f89bf6c41d0585af867bdeec8d51649b2
prerequisite-patch-id:e3b4b5b69b4eadf87ed97beb8c03a471e7628cb9
prerequisite-patch-id:3fbc9745cf3f28872b3e63f6d1f6e2fd7598be8a
prerequisite-patch-id:ba2b190c2e54cfb505a282e688c2222712f0acd7
prerequisite-patch-id:47e5ca730748bb7bf9248a9e711045d8c1028199
prerequisite-patch-id:dcd9f87f00290d2f9be83e404f8883eb90c5fb1c
prerequisite-patch-id:d4629be1a61585ab821da2d2850f246761f72f25
prerequisite-patch-id:f740190f4b94e57cbf3659f220d94483713341a1
prerequisite-patch-id:301c2e530e2af4568267e19247d4a49ac2a9871dSignature · 1 line
2.43.0Signature · 1 line
Joel Granados
Signature · 1 line
Joel Granados
Re: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header
In reply to Luis ChamberlainQuoted 21 lines · Luis Chamberlain
Quoted 16 lines · Thomas Weißschuh
Quoted 4 lines · Luis Chamberlain
Quoted 3 lines · Thomas Weißschuh
fs/proc/proc_sysctl.c +0
-0@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)return -EROFS ;Quoted 9 lines
fs/proc/proc_sysctl.c static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) · line 238
Quoted 7 lines
fs/proc/proc_sysctl.c +2
-1/* Am I creating a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (header)) { +if (header->ctl_table == sysctl_mount_point || +sysctl_is_perm_empty_ctl_header (header)) {if (!RB_EMPTY_ROOT (&dir->root))return -EINVAL ;sysctl_set_perm_empty_ctl_header (dir_h);While you're at it.
Quoted 1 line
This hunk is completely gone in v3/the code that you merged.
It is worse in that it is not obvious:
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (table == sysctl_mount_point) + sysctl_set_perm_empty_ctl_header(head);
Notice that the test is done on the header and the set is done on the dir_h.
I mention this because here you wrote:
"sysctl_set_perm_empty_ctl_header(head)"
instead of
"sysctl_set_perm_empty_ctl_header(dir_h)"
dir_h and head are different.
Was this your concern? or did I miss your point?
Quoted 11 lines
Quoted 2 lines
Which kind of unsafety do you envision here?
Making the code obvious during patch review hy this is needed / special, and if we special case this, why not remove enum, and make it specific to only that one table. The catch is that it is not immediately obvious that we actually call
sysctl_set_perm_empty_ctl_header()in other places, and it begs the question if this can be cleaned up somehow.Luis
Signature · 1 line
Joel Granados
Re: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header
In reply to Thomas WeißschuhThis is the patch that I said could be on its own to facilitate review
Quoted 42 lines · Thomas Weißschuh
In a future commit the sysctl core will only use
"const structctl_table". As a preparation for that move this mutable field from "structctl_table" to "structctl_table_header".This is also more correct in general as this is in fact a property of the header and not the table itself.
Signed-off-by Thomas Weißschuh <[email protected]>--- fs/proc/proc_sysctl.c | 11 ++++++----- include/linux/sysctl.h | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-)fs/proc/proc_sysctl.c +4
-4@@ -31,7 +31,7 @@ static const struct inode_operations proc_sys_dir_operations;/* Support for permanently empty directories */ static struct ctl_table sysctl_mount_point[] = { - {.type =SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY } + { } };/** @@ -49,11 +49,11 @@ struct ctl_table_header *register_sysctl_mount_point(const char *path)EXPORT_SYMBOL (register_sysctl_mount_point);#define sysctl_is_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) + (hptr->type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY)#define sysctl_set_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) + (hptr->type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY)#define sysctl_clear_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_DEFAULT) + (hptr->type = SYSCTL_TABLE_TYPE_DEFAULT)void proc_sys_poll_notify (struct ctl_table_poll *poll) {
fs/proc/proc_sysctl.c static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) · line 235
Quoted 6 lines
fs/proc/proc_sysctl.c +2
-1@@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)return -EROFS ;/* Am I creating a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (header)) { +if (header->ctl_table == sysctl_mount_point || +sysctl_is_perm_empty_ctl_header (header)) {
Why do you have to check that it is equal to sysctl_mount_point? It should be enough to make sure that the type of PERMANENTLY_EMPTY. no?
Quoted 47 lines
fs/proc/proc_sysctl.c +0
-0if (!RB_EMPTY_ROOT (&dir->root))return -EINVAL ;sysctl_set_perm_empty_ctl_header (dir_h);include/linux/sysctl.h +11
-11@@ -137,17 +137,6 @@ struct ctl_table {void *data;int maxlen;umode_t mode; -/** -* enum type - Enumeration to differentiate between ctl target types -* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations -* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently -* empty directory target to serve -* as mount point. -*/ -enum { -SYSCTL_TABLE_TYPE_DEFAULT , -SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY - } type;proc_handler *proc_handler;/* Callback for text formatting */ struct ctl_table_poll *poll;void *extra1;@@ -188,6 +177,17 @@ struct ctl_table_header {struct ctl_dir *parent;struct ctl_node *node;struct hlist_head inodes;/* head for proc_inode->sysctl_inodes */ +/** +* enum type - Enumeration to differentiate between ctl target types +* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations +* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently +* empty directory target to serve +* as mount point. +*/ +enum { +SYSCTL_TABLE_TYPE_DEFAULT , +SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY + } type; };struct ctl_dir {Signature · 2 lines
-- 2.43.0
Signature · 1 line
Joel Granados
PATCH v2 14/18 sysctl: move internal interfaces to const struct ctl_table
In reply to Thomas WeißschuhAs a preparation to make all the sysctl code work with const struct ctl_table switch over the internal function to use the const variant.
--- fs/proc/internal.h | 2 +- fs/proc/proc_sysctl.c | 81 +++++++++++++++++++++++++------------------------- include/linux/sysctl.h | 2 +- 3 files changed, 43 insertions(+), 42 deletions(-)
fs/proc/internal.h +1 -1
@@ -101,7 +101,7 @@ struct proc_inode {union proc_op op;struct proc_dir_entry *pde;struct ctl_table_header *sysctl; -struct ctl_table *sysctl_entry; +const struct ctl_table *sysctl_entry;struct hlist_node sibling_inodes;const struct proc_ns_operations *ns_ops;struct inode vfs_inode;
fs/proc/proc_sysctl.c +41 -40
293 lines not on this page · raw message
include/linux/sysctl.h +1 -1
@@ -162,7 +162,7 @@ struct ctl_node { struct ctl_table_header { union { struct { - struct ctl_table *ctl_table; + const struct ctl_table *ctl_table; int ctl_table_size; int used; int count;
Signature · 1 line
2.43.0
PATCH v2 15/18 sysctl: allow registration of const struct ctl_table
In reply to Thomas WeißschuhThis allows sysctl table to be put into read-only data.
--- fs/proc/proc_sysctl.c | 6 +++--- include/linux/sysctl.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-)
fs/proc/proc_sysctl.c +3 -3
@@ -1356,7 +1356,7 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path)*/ struct ctl_table_header *__register_sysctl_table (struct ctl_table_set *set, -const char *path,struct ctl_table *table,size_t table_size) +const char *path,const struct ctl_table *table,size_t table_size) {struct ctl_table_root *root = set->dir.header.root;struct ctl_table_header *header;
@@ -1417,7 +1417,7 @@ struct ctl_table_header *__register_sysctl_table(* * See __register_sysctl_table for more details. */ -struct ctl_table_header *register_sysctl_sz (const char *path,struct ctl_table *table, +struct ctl_table_header *register_sysctl_sz (const char *path,const struct ctl_table *table,size_t table_size) { return __register_sysctl_table(&sysctl_table_root.default_set,
@@ -1446,7 +1446,7 @@ EXPORT_SYMBOL(register_sysctl_sz);* * Context: if your base directory does not exist it will be created for you. */ -void __init __register_sysctl_init (const char *path,struct ctl_table *table, +void __init __register_sysctl_init (const char *path,const struct ctl_table *table,const char *table_name,size_t table_size) {struct ctl_table_header *hdr =register_sysctl_sz (path, table, table_size);
include/linux/sysctl.h +5 -5
@@ -229,13 +229,13 @@ extern void retire_sysctl_set(struct ctl_table_set *set);struct ctl_table_header *__register_sysctl_table (struct ctl_table_set *set, -const char *path,struct ctl_table *table,size_t table_size); -struct ctl_table_header *register_sysctl_sz (const char *path,struct ctl_table *table, +const char *path,const struct ctl_table *table,size_t table_size); +struct ctl_table_header *register_sysctl_sz (const char *path,const struct ctl_table *table,size_t table_size);void unregister_sysctl_table (struct ctl_table_header * table);extern int sysctl_init_bases (void ); -extern void __register_sysctl_init (const char *path,struct ctl_table *table, +extern void __register_sysctl_init (const char *path,const struct ctl_table *table,const char *table_name,size_t table_size);#define register_sysctl_init (path, table) \ __register_sysctl_init(path, table, #table, ARRAY_SIZE(table))
@@ -257,7 +257,7 @@ extern int no_unaligned_warning;#else /* CONFIG_SYSCTL */ -static inline void register_sysctl_init (const char *path,struct ctl_table *table) +static inline void register_sysctl_init (const char *path,const struct ctl_table *table) { }
@@ -267,7 +267,7 @@ static inline struct ctl_table_header *register_sysctl_mount_point(const char *p }static inline struct ctl_table_header *register_sysctl_sz (const char *path, -struct ctl_table *table, +const struct ctl_table *table,size_t table_size) {return NULL ;
Signature · 1 line
2.43.0
PATCH v2 16/18 const_structs.checkpatch: add ctl_table
In reply to Thomas WeißschuhNow that the sysctl core can handle "const struct ctl_table", make sure that new usages of the struct already enter the tree as const.
--- scripts/const_structs.checkpatch | 1 + 1 file changed, 1 insertion(+)
scripts/const_structs.checkpatch +1 -0
@@ -5,6 +5,7 @@ block_device_operations clk_ops comedi_lrange component_ops +ctl_table dentry_operations dev_pm_ops dma_map_ops
Signature · 1 line
2.43.0
PATCH v2 17/18 sysctl: make ctl_table sysctl_mount_point const
In reply to Thomas WeißschuhThis is a first example on how to use const struct ctl_table.
--- fs/proc/proc_sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/proc_sysctl.c +1 -1
@@ -30,7 +30,7 @@ static const struct file_operations proc_sys_dir_file_operations;static const struct inode_operations proc_sys_dir_operations;/* Support for permanently empty directories */ -static struct ctl_table sysctl_mount_point[] = { +static const struct ctl_table sysctl_mount_point[] = { { } };
Signature · 1 line
2.43.0
PATCH v2 18/18 sysctl: constify standard sysctl tables
In reply to Thomas WeißschuhRecent changes in the sysctl allow sysctl tables to be put into .rodata.
--- kernel/sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sysctl.c +1 -1
@@ -1615,7 +1615,7 @@ int proc_do_static_key(const struct ctl_table *table, int write,return ret; } -static struct ctl_table kern_table[] = { +static const struct ctl_table kern_table[] = { { .procname ="panic" , .data = &panic_timeout,
Signature · 1 line
2.43.0
Luis Chamberlain
maintainerQuoted 1 line · Thomas Weißschuh
Tested by booting and with the sysctl selftests on x86.
Can I trouble you to rebase on sysctl-next?
https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-next
Luis
Quoted 6 lines · Luis Chamberlain
Quoted 1 line · Thomas Weißschuh
Tested by booting and with the sysctl selftests on x86.
Can I trouble you to rebase on sysctl-next?
https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-next
Will do.
Note:
I noticed that patch "sysctl: move sysctl type to ctl_table_header" from this series seems to be the better alternative to
commit fd696ee2395755a ("sysctl: Fix out of bounds access for empty sysctl registers") which is currently on sysctl-next.
The patch from the series should only depend on "sysctl: drop sysctl_is_perm_empty_ctl_table" from my series.
Thomas
Hi Luis, Joel,
Quoted 9 lines · Thomas Weißschuh
Quoted 6 lines · Luis Chamberlain
Quoted 1 line · Thomas Weißschuh
Tested by booting and with the sysctl selftests on x86.
Can I trouble you to rebase on sysctl-next?
https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-next
Will do.
The rebased series is now available at
https://git.sr.ht/~t-8ch/linux b4/const-sysctl
Nothing much has changed in contrast to v2.
The only functional change so far is the initialization of ctl_table_header::type in init_header().
I'll wait for Joels and maybe some more reviews before resending it.
Quoted 1 line
[..]
For the future I think it would make sense to combine the tree-wide constification of the structs with the removal of the sentinel values.
This would reduce the impacts of the maintainers.
Thomas
Luis Chamberlain
maintainerQuoted 7 lines · Thomas Weißschuh
Hi Luis, Joel,
Quoted 4 lines · Thomas Weißschuh
Quoted 3 lines · Luis Chamberlain
Quoted 1 line · Thomas Weißschuh
Tested by booting and with the sysctl selftests on x86.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Can I trouble you to rebase on sysctl-next?
https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-next
Will do.
The rebased series is now available at
https://git.sr.ht/~t-8ch/linux b4/const-sysctl
I've applied this to sysctl-next as this all looks very sensible to me, except one patch which I'll chime in on, but I'm merging it to sysctl-next now without a promise to get this in as I really would like this to soak in on linux-next for a bit even if it does not get merged in the next kernel release. Exposing it on linux-next will surely iron out run time issues fast.
Quoted 5 lines
Nothing much has changed in contrast to v2.
The only functional change so far is the initialization ofctl_table_header::typeininit_header().I'll wait for Joels and maybe some more reviews before resending it.
It all is very trivial stuff, except a few patches, but it all is making sense, so my ask is to address feedback this week and post next week a new set so we can have changes merged as-is for Linux in case this really doesn't break anything.
For some reason I raccall seeing som hacky sysclts that shared and modified an entry somewhere but the exact sysctl phases me, and I just cannot recall.
Quoted 6 lines
Quoted 1 line
[..]
For the future I think it would make sense to combine the tree-wide constification of the structs with the removal of the sentinel values.
This would reduce the impacts of the maintainers.
Indeed.
Luis
Quoted 12 lines · Luis Chamberlain
Quoted 11 lines · Thomas Weißschuh
Hi Luis, Joel,
Quoted 8 lines · Thomas Weißschuh
Quoted 6 lines · Luis Chamberlain
Quoted 1 line · Thomas Weißschuh
Tested by booting and with the sysctl selftests on x86.
Can I trouble you to rebase on sysctl-next?
https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-next
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Will do.
The rebased series is now available at
https://git.sr.ht/~t-8ch/linux b4/const-sysctlI've applied this to sysctl-next as this all looks very sensible to me, except one patch which I'll chime in on, but I'm merging it to
That is the "move sysctl type to ctl_table_header" right?
Quoted 4 lines
sysctl-next now without a promise to get this in as I really would like this to soak in on linux-next for a bit even if it does not get merged in the next kernel release. Exposing it on linux-next will surely iron out run time issues fast.
+1 for soaking it :)
Quoted 11 lines
Quoted 6 lines
Nothing much has changed in contrast to v2.
The only functional change so far is the initialization ofctl_table_header::typeininit_header().I'll wait for Joels and maybe some more reviews before resending it.
It all is very trivial stuff, except a few patches, but it all is making sense, so my ask is to address feedback this week and post next week a new set so we can have changes merged as-is for Linux in case this really doesn't break anything.
Any thoughts on the size of the tree-wide patches?
Quoted 4 lines
For some reason I raccall seeing som hacky sysclts that shared and modified an entry somewhere but the exact sysctl phases me, and I just cannot recall.
Its probably in net/*. There is were they are really taking advantage of ctl_table.
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
[..]
For the future I think it would make sense to combine the tree-wide constification of the structs with the removal of the sentinel values.
This would reduce the impacts of the maintainers.
Indeed.
Luis
Signature · 1 line
Joel Granados
Quoted 20 lines · Thomas Weißschuh
Hi Luis, Joel,
Quoted 9 lines · Thomas Weißschuh
Quoted 6 lines · Luis Chamberlain
Quoted 1 line · Thomas Weißschuh
Tested by booting and with the sysctl selftests on x86.
Can I trouble you to rebase on sysctl-next?
https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-next
Will do.
The rebased series is now available at
https://git.sr.ht/~t-8ch/linux b4/const-sysctlNothing much has changed in contrast to v2.
The only functional change so far is the initialization ofctl_table_header::typeininit_header().
Quoted 6 lines
I'll wait for Joels and maybe some more reviews before resending it.
Quoted 1 line
[..]
For the future I think it would make sense to combine the tree-wide constification of the structs with the removal of the sentinel values.
I don't see how these two would fit. And this is why:
1. The "remove sentinel" stuff is almost done. With the sets going into 6.7 we would only be missing everything under net/*. So you would not be able to combine them (except for the net stuff)
2. The motivation for the two sets is differnt. This would confuse rather than simplify the process.
3. In order to introduce the const stuff we would have to go through another round of "convincing" which can potentially derail the "remove sentinel" stuff.
I would *not* like to combine them. I think the const set can stand on its own.
Quoted 5 lines
This would reduce the impacts of the maintainers.
Thomas
Signature · 1 line
Joel Granados
Quoted 28 lines · Joel Granados
Quoted 20 lines · Thomas Weißschuh
Hi Luis, Joel,
Quoted 9 lines · Thomas Weißschuh
Quoted 6 lines · Luis Chamberlain
Quoted 1 line · Thomas Weißschuh
Tested by booting and with the sysctl selftests on x86.
Can I trouble you to rebase on sysctl-next?
https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-next
Will do.
The rebased series is now available at
https://git.sr.ht/~t-8ch/linux b4/const-sysctlNothing much has changed in contrast to v2.
The only functional change so far is the initialization ofctl_table_header::typeininit_header().Quoted 6 lines
I'll wait for Joels and maybe some more reviews before resending it.
Quoted 1 line
[..]
For the future I think it would make sense to combine the tree-wide constification of the structs with the removal of the sentinel values.
Quoted 9 lines
I don't see how these two would fit. And this is why:
1. The "remove sentinel" stuff is almost done. With the sets going into 6.7 we would only be missing everything undernet/*. So you would not be able to combine them (except for the net stuff)
2. The motivation for the two sets is differnt. This would confuse rather than simplify the process.
3. In order to introduce the const stuff we would have to go through another round of "convincing" which can potentially derail the "remove sentinel" stuff.
Good reasons, especially 1).
Quoted 2 lines
I would *not* like to combine them. I think the const set can stand on its own.
It was more about a process optimization. If somebody has to touch each sysctl table anyway and test the changes, doing so for both series would be easier for the sysctl and subsystem maintainers.
But alas, it seems I have to do it myself and can't heap it onto your pile :-)
Quoted 2 lines
Quoted 2 lines
This would reduce the impacts of the maintainers.
Quoted 8 lines · Thomas Weißschuh
Quoted 6 lines · Luis Chamberlain
Quoted 1 line · Thomas Weißschuh
Tested by booting and with the sysctl selftests on x86.
Can I trouble you to rebase on sysctl-next?
https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-next
Quoted 8 lines
Will do.
Note:
I noticed that patch "sysctl: move sysctl type to
ctl_table_header" from this series seems to be the better alternative to
commitfd696ee2395755a("sysctl: Fix out of bounds access for empty sysctl registers") which is currently on sysctl-next.
Indeed. By taking this out of the ctl_table, we would not need to make sure that we don't touch that (potentially non-existing) first element.
This is what I think should be done (@Luis @Kees chime in if you have any thoughts):
1. Leave the current fix for 6.7. AFAIK, it is already queued for that release and it is a bit late in the cycle to put anything new in.
2. I think this patch has value on its own as a better solution to the "access invalid memory" issue. @thomas: remove this patch from your const set and send it in a different patch series.
3. const patchset would need to go on top of the new set.
Having it on its own will allow it to go in faster and make it easier to review without having to thinkg about the const stuff as well.
Best
Quoted 5 lines
The patch from the series should only depend on "sysctl: drop
sysctl_is_perm_empty_ctl_table" from my series.Thomas
Signature · 1 line
Joel Granados
Hey Thomas
You have a couple of test bot issues for your 12/18 patch. Can you please address those for your next version.
Quoted 5 lines · Thomas Weißschuh
Problem description:
The kernel contains a lot of struct
ctl_tablethrought the tree. These are very often 'static' definitions.
It would be good to make the tables unmodifiable by marking them "const"
Here I would remove "It would be good to". Just state it: "Make the tables unmodifiable...."
Quoted 3 lines
to avoid accidental or malicious modifications.
This is in line with a general effort to move as much data as possible into .rodata. (See for example[0] and [1])
If you could find more examples, it would make a better case.
Quoted 11 lines
Unfortunately the tables can not be made const right now because the core registration functions expect mutable tables.
This is for two main reasons:
1) sysctl_{set,clear}_perm_empty_ctl_header in the sysctl core modify the table.
2) The table is passed to the handler function as a non-const pointer.This series migrates the core and all handlers.
awesome!
Quoted 12 lines
Structure of the series:
Patch 1-3: Cleanup patches Patch 4-7: Non-logic preparation patches Patch 8: Preparation patch changing a bit of logic Patch 9-12: Treewide changes to handler function signature Patch 13-14: Adaption of the sysctl core implementation Patch 15: Adaption of the sysctl core interface Patch 16: New entry for checkpatch Patch 17-18: Constification of existing "struct ctl_table"s
Quoted 7 lines
Tested by booting and with the sysctl selftests on x86.
Note:
This is intentionally sent only to a small number of people as I'd like to get some more sysctl core-maintainer feedback before sending this to essentially everybody.
When you do send it to the broader audience, you should chunk up your big patches (12/18 and 11/18) and this is why:
1. To avoid mail rejections from lists:
You have to tell a lot of people about the changes in one mail. That will make mail header too big for some lists and it will be rejected. This happened to me with [3]
2. Avoid being rejected for the wrong reasons :)
Maintainers are busy ppl and sending them a set with so many files may elicit a rejection on the grounds that it involves too many subsystems at the same time.
I suggest you chunk it up with directories in mind. Something similar to what I did for [4] where I divided stuff that when for fs/*, kernel/*, net/*, arch/* and drivers/*. That will complicate your patch a tad because you have to ensure that the tree can be compiled/run for every commit. But it will pay off once you push it to the broader public.
[3] https://lore.kernel.org/all/[email protected]
[4] https://lore.kernel.org/all/[email protected]
Quoted 153 lines
[0]
43a7206b0963("driver core: class: makeclass_register()take a const *")
[1] https://lore.kernel.org/lkml/[email protected]/---
Changes in v2:
- Migrate all handlers.
- Remove intermediate "proc_handler_new" step (Thanks Joel).
- Drop RFC status.
- Prepare other parts of the tree.
- Link to v1: https://lore.kernel.org/r/[email protected]---
Thomas Weißschuh (18):
watchdog/core: remove sysctl handlers from public header
sysctl: delete unused defineSYSCTL_PERM_EMPTY_DIR
sysctl: dropsysctl_is_perm_empty_ctl_table
cgroup: bpf: constifyctl_tablearguments and fields
seccomp: constifyctl_tablearguments of utility functions
hugetlb: constifyctl_tablearguments of utility functions
utsname: constifyctl_tablearguments of utility function
stackleak: don't modifyctl_tableargument
sysctl: treewide: constifyctl_table_root::set_ownership
sysctl: treewide: constifyctl_table_root::permissions
sysctl: treewide: constifyctl_table_header::ctl_table_arg
sysctl: treewide: constify thectl_tableargument of handlers
sysctl: move sysctl type toctl_table_header
sysctl: move internal interfaces to const structctl_table
sysctl: allow registration of const structctl_tableconst_structs.checkpatch: addctl_table
sysctl: makectl_tablesysctl_mount_pointconst
sysctl: constify standard sysctl tablesarch/arm64/kernel/armv8_deprecated.c | 2 +- arch/arm64/kernel/fpsimd.c | 2 +- arch/s390/appldata/appldata_base.c | 8 +-- 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 | 4 +- drivers/macintosh/mac_hid.c | 2 +- drivers/net/vrf.c | 4 +- drivers/parport/procfs.c | 12 ++-- fs/coredump.c | 2 +- fs/dcache.c | 4 +- fs/drop_caches.c | 2 +- fs/exec.c | 4 +- fs/file_table.c | 2 +- fs/fs-writeback.c | 2 +- fs/inode.c | 4 +- fs/pipe.c | 2 +- fs/proc/internal.h | 2 +- fs/proc/proc_sysctl.c | 102 +++++++++++++++--------------- fs/quota/dquot.c | 2 +- fs/xfs/xfs_sysctl.c | 6 +- include/linux/bpf-cgroup.h | 2 +- include/linux/filter.h | 2 +- include/linux/ftrace.h | 4 +- include/linux/mm.h | 8 +-- include/linux/nmi.h | 7 -- include/linux/perf_event.h | 6 +- include/linux/security.h | 2 +- include/linux/sysctl.h | 78 +++++++++++------------ 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 | 12 ++-- ipc/mq_sysctl.c | 2 +- kernel/bpf/cgroup.c | 2 +- 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 | 4 +- 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 | 12 ++-- kernel/sched/topology.c | 2 +- kernel/seccomp.c | 8 +-- kernel/stackleak.c | 9 +-- kernel/sysctl.c | 84 ++++++++++++------------ 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/ucount.c | 4 +- kernel/umh.c | 2 +- kernel/utsname_sysctl.c | 4 +- kernel/watchdog.c | 15 +++-- mm/compaction.c | 8 +-- mm/hugetlb.c | 10 +-- mm/page-writeback.c | 18 +++--- mm/page_alloc.c | 22 +++---- mm/util.c | 12 ++-- mm/vmstat.c | 4 +- net/ax25/sysctl_net_ax25.c | 2 +- net/bridge/br_netfilter_hooks.c | 6 +- net/core/neighbour.c | 24 +++---- net/core/sysctl_net_core.c | 22 +++---- net/ieee802154/6lowpan/reassembly.c | 2 +- net/ipv4/devinet.c | 8 +-- net/ipv4/ip_fragment.c | 2 +- net/ipv4/route.c | 4 +- net/ipv4/sysctl_net_ipv4.c | 35 +++++----- net/ipv4/xfrm4_policy.c | 2 +- net/ipv6/addrconf.c | 29 +++++---- net/ipv6/ndisc.c | 4 +- net/ipv6/netfilter/nf_conntrack_reasm.c | 2 +- net/ipv6/reassembly.c | 2 +- net/ipv6/route.c | 2 +- net/ipv6/sysctl_net_ipv6.c | 10 +-- net/ipv6/xfrm6_policy.c | 2 +- net/mpls/af_mpls.c | 8 +-- net/mptcp/ctrl.c | 2 +- net/netfilter/ipvs/ip_vs_ctl.c | 16 ++--- net/netfilter/nf_conntrack_standalone.c | 4 +- net/netfilter/nf_hooks_lwtunnel.c | 2 +- net/netfilter/nf_log.c | 4 +- net/phonet/sysctl.c | 2 +- net/rds/tcp.c | 4 +- net/sctp/sysctl.c | 30 ++++----- net/smc/smc_sysctl.c | 2 +- net/sunrpc/sysctl.c | 6 +- net/sunrpc/xprtrdma/svc_rdma.c | 2 +- net/sysctl_net.c | 4 +- net/unix/sysctl_net_unix.c | 2 +- net/xfrm/xfrm_sysctl.c | 2 +- scripts/const_structs.checkpatch | 1 + security/apparmor/lsm.c | 2 +- security/min_addr.c | 2 +- security/yama/yama_lsm.c | 2 +- 111 files changed, 427 insertions(+), 428 deletions(-)---
base-commit:33cc938e65a98f1d29d0a18403dbbee050dcad9a
change-id: 20231116-const-sysctl-e14624f1295cBest regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
Signature · 1 line
Joel Granados
Quoted 4 lines · Joel Granados
Hey Thomas
You have a couple of test bot issues for your 12/18 patch. Can you please address those for your next version.
I have these fixed locally, I assumed Luis would also pick them up directly until I have a proper v2, properly should have communicated that.
Quoted 8 lines · Thomas Weißschuh
Quoted 5 lines
Problem description:
The kernel contains a lot of struct
ctl_tablethrought the tree. These are very often 'static' definitions.
It would be good to make the tables unmodifiable by marking them "const"Here I would remove "It would be good to". Just state it: "Make the tables unmodifiable...."
Ack.
Quoted 6 lines
Quoted 4 lines
to avoid accidental or malicious modifications.
This is in line with a general effort to move as much data as possible into .rodata. (See for example[0] and [1])If you could find more examples, it would make a better case.
I'll look for some. So far my constifications went in without them :-)
Quoted 34 lines
Quoted 11 lines
Unfortunately the tables can not be made const right now because the core registration functions expect mutable tables.
This is for two main reasons:
1) sysctl_{set,clear}_perm_empty_ctl_header in the sysctl core modify the table.
2) The table is passed to the handler function as a non-const pointer.This series migrates the core and all handlers.
awesome!
Quoted 12 lines
Structure of the series:
Patch 1-3: Cleanup patches Patch 4-7: Non-logic preparation patches Patch 8: Preparation patch changing a bit of logic Patch 9-12: Treewide changes to handler function signature Patch 13-14: Adaption of the sysctl core implementation Patch 15: Adaption of the sysctl core interface Patch 16: New entry for checkpatch Patch 17-18: Constification of existing "struct ctl_table"sQuoted 7 lines
Tested by booting and with the sysctl selftests on x86.
Note:
This is intentionally sent only to a small number of people as I'd like to get some more sysctl core-maintainer feedback before sending this to essentially everybody.
Quoted 15 lines
When you do send it to the broader audience, you should chunk up your big patches (12/18 and 11/18) and this is why:
1. To avoid mail rejections from lists:
You have to tell a lot of people about the changes in one mail. That will make mail header too big for some lists and it will be rejected. This happened to me with [3]
2. Avoid being rejected for the wrong reasons :)
Maintainers are busy ppl and sending them a set with so many files may elicit a rejection on the grounds that it involves too many subsystems at the same time.
I suggest you chunk it up with directories in mind. Something similar to what I did for [4] where I divided stuff that when forfs/*,kernel/*,net/*,arch/*anddrivers/*. That will complicate your patch a tad because you have to ensure that the tree can be compiled/run for every commit. But it will pay off once you push it to the broader public.
This will break bisections. All function signatures need to be switched in one step. I would strongly like to avoid introducing broken commits.
The fact that these big commits have no functional changes at all makes me hope it can work.
Quoted 80 lines · Thomas Weißschuh
Quoted 4 lines · Joel Granados
Hey Thomas
You have a couple of test bot issues for your 12/18 patch. Can you please address those for your next version.
I have these fixed locally, I assumed Luis would also pick them up directly until I have a proper v2, properly should have communicated that.
Quoted 8 lines · Thomas Weißschuh
Quoted 5 lines
Problem description:
The kernel contains a lot of struct
ctl_tablethrought the tree. These are very often 'static' definitions.
It would be good to make the tables unmodifiable by marking them "const"Here I would remove "It would be good to". Just state it: "Make the tables unmodifiable...."
Ack.
Quoted 6 lines
Quoted 4 lines
to avoid accidental or malicious modifications.
This is in line with a general effort to move as much data as possible into .rodata. (See for example[0] and [1])If you could find more examples, it would make a better case.
I'll look for some. So far my constifications went in without them :-)
Quoted 34 lines
Quoted 11 lines
Unfortunately the tables can not be made const right now because the core registration functions expect mutable tables.
This is for two main reasons:
1) sysctl_{set,clear}_perm_empty_ctl_header in the sysctl core modify the table.
2) The table is passed to the handler function as a non-const pointer.This series migrates the core and all handlers.
awesome!
Quoted 12 lines
Structure of the series:
Patch 1-3: Cleanup patches Patch 4-7: Non-logic preparation patches Patch 8: Preparation patch changing a bit of logic Patch 9-12: Treewide changes to handler function signature Patch 13-14: Adaption of the sysctl core implementation Patch 15: Adaption of the sysctl core interface Patch 16: New entry for checkpatch Patch 17-18: Constification of existing "struct ctl_table"sQuoted 7 lines
Tested by booting and with the sysctl selftests on x86.
Note:
This is intentionally sent only to a small number of people as I'd like to get some more sysctl core-maintainer feedback before sending this to essentially everybody.
Quoted 15 lines
When you do send it to the broader audience, you should chunk up your big patches (12/18 and 11/18) and this is why:
1. To avoid mail rejections from lists:
You have to tell a lot of people about the changes in one mail. That will make mail header too big for some lists and it will be rejected. This happened to me with [3]
2. Avoid being rejected for the wrong reasons :)
Maintainers are busy ppl and sending them a set with so many files may elicit a rejection on the grounds that it involves too many subsystems at the same time.
I suggest you chunk it up with directories in mind. Something similar to what I did for [4] where I divided stuff that when forfs/*,kernel/*,net/*,arch/*anddrivers/*. That will complicate your patch a tad because you have to ensure that the tree can be compiled/run for every commit. But it will pay off once you push it to the broader public.
Quoted 1 line
This will break bisections. All function signatures need to be switched
I was suggesting a solution without breaking bisections of course. I can think of a couple of ways to do this in chunks but it might be premature. You can send it and if you get push back because of this then we can deal with chunking it down.
I'm still concerned about the header size for those mails. How does the mail look like when you run the get maintainers script on it?
Quoted 4 lines
in one step. I would strongly like to avoid introducing broken commits.
The fact that these big commits have no functional changes at all makes me hope it can work.
Signature · 1 line
Joel Granados
Quoted 11 lines · Joel Granados
Quoted 1 line · Thomas Weißschuh
On 2023-12-07 11:43:57+0100, Joel Granados wrote:
[..]
Quoted 6 lines
Quoted 5 lines
I suggest you chunk it up with directories in mind. Something similar to what I did for [4] where I divided stuff that when for
fs/*,kernel/*,net/*,arch/*anddrivers/*. That will complicate your patch a tad because you have to ensure that the tree can be compiled/run for every commit. But it will pay off once you push it to the broader public.
Quoted 6 lines
Quoted 1 line
This will break bisections. All function signatures need to be switched
I was suggesting a solution without breaking bisections of course. I can think of a couple of ways to do this in chunks but it might be premature. You can send it and if you get push back because of this then we can deal with chunking it down.
I'm curious about those ways. I don't see how to split the big commit.
Quoted 2 lines
I'm still concerned about the header size for those mails. How does the mail look like when you run the get maintainers script on it?
The full series has 142 recipients in total,
the biggest patch itself has 124.
Before sending it I'd like to get feedback on the internal rework of the is_empty detection from you and/or Luis.
https://git.sr.ht/~t-8ch/linux/commit/ea27507070f3c47be6febebe451bbb88f6ea707e
or the attached patch.
Quoted 1 line
[..]
From ea27507070f3c47be6febebe451bbb88f6ea707e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <[email protected]>
Date: Sun, 3 Dec 2023 21:56:46 +0100
Subject: [PATCH] sysctl: move permanently empty flag to ctl_dir
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Simplify the logic by always keeping the permanently_empty flag on the ctl_dir.
The previous logic kept the flag in the leaf ctl_table and from there transferred it to the ctl_table from the directory.
This also removes the need to have a mutable ctl_table and will allow the constification of those structs.
--- fs/proc/proc_sysctl.c | 74 +++++++++++++++++++----------------------- include/linux/sysctl.h | 13 ++------ 2 files changed, 36 insertions(+), 51 deletions(-)
fs/proc/proc_sysctl.c +34 -40
@@ -17,6 +17,7 @@#include <linux/bpf-cgroup.h> #include <linux/mount.h> #include <linux/kmemleak.h> +#include <linux/cleanup.h> #include "internal.h" #define list_for_each_table_entry (entry, header) \
@@ -29,32 +30,6 @@ static const struct inode_operations proc_sys_inode_operations;static const struct file_operations proc_sys_dir_file_operations;static const struct inode_operations proc_sys_dir_operations; -/* Support for permanently empty directories */ -static struct ctl_table sysctl_mount_point[] = { - {.type =SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY } -}; - -/** -* register_sysctl_mount_point() - registers a sysctl mount point -* @path: path for the mount point -* -* Used to create a permanently empty directory to serve as mount point. -* There are some subtle but important permission checks this allows in the -* case of unprivileged mounts. -*/ -struct ctl_table_header *register_sysctl_mount_point (const char *path) -{ -return register_sysctl (path, sysctl_mount_point); -} -EXPORT_SYMBOL (register_sysctl_mount_point); - -#define sysctl_is_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_set_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_clear_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_DEFAULT) -void proc_sys_poll_notify (struct ctl_table_poll *poll) {if (!poll)
@@ -226,17 +201,9 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)/* Is this a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (dir_h)) +if (dir->permanently_empty)return -EROFS ; -/* Am I creating a permanently empty directory? */ -if (header->ctl_table_size >0 && -sysctl_is_perm_empty_ctl_header (header)) { -if (!RB_EMPTY_ROOT (&dir->root)) -return -EINVAL ; -sysctl_set_perm_empty_ctl_header (dir_h); - } - dir_h->nreg++; header->parent = dir; err =insert_links (header);
@@ -252,8 +219,6 @@ fail:erase_header (header);put_links (header); fail_links: -if (header->ctl_table == sysctl_mount_point) -sysctl_clear_perm_empty_ctl_header (dir_h); header->parent =NULL ;drop_sysctl_table (dir_h);return err;
@@ -440,6 +405,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, struct ctl_table_header *head, struct ctl_table *table) { struct ctl_table_root *root = head->root; +struct ctl_dir *ctl_dir;struct inode *inode;struct proc_inode *ei;
@@ -473,7 +439,9 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, inode->i_mode |=S_IFDIR ; inode->i_op = &proc_sys_dir_operations; inode->i_fop = &proc_sys_dir_file_operations; -if (sysctl_is_perm_empty_ctl_header (head)) + + ctl_dir = container_of(head, struct ctl_dir, header); +if (ctl_dir->permanently_empty)make_empty_dir_inode (inode); }
@@ -1211,8 +1179,7 @@ static bool get_links(struct ctl_dir *dir,struct ctl_table_header *tmp_head;struct ctl_table *entry, *link; -if (header->ctl_table_size ==0 || -sysctl_is_perm_empty_ctl_header (header)) +if (header->ctl_table_size ==0 || dir->permanently_empty)return true;/* Are there links available for every entry in table? */
@@ -1533,6 +1500,33 @@ void unregister_sysctl_table(struct ctl_table_header * header) }EXPORT_SYMBOL (unregister_sysctl_table); +/** +* register_sysctl_mount_point() - registers a sysctl mount point +* @path: path for the mount point +* +* Used to create a permanently empty directory to serve as mount point. +* There are some subtle but important permission checks this allows in the +* case of unprivileged mounts. +*/ +struct ctl_table_header *register_sysctl_mount_point (const char *path) +{ +struct ctl_dir *dir =sysctl_mkdir_p (&sysctl_table_root.default_set.dir, path); + +if (IS_ERR (dir)) +return NULL ; + +guard (spinlock)(&sysctl_lock); + +if (!RB_EMPTY_ROOT (&dir->root)) { +drop_sysctl_table (&dir->header); +return NULL ; + } + + dir->permanently_empty = true; +return &dir->header; +} +EXPORT_SYMBOL (register_sysctl_mount_point); +void setup_sysctl_set (struct ctl_table_set *set,struct ctl_table_root *root,int (*is_seen)(struct ctl_table_set *))
include/linux/sysctl.h +2 -11
@@ -137,17 +137,6 @@ struct ctl_table {void *data;int maxlen;umode_t mode; -/** -* enum type - Enumeration to differentiate between ctl target types -* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations -* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently -* empty directory target to serve -* as mount point. -*/ -enum { -SYSCTL_TABLE_TYPE_DEFAULT , -SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY - } type;proc_handler *proc_handler;/* Callback for text formatting */ struct ctl_table_poll *poll;void *extra1;
@@ -194,6 +183,8 @@ struct ctl_dir {/* Header must be at the start of ctl_dir */ struct ctl_table_header header;struct rb_root root; +/* Permanently empty directory target to serve as mount point. */ +bool permanently_empty; };struct ctl_table_set {
Signature · 1 line
2.38.5
Quoted 12 lines · Thomas Weißschuh
Quoted 11 lines · Joel Granados
Quoted 1 line · Thomas Weißschuh
On 2023-12-07 11:43:57+0100, Joel Granados wrote:
[..]
Quoted 6 lines
Quoted 5 lines
I suggest you chunk it up with directories in mind. Something similar to what I did for [4] where I divided stuff that when for
fs/*,kernel/*,net/*,arch/*anddrivers/*. That will complicate your patch a tad because you have to ensure that the tree can be compiled/run for every commit. But it will pay off once you push it to the broader public.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
This will break bisections. All function signatures need to be switched
I was suggesting a solution without breaking bisections of course. I can think of a couple of ways to do this in chunks but it might be premature. You can send it and if you get push back because of this then we can deal with chunking it down.
I'm curious about those ways. I don't see how to split the big commit.
My idea was to do something similar to your originl RFC, where you have an temporary proc_handler something like proc_hdlr_const (we would need to work on the name) and move each subsystem to the new handler while the others stay with the non-const one. At the end, the old proc_handler function name would disapear and would be completely replaced by the new proc_hdlr_const.
This is of course extra work and might not be worth it if you don't get negative feedback related to tree-wide changes. Therefore I stick to my previous suggestion. Send the big tree-wide patches and only explore this option if someone screams.
Quoted 6 lines
Quoted 3 lines
I'm still concerned about the header size for those mails. How does the mail look like when you run the get maintainers script on it?
The full series has 142 recipients in total,
the biggest patch itself has 124.
This seems low. might just be enough to make into the lists that have the check.
In any case it depends on the size of the header; if it is greater than 8912 you get a message back similar to this one:
"linux-raid-owne ( 22K) BOUNCE [email protected]: Header field too long (>8192)"
Quoted 3 lines
Before sending it I'd like to get feedback on the internal rework of the
is_emptydetection from you and/or Luis.
Yep, this is still on my todo. With holidays just around the corner, I'll be a bit slower to get to it. I'll eventually get to it if someone else does not beat me to it :)
Thx for reminding me.
Quoted 198 lines
https://git.sr.ht/~t-8ch/linux/commit/ea27507070f3c47be6febebe451bbb88f6ea707e
or the attached patch.Quoted 1 line
[..]
From
ea27507070f3c47be6febebe451bbb88f6ea707eMon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <[email protected]>
Date: Sun, 3 Dec 2023 21:56:46 +0100
Subject: [PATCH] sysctl: move permanently empty flag toctl_dir
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitSimplify the logic by always keeping the
permanently_emptyflag on thectl_dir.
The previous logic kept the flag in the leafctl_tableand from there transferred it to thectl_tablefrom the directory.This also removes the need to have a mutable
ctl_tableand will allow the constification of those structs.Signed-off-by Thomas Weißschuh <[email protected]>--- fs/proc/proc_sysctl.c | 74 +++++++++++++++++++----------------------- include/linux/sysctl.h | 13 ++------ 2 files changed, 36 insertions(+), 51 deletions(-)fs/proc/proc_sysctl.c +34
-40@@ -17,6 +17,7 @@#include <linux/bpf-cgroup.h> #include <linux/mount.h> #include <linux/kmemleak.h> +#include <linux/cleanup.h> #include "internal.h" #define list_for_each_table_entry (entry, header) \@@ -29,32 +30,6 @@ static const struct inode_operations proc_sys_inode_operations;static const struct file_operations proc_sys_dir_file_operations;static const struct inode_operations proc_sys_dir_operations; -/* Support for permanently empty directories */ -static struct ctl_table sysctl_mount_point[] = { - {.type =SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY } -}; - -/** -* register_sysctl_mount_point() - registers a sysctl mount point -* @path: path for the mount point -* -* Used to create a permanently empty directory to serve as mount point. -* There are some subtle but important permission checks this allows in the -* case of unprivileged mounts. -*/ -struct ctl_table_header *register_sysctl_mount_point (const char *path) -{ -return register_sysctl (path, sysctl_mount_point); -} -EXPORT_SYMBOL (register_sysctl_mount_point); - -#define sysctl_is_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_set_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_clear_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_DEFAULT) -void proc_sys_poll_notify (struct ctl_table_poll *poll) {if (!poll)@@ -226,17 +201,9 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)/* Is this a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (dir_h)) +if (dir->permanently_empty)return -EROFS ; -/* Am I creating a permanently empty directory? */ -if (header->ctl_table_size >0 && -sysctl_is_perm_empty_ctl_header (header)) { -if (!RB_EMPTY_ROOT (&dir->root)) -return -EINVAL ; -sysctl_set_perm_empty_ctl_header (dir_h); - } - dir_h->nreg++; header->parent = dir; err =insert_links (header);@@ -252,8 +219,6 @@ fail:erase_header (header);put_links (header); fail_links: -if (header->ctl_table == sysctl_mount_point) -sysctl_clear_perm_empty_ctl_header (dir_h); header->parent =NULL ;drop_sysctl_table (dir_h);return err;@@ -440,6 +405,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, struct ctl_table_header *head, struct ctl_table *table) { struct ctl_table_root *root = head->root; +struct ctl_dir *ctl_dir;struct inode *inode;struct proc_inode *ei;@@ -473,7 +439,9 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, inode->i_mode |=S_IFDIR ; inode->i_op = &proc_sys_dir_operations; inode->i_fop = &proc_sys_dir_file_operations; -if (sysctl_is_perm_empty_ctl_header (head)) + + ctl_dir = container_of(head, struct ctl_dir, header); +if (ctl_dir->permanently_empty)make_empty_dir_inode (inode); }@@ -1211,8 +1179,7 @@ static bool get_links(struct ctl_dir *dir,struct ctl_table_header *tmp_head;struct ctl_table *entry, *link; -if (header->ctl_table_size ==0 || -sysctl_is_perm_empty_ctl_header (header)) +if (header->ctl_table_size ==0 || dir->permanently_empty)return true;/* Are there links available for every entry in table? */ @@ -1533,6 +1500,33 @@ void unregister_sysctl_table(struct ctl_table_header * header) }EXPORT_SYMBOL (unregister_sysctl_table); +/** +* register_sysctl_mount_point() - registers a sysctl mount point +* @path: path for the mount point +* +* Used to create a permanently empty directory to serve as mount point. +* There are some subtle but important permission checks this allows in the +* case of unprivileged mounts. +*/ +struct ctl_table_header *register_sysctl_mount_point (const char *path) +{ +struct ctl_dir *dir =sysctl_mkdir_p (&sysctl_table_root.default_set.dir, path); + +if (IS_ERR (dir)) +return NULL ; + +guard (spinlock)(&sysctl_lock); + +if (!RB_EMPTY_ROOT (&dir->root)) { +drop_sysctl_table (&dir->header); +return NULL ; + } + + dir->permanently_empty = true; +return &dir->header; +} +EXPORT_SYMBOL (register_sysctl_mount_point); +void setup_sysctl_set (struct ctl_table_set *set,struct ctl_table_root *root,int (*is_seen)(struct ctl_table_set *))include/linux/sysctl.h +2
-11@@ -137,17 +137,6 @@ struct ctl_table {void *data;int maxlen;umode_t mode; -/** -* enum type - Enumeration to differentiate between ctl target types -* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations -* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently -* empty directory target to serve -* as mount point. -*/ -enum { -SYSCTL_TABLE_TYPE_DEFAULT , -SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY - } type;proc_handler *proc_handler;/* Callback for text formatting */ struct ctl_table_poll *poll;void *extra1;@@ -194,6 +183,8 @@ struct ctl_dir {/* Header must be at the start of ctl_dir */ struct ctl_table_header header;struct rb_root root; +/* Permanently empty directory target to serve as mount point. */ +bool permanently_empty; };struct ctl_table_set {Signature · 1 line
2.38.5
Signature · 1 line
Joel Granados
Luis Chamberlain
maintainerQuoted 11 lines · Joel Granados
My idea was to do something similar to your originl RFC, where you have an temporary
proc_handlersomething likeproc_hdlr_const(we would need to work on the name) and move each subsystem to the new handler while the others stay with the non-const one. At the end, the oldproc_handlerfunction name would disapear and would be completely replaced by the newproc_hdlr_const.This is of course extra work and might not be worth it if you don't get negative feedback related to tree-wide changes. Therefore I stick to my previous suggestion. Send the big tree-wide patches and only explore this option if someone screams.
I think we can do better, can't we just increase confidence in that we don't *need* muttable ctl_cables with something like smatch or coccinelle so that we can just make them const?
Seems like a noble endeavor for us to generalize.
Then we just breeze through by first fixing those that *are* using mutable tables by having it just de-register and then re-register new tables if they need to be changed, and then a new series is sent once we fix all those muttable tables.
Luis
Quoted 8 lines · Luis Chamberlain
Quoted 7 lines · Joel Granados
My idea was to do something similar to your originl RFC, where you have an temporary
proc_handlersomething likeproc_hdlr_const(we would need to work on the name) and move each subsystem to the new handler while the others stay with the non-const one. At the end, the oldproc_handlerfunction name would disapear and would be completely replaced by the newproc_hdlr_const.
Quoted 8 lines
Quoted 4 lines
This is of course extra work and might not be worth it if you don't get negative feedback related to tree-wide changes. Therefore I stick to my previous suggestion. Send the big tree-wide patches and only explore this option if someone screams.
I think we can do better, can't we just increase confidence in that we don't *need* muttable
ctl_cableswith something like smatch or coccinelle so that we can just make them const?
The fact that the code compiles should be enough, no? Any funky casting that would trick the compiler to accept it would probably also confuse any other tool.
Quoted 6 lines
Seems like a noble endeavor for us to generalize.
Then we just breeze through by first fixing those that *are* using mutable tables by having it just de-register and then re-register new tables if they need to be changed, and then a new series is sent once we fix all those muttable tables.
Ack. But I think the actual constification should really only be started after the first series for the infrastructure is in.
Thomas
Quoted 14 lines · Thomas Weißschuh
Quoted 13 lines · Luis Chamberlain
Quoted 11 lines · Joel Granados
My idea was to do something similar to your originl RFC, where you have an temporary
proc_handlersomething likeproc_hdlr_const(we would need to work on the name) and move each subsystem to the new handler while the others stay with the non-const one. At the end, the oldproc_handlerfunction name would disapear and would be completely replaced by the newproc_hdlr_const.This is of course extra work and might not be worth it if you don't get negative feedback related to tree-wide changes. Therefore I stick to my previous suggestion. Send the big tree-wide patches and only explore this option if someone screams.
Quoted 7 lines
Quoted 3 lines
I think we can do better, can't we just increase confidence in that we don't *need* muttable
ctl_cableswith something like smatch or coccinelle so that we can just make them const?The fact that the code compiles should be enough, no? Any funky casting that would trick the compiler to accept it would probably also confuse any other tool.
I don't know the context, but the fact that a particular file compiles doesn't mean that all of the lines in the file have been subjected to the compiler, due to ifdefs.
julia
Quoted 13 lines
Quoted 7 lines
Seems like a noble endeavor for us to generalize.
Then we just breeze through by first fixing those that *are* using mutable tables by having it just de-register and then re-register new tables if they need to be changed, and then a new series is sent once we fix all those muttable tables.
Ack. But I think the actual constification should really only be started after the first series for the infrastructure is in.
Thomas
Catching up with mail....
Quoted 13 lines · Luis Chamberlain
Quoted 11 lines · Joel Granados
My idea was to do something similar to your originl RFC, where you have an temporary
proc_handlersomething likeproc_hdlr_const(we would need to work on the name) and move each subsystem to the new handler while the others stay with the non-const one. At the end, the oldproc_handlerfunction name would disapear and would be completely replaced by the newproc_hdlr_const.This is of course extra work and might not be worth it if you don't get negative feedback related to tree-wide changes. Therefore I stick to my previous suggestion. Send the big tree-wide patches and only explore this option if someone screams.
Quoted 8 lines
I think we can do better, can't we just increase confidence in that we don't *need* muttable
ctl_cableswith something like smatch or coccinelle so that we can just make them const?Seems like a noble endeavor for us to generalize.
Then we just breeze through by first fixing those that *are* using mutable tables by having it just de-register and then re-register
So let me see if I understand your {de,re}-register idea:
When we have a situation (like in the networking code) where a ctl_table is being used in an unmuttable way, we do your {de,re}-register trick.
The trick consists in unregistering an old ctl_table and reregistering with a whole new const changed table. In this way, whatever we register is always const.
Once we address all the places where this happens, then we just change the handler to const and we are done.
Is that correct?
If that is indeed what you are proposing, you might not even need the un-register step as all the mutability that I have seen occurs before the register. So maybe instead of re-registering it, you can so a copy (of the changed ctl_table) to a const pointer and then pass that along to the register function.
Can't think of anything else off the top of my head. Would have to actually see the code to evaluate further I think.
Quoted 4 lines
new tables if they need to be changed, and then a new series is sent once we fix all those muttable tables.
Luis
best
Signature · 1 line
Joel Granados
Quoted 20 lines · Joel Granados
Catching up with mail....
Quoted 17 lines · Luis Chamberlain
Quoted 11 lines · Joel Granados
My idea was to do something similar to your originl RFC, where you have an temporary
proc_handlersomething likeproc_hdlr_const(we would need to work on the name) and move each subsystem to the new handler while the others stay with the non-const one. At the end, the oldproc_handlerfunction name would disapear and would be completely replaced by the newproc_hdlr_const.This is of course extra work and might not be worth it if you don't get negative feedback related to tree-wide changes. Therefore I stick to my previous suggestion. Send the big tree-wide patches and only explore this option if someone screams.
I think we can do better, can't we just increase confidence in that we don't *need* muttable
ctl_cableswith something like smatch or coccinelle so that we can just make them const?
Quoted 7 lines
Quoted 4 lines
Seems like a noble endeavor for us to generalize.
Then we just breeze through by first fixing those that *are* using mutable tables by having it just de-register and then re-register
So let me see if I understand your {de,re}-register idea:
When we have a situation (like in the networking code) where actl_tableis being used in an unmuttable way, we do your {de,re}-register trick.
unmuttable?
Quoted 8 lines
The trick consists in unregistering an old
ctl_tableand reregistering with a whole new const changed table. In this way, whatever we register is always const.Once we address all the places where this happens, then we just change the handler to const and we are done.
Is that correct?
I'm confused.
The handlers can already be made const as shown in this series, which does convert the whole kernel tree.
There is only one handler (the stackleak one) which modifies the table and this one is fixed as part of the series.
(Plus the changes needed to the sysctl core to avoid mutation there)
Quoted 5 lines
If that is indeed what you are proposing, you might not even need the un-register step as all the mutability that I have seen occurs before the register. So maybe instead of re-registering it, you can so a copy (of the changed
ctl_table) to a const pointer and then pass that along to the register function.
Tables that are modified, but *not* through the handler, would crop during the constification of the table structs.
Which should be a second step.
But Luis' message was not completely clear to me.
I guess I'm missing something.
Quoted 5 lines
Can't think of anything else off the top of my head. Would have to actually see the code to evaluate further I think.
Quoted 2 lines
new tables if they need to be changed, and then a new series is sent once we fix all those muttable tables.
Thomas
Luis Chamberlain
maintainerSo we can split this up concentually in two:
* constificaiton of the table handlers
* constification of the table struct itself
Quoted 1 line · Thomas Weißschuh
The handlers can already be made const as shown in this series,
The series did already produce issues with some builds, and so Julia's point is confirmed that the series only proves hanlders which you did build and for which 0-day has coverage for.
The challenge here was to see if we could draw up a test case that would prove this without build tests, and what occurred to me was coccinelle or smatch.
Quoted 9 lines
Quoted 5 lines
If that is indeed what you are proposing, you might not even need the un-register step as all the mutability that I have seen occurs before the register. So maybe instead of re-registering it, you can so a copy (of the changed
ctl_table) to a const pointer and then pass that along to the register function.Tables that are modified, but *not* through the handler, would crop during the constification of the table structs.
Which should be a second step.
Instead of "croping up" at build time again, I wonder if we can do better with coccinelle / smatch.
Joel, and yes, what you described is what I was suggesting, that is to avoid having to add a non-const handler a first step, instead we modify those callers which do require to modify the table by first a deregistration and later a registration. In fact to make this even easier a new call would be nice so to aslo be able to git grep when this is done in the kernel.
But if what you suggest is true that there are no registrations which later modify the table, we don't need that. It is the uncertainty that we might have that this is a true statment that I wanted to challenge to see if we could do better. Can we avoid this being a stupid regression later by doing code analysis with coccinelle / smatch?
The template of the above endeavor seems useful not only to this use case but to any place in the kernel where this previously has been done before, and hence my suggestion that this seems like a sensible thing to think over to see if we could generalize.
Luis
Hi Luis and Julia,
(Julia, there is a question and context for you inline, marked with your name)
Quoted 8 lines · Luis Chamberlain
So we can split this up concentually in two:
* constificaiton of the table handlers
* constification of the table struct itselfQuoted 1 line · Thomas Weißschuh
The handlers can already be made const as shown in this series,
Quoted 7 lines
The series did already produce issues with some builds, and so Julia's point is confirmed that the series only proves hanlders which you did build and for which 0-day has coverage for.
The challenge here was to see if we could draw up a test case that would prove this without build tests, and what occurred to me was coccinelle or smatch.
I used the following coccinelle script to find more handlers that I missed before:
virtual patch
virtual context
virtual report
@@
identifier func;
identifier ctl;
identifier write;
identifier buffer;
identifier lenp;
identifier ppos;
type loff_t;
@@
int func(
- struct ctl_table *ctl,
+ const struct ctl_table *ctl,
int write, void *buffer, size_t *lenp, loff_t *ppos) { ... }
It did not find any additional occurrences while it was able to match the existing changes.
After that I manually reviewed all handlers that they are not modifying their table argument, which they don't.
Should we do more?
For Julia:
Maybe you could advise on how to use coccinelle to find where a const function argument or one of its members are modified directly or passed to some other function as non-const arguments.
See the coccinelle patch above.
Is this possible?
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
If that is indeed what you are proposing, you might not even need the un-register step as all the mutability that I have seen occurs before the register. So maybe instead of re-registering it, you can so a copy (of the changed
ctl_table) to a const pointer and then pass that along to the register function.
Quoted 6 lines
Quoted 3 lines
Tables that are modified, but *not* through the handler, would crop during the constification of the table structs.
Which should be a second step.Instead of "croping up" at build time again, I wonder if we can do better with coccinelle / smatch.
As for smatch:
Doesn't smatch itself run as part of a normal build [0]? So it would have the same visibility issues as the compiler itself.
Quoted 13 lines
Joel, and yes, what you described is what I was suggesting, that is to avoid having to add a non-const handler a first step, instead we modify those callers which do require to modify the table by first a deregistration and later a registration. In fact to make this even easier a new call would be nice so to aslo be able to git grep when this is done in the kernel.
But if what you suggest is true that there are no registrations which later modify the table, we don't need that. It is the uncertainty that we might have that this is a true statment that I wanted to challenge to see if we could do better. Can we avoid this being a stupid regression later by doing code analysis with coccinelle / smatch?
Quoted 4 lines
The template of the above endeavor seems useful not only to this use case but to any place in the kernel where this previously has been done before, and hence my suggestion that this seems like a sensible thing to think over to see if we could generalize.
I'd like to split the series and submit the part up until and including the constification of arguments first and on its own.
It keeps the subsystem maintainers out of the discussion of the core sysctl changes.
I'll submit the core sysctl changes after I figure out proper responses to all review comments and we can do this in parallel to the tree-wide preparation.
What do you think Luis and Joel?
[0] https://repo.or.cz/smatch.git/blob/HEAD:/smatch_scripts/test_kernel.sh
Quoted 52 lines · Thomas Weißschuh
Hi Luis and Julia,
(Julia, there is a question and context for you inline, marked with your name)
Quoted 8 lines · Luis Chamberlain
So we can split this up concentually in two:
* constificaiton of the table handlers
* constification of the table struct itselfQuoted 1 line · Thomas Weißschuh
The handlers can already be made const as shown in this series,
Quoted 7 lines
The series did already produce issues with some builds, and so Julia's point is confirmed that the series only proves hanlders which you did build and for which 0-day has coverage for.
The challenge here was to see if we could draw up a test case that would prove this without build tests, and what occurred to me was coccinelle or smatch.
I used the following coccinelle script to find more handlers that I missed before:
virtual patch
virtual context
virtual report@@
identifier func;
identifier ctl;
identifier write;
identifier buffer;
identifier lenp;
identifier ppos;
typeloff_t;
@@int func(
- structctl_table*ctl,
+ const structctl_table*ctl,
int write, void *buffer,size_t*lenp,loff_t*ppos) { ... }It did not find any additional occurrences while it was able to match the existing changes.
After that I manually reviewed all handlers that they are not modifying their table argument, which they don't.
Should we do more?
Quoted 8 lines
For Julia:
Maybe you could advise on how to use coccinelle to find where a const function argument or one of its members are modified directly or passed to some other function as non-const arguments.
See the coccinelle patch above.Is this possible?
I will propose something.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
If that is indeed what you are proposing, you might not even need the un-register step as all the mutability that I have seen occurs before the register. So maybe instead of re-registering it, you can so a copy (of the changed
ctl_table) to a const pointer and then pass that along to the register function.Tables that are modified, but *not* through the handler, would crop during the constification of the table structs.
Which should be a second step.
Quoted 7 lines
Quoted 2 lines
Instead of "croping up" at build time again, I wonder if we can do better with coccinelle / smatch.
As for smatch:
Doesn't smatch itself run as part of a normal build [0]? So it would have the same visibility issues as the compiler itself.
I also believe that this is the case.
julia
Quoted 31 lines
Quoted 13 lines
Joel, and yes, what you described is what I was suggesting, that is to avoid having to add a non-const handler a first step, instead we modify those callers which do require to modify the table by first a deregistration and later a registration. In fact to make this even easier a new call would be nice so to aslo be able to git grep when this is done in the kernel.
But if what you suggest is true that there are no registrations which later modify the table, we don't need that. It is the uncertainty that we might have that this is a true statment that I wanted to challenge to see if we could do better. Can we avoid this being a stupid regression later by doing code analysis with coccinelle / smatch?
Quoted 4 lines
The template of the above endeavor seems useful not only to this use case but to any place in the kernel where this previously has been done before, and hence my suggestion that this seems like a sensible thing to think over to see if we could generalize.
I'd like to split the series and submit the part up until and including the constification of arguments first and on its own.
It keeps the subsystem maintainers out of the discussion of the core sysctl changes.I'll submit the core sysctl changes after I figure out proper responses to all review comments and we can do this in parallel to the tree-wide preparation.
What do you think Luis and Joel?
[0] https://repo.or.cz/smatch.git/blob/HEAD:/smatch_scripts/test_kernel.sh
Luis Chamberlain
maintainerQuoted 18 lines · Thomas Weißschuh
I used the following coccinelle script to find more handlers that I missed before:
virtual patch
virtual context
virtual report@@
identifier func;
identifier ctl;
identifier write;
identifier buffer;
identifier lenp;
identifier ppos;
typeloff_t;
@@
Quoted 4 lines
int func(
- structctl_table*ctl,
+ const structctl_table*ctl,
int write, void *buffer,size_t*lenp,loff_t*ppos) { ... }
I think it would be useful to describe that the reason why you have the parameters in places as required is you want to limit the scope to the sysctl handler routines only, and these have these fixed arguments.
make coccicheck MODE=patch COCCI=sysctl-const.cocci SPFLAGS="--in-place" > /dev/null git diff --stat | tail -1
80 files changed, 390 insertions(+), 306 deletions(-)
git diff --stat | sha1sum
ec90851ba02dad069b11822782c74665a01142db -
Quoted 2 lines
It did not find any additional occurrences while it was able to match the existing changes.
Fantastic, then please use and include the coccinelle rule to express that this is the goal, it is easier to review *one* cocinelle rule with intent rather than tons of changes.
Quoted 4 lines
After that I manually reviewed all handlers that they are not modifying their table argument, which they don't.
Should we do more?
Now that we started to think about *what* is the goal, and trying to break it down it is easier to think about the ramifications of what we need checked and how tools can help.
We break down the first goal into a simple grammatical expression listed above, we want to constify the proc hanlders use of the struct ctl_table.
Given this, I think that for the first part the coccinelle grammar above should take care of the cases where the compiler would not have caught a few builds where your config was not testing the compiler build. Now could this still allow
ctl->foo = bar ?
I think so, so here is a simple sysctl-const-mod.cocci which can be used in coccicheck patch mode as well instead of coccicheck context mode as the context mode just produces a removal visually, and I prefer to see the removals with git diff instead due to color syntax highlighting:
make coccicheck MODE=patch COCCI=sysctl-const-mod.cocci SPFLAGS="--in-place" > /dev/null virtual patch
@ r1 @
identifier func;
identifier ctl;
identifier write;
identifier buffer;
identifier lenp;
identifier ppos;
type loff_t;
@@
int func(
struct ctl_table *ctl,
int write, void *buffer, size_t *lenp, loff_t *ppos)
{ ... }
@ r2 depends on r1 @
struct ctl_table *ctl;
expression E1, E2;
@@
(
- ctl->extra1 = E1;
|
- ctl->extra2 = E1;
)
The git diff --stat:
arch/arm64/kernel/armv8_deprecated.c | 2 -- drivers/net/vrf.c | 3 --- net/ipv4/devinet.c | 2 -- net/ipv4/route.c | 1 - net/ipv6/addrconf.c | 2 -- net/ipv6/route.c | 1 - net/mpls/af_mpls.c | 2 -- net/netfilter/ipvs/ip_vs_ctl.c | 6 +----- net/netfilter/nf_log.c | 2 +- net/sctp/sysctl.c | 5 ----- 10 files changed, 2 insertions(+), 24 deletions(-)
So that needs review. And the OR could be expanded with more components of the struct ctl_table
As I noted, I think this is a generically neat endeavor and so I think it would be nice to shorthand *any* member of the struct. ctl->any. Julia, is that possible?
The depends on is rather loose so I *think* this means the second rule should only apply the rule on files which define handler. But that second rule could perhaps be made as a long term generic goal without the first rule.
I first tried to attach the modification of the ctl table to the routine itself with so only the caller is modified:
virtual patch
@ r1 @
identifier func;
struct ctl_table *ctl;
identifier write;
identifier buffer;
identifier lenp;
identifier ppos;
type loff_t;
@@
int func(
struct ctl_table *ctl,
int write, void *buffer, size_t *lenp, loff_t *ppos)
{ ... }
@ r2 depends on r1 @
r1.ctl;
expression E1, E2;
@@
(
- ctl->extra1 = E1;
|
- ctl->extra2 = E1;
)
But that didn't work.
Quoted 7 lines
Quoted 4 lines
The template of the above endeavor seems useful not only to this use case but to any place in the kernel where this previously has been done before, and hence my suggestion that this seems like a sensible thing to think over to see if we could generalize.
I'd like to split the series and submit the part up until and including the constification of arguments first and on its own.
The first part is the proc handlers.
If after that you generalize when its used in any routine as this:
virtual patch
@@
identifier func;
identifier ctl;
@@
int func(...,
- struct ctl_table *ctl,
+ const struct ctl_table *ctl,
...) { ... }
You increase the required changes and scope. This does not handle the case where two different tables are in the same routine arguments, but that is a special case and could be hanlded through its own rule.
Quoted 2 lines
It keeps the subsystem maintainers out of the discussion of the core sysctl changes.
We'll need to involve subsystem maintainers eventually to deal with special cases which don't fit the goal we want to normalize to. I suggest you think about the changes in grammatical expressions, leading up to the final gaol, where we could do a full sweep and ensure no struct ctl_table is not const.
That is, as you work your way up to the goal, I suspect you may need to modify a few loose drivers / components which may need special handling so that we could normalize on the intended grammatical requirements. Just as with the ctrl work Joel did -- a few drives needed to be modified so that the long term goal for the sentinel could be applied.
I don't think time is wasted in formalizing this endeavor as it is a generic goal we tend to see. We're breaking this down then into a few goals, leaps:
1) Start off with a few key special routines which deal with the data structure we want to constify, so we create grammar rules which modify the expected function data types with the one we are intersted in with const. The value in this is that Coccinelle will find changes we need outside of the scope of our build.
2) Those routines then need checks to ensure that no variable is modified, so we need a scaper first to report these so we can inspect the routine and change it so that the grammar rule in
1) works without any expected compile failure.
3) Loosten the search to any routine that uses the struct we want to constify and address cases where the struct is used more than once in a routine.
4) Ensure globally we don't modify the struct as done in the report
on goal 1).
5) Constify the struct
Luis
Quoted 3 lines
As I noted, I think this is a generically neat endeavor and so I think it would be nice to shorthand *any* member of the struct.
ctl->any. Julia, is that possible?
What do you mean by *any* member? If any is an identifier typed metavariable then that would get any immediate member. But maybe you want something like
<+...ctl->any...+>
that will match anything that has ctl->any as a subexpression?
It may be necessary to put this in parentheses to address parsing issues, but the () won't need to be present in the matched code.
You could also use
assignment operator aop;
rather than =, to also match += etc.
julia
Luis Chamberlain
maintainerQuoted 5 lines · Julia Lawall
Quoted 3 lines
As I noted, I think this is a generically neat endeavor and so I think it would be nice to shorthand *any* member of the struct.
ctl->any. Julia, is that possible?What do you mean by *any* member?
I meant when any code tries to assign a new variable to any of the members of the struct ctl_table *foo, so any foo->*any*
Quoted 7 lines
If any is an identifier typed
metavariable then that would get any immediate member. But maybe you want something like<+...ctl->any...+>
that will match anything that has
ctl->anyas a subexpression?
If as just an expression, then no, we really want this to be tied to the data struture in question we want to modify.
Luis
Quoted 9 lines · Luis Chamberlain
Quoted 5 lines · Julia Lawall
Quoted 3 lines
As I noted, I think this is a generically neat endeavor and so I think it would be nice to shorthand *any* member of the struct.
ctl->any. Julia, is that possible?What do you mean by *any* member?
I meant when any code tries to assign a new variable to any of the members of the struct
ctl_table*foo, so any foo->*any*
Declaring any to be an identifier metavariable would be sufficient.
Quoted 11 lines
Quoted 8 lines
If any is an identifier typed
metavariable then that would get any immediate member. But maybe you want something like<+...ctl->any...+>
that will match anything that has
ctl->anyas a subexpression?If as just an expression, then no, we really want this to be tied to the data struture in question we want to modify.
What about foo->a.b? Or maybe that doesn't occur in your structure?
julia
Luis Chamberlain
maintainerQuoted 9 lines · Julia Lawall
Quoted 5 lines · Luis Chamberlain
Quoted 4 lines · Julia Lawall
Quoted 3 lines
As I noted, I think this is a generically neat endeavor and so I think it would be nice to shorthand *any* member of the struct.
ctl->any. Julia, is that possible?
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
What do you mean by *any* member?
I meant when any code tries to assign a new variable to any of the members of the struct
ctl_table*foo, so any foo->*any*Declaring any to be an identifier metavariable would be sufficient.
Fantastic thanks!
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
If any is an identifier typed
metavariable then that would get any immediate member. But maybe you want something like
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
<+...ctl->any...+>
that will match anything that has
ctl->anyas a subexpression?If as just an expression, then no, we really want this to be tied to the data struture in question we want to modify.
What about
foo->a.b? Or maybe that doesn't occur in your structure?
We'll consider that too, good idea!
Luis
I came up with the following:
@@
type t;
const t *x;
identifier y,z;
expression a;
assignment operator aop;
@@
(
(<+...(<+...x->y...+>)[...]...+>) aop a
|
(<+...(<+...x->y...+>)->z...+>) aop a
|
* (<+...x->y...+>) aop a
)
@fn disable optional_qualifier@
identifier f,x;
type t;
parameter list[n] ps;
@@
f(ps,t *x,...) { ... }
@@
identifier fn.f;
expression list[fn.n] es;
type t;
const t *e;
@@
*f(es,e,...)
---------------
The first rule takes care of assignments, while the remaining rules check function calls.
This is not extensively tested and has false positives. One case is when you have a->b[x->y] = 12; and it is x not a that is const. Maybe I can improve it to avoid this problem.
I would suggest to replace the occurrences of t by your specific type of interest (and then drop the occurrences type t;), to reduce the amount of work to be done and the chance of false positives.
This is also limited in that it only works on a single file. Thus in particular the last rule on function calls will only be triggered when the called function is defined in the same file.
Despite the current limitations, maybe it will find something useful.
julia
Quoted 9 lines · Thomas Weißschuh
Hi Luis and Julia,
(Julia, there is a question and context for you inline, marked with your name)
Quoted 4 lines · Luis Chamberlain
So we can split this up concentually in two:
* constificaiton of the table handlers
* constification of the table struct itself
<--- snip --->
Quoted 8 lines
Quoted 3 lines
case but to any place in the kernel where this previously has been done before, and hence my suggestion that this seems like a sensible thing to think over to see if we could generalize.
I'd like to split the series and submit the part up until and including the constification of arguments first and on its own.
It keeps the subsystem maintainers out of the discussion of the core sysctl changes.
quick comment : Note that if this contains the tree-wide patches, it will inevitably bring in the rest of the maintainers.
Quoted 6 lines
I'll submit the core sysctl changes after I figure out proper responses to all review comments and we can do this in parallel to the tree-wide preparation.
What do you think Luis and Joel?
Separating all this into patch series that have a defined motivation and that are self contained is the way to go IMO.
Best
Signature · 1 line
Joel Granados
Quoted 36 lines · Luis Chamberlain
So we can split this up concentually in two:
* constificaiton of the table handlers
* constification of the table struct itselfQuoted 1 line · Thomas Weißschuh
The handlers can already be made const as shown in this series,
The series did already produce issues with some builds, and so Julia's point is confirmed that the series only proves hanlders which you did build and for which 0-day has coverage for.
The challenge here was to see if we could draw up a test case that would prove this without build tests, and what occurred to me was coccinelle or smatch.
Quoted 9 lines
Quoted 5 lines
If that is indeed what you are proposing, you might not even need the un-register step as all the mutability that I have seen occurs before the register. So maybe instead of re-registering it, you can so a copy (of the changed
ctl_table) to a const pointer and then pass that along to the register function.Tables that are modified, but *not* through the handler, would crop during the constification of the table structs.
Which should be a second step.Instead of "croping up" at build time again, I wonder if we can do better with coccinelle / smatch.
Joel, and yes, what you described is what I was suggesting, that is to avoid having to add a non-const handler a first step, instead we modify those callers which do require to modify the table by first a deregistration and later a registration. In fact to make this even easier a new call would be nice so to aslo be able to git grep when this is done in the kernel.
Quoted 5 lines
But if what you suggest is true that there are no registrations which later modify the table, we don't need that. It is the uncertainty that we might have that this is a true statment that I wanted to challenge to see if we could do better. Can we avoid this being a stupid regression later by doing code analysis with coccinelle / smatch?
That would be amazing! Having an analysis (coccinelle or smatch) that prevents the regression would be the cherry on top.
So to further clarify: what you propose is an additional patch in the series that adds this regression prevention.
Or do you want a general analysis that prevents changing a variable variable that was defined as const.
Quoted 5 lines
The template of the above endeavor seems useful not only to this use case but to any place in the kernel where this previously has been done before, and hence my suggestion that this seems like a sensible thing to think over to see if we could generalize.
A generalized analysis for inadvertent de-constification would be great. It would point to places where we need remove the const qualifier or add it.
Quoted 2 lines
Luis
Signature · 1 line
Joel Granados
Quoted 23 lines · Thomas Weißschuh
Quoted 22 lines · Joel Granados
Catching up with mail....
Quoted 19 lines · Luis Chamberlain
Quoted 11 lines · Joel Granados
My idea was to do something similar to your originl RFC, where you have an temporary
proc_handlersomething likeproc_hdlr_const(we would need to work on the name) and move each subsystem to the new handler while the others stay with the non-const one. At the end, the oldproc_handlerfunction name would disapear and would be completely replaced by the newproc_hdlr_const.This is of course extra work and might not be worth it if you don't get negative feedback related to tree-wide changes. Therefore I stick to my previous suggestion. Send the big tree-wide patches and only explore this option if someone screams.
I think we can do better, can't we just increase confidence in that we don't *need* muttable
ctl_cableswith something like smatch or coccinelle so that we can just make them const?Seems like a noble endeavor for us to generalize.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Then we just breeze through by first fixing those that *are* using mutable tables by having it just de-register and then re-register
So let me see if I understand your {de,re}-register idea:
When we have a situation (like in the networking code) where actl_tableis being used in an unmuttable way, we do your {de,re}-register trick.unmuttable?
meant muttable here.
Quoted 39 lines
Quoted 9 lines
The trick consists in unregistering an old
ctl_tableand reregistering with a whole new const changed table. In this way, whatever we register is always const.Once we address all the places where this happens, then we just change the handler to const and we are done.
Is that correct?
I'm confused.
The handlers can already be made const as shown in this series, which does convert the whole kernel tree.
There is only one handler (the stackleak one) which modifies the table and this one is fixed as part of the series.(Plus the changes needed to the sysctl core to avoid mutation there)
Quoted 5 lines
If that is indeed what you are proposing, you might not even need the un-register step as all the mutability that I have seen occurs before the register. So maybe instead of re-registering it, you can so a copy (of the changed
ctl_table) to a const pointer and then pass that along to the register function.Tables that are modified, but *not* through the handler, would crop during the constification of the table structs.
Which should be a second step.But Luis' message was not completely clear to me.
I guess I'm missing something.Quoted 5 lines
Can't think of anything else off the top of my head. Would have to actually see the code to evaluate further I think.
Quoted 2 lines
new tables if they need to be changed, and then a new series is sent once we fix all those muttable tables.
Thomas
Signature · 1 line
Joel Granados
Luis Chamberlain
maintainerQuoted 5 lines · Thomas Weißschuh
Before sending it I'd like to get feedback on the internal rework of the
is_emptydetection from you and/or Luis.https://git.sr.ht/~t-8ch/linux/commit/ea27507070f3c47be6febebe451bbb88f6ea707e
or the attached patch.
Please send as a new patch as RFC and please ensure on the To field is first "Eric W. Biederman" <[email protected]> with a bit more elaborate commit log as suggested from my review below. If there are any hidden things me and Joel could probably miss I'm sure Eric will be easily able to spot it.
Quoted 8 lines
From
ea27507070f3c47be6febebe451bbb88f6ea707eMon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <[email protected]>
Date: Sun, 3 Dec 2023 21:56:46 +0100
Subject: [PATCH] sysctl: move permanently empty flag toctl_dir
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Quoted 7 lines
Simplify the logic by always keeping the
permanently_emptyflag on thectl_dir.
The previous logic kept the flag in the leafctl_tableand from there transferred it to thectl_tablefrom the directory.This also removes the need to have a mutable
ctl_tableand will allow the constification of those structs.
Please elaborate a bit more on this here in your next RFC.
Quoted 100 lines
Signed-off-by Thomas Weißschuh <[email protected]>--- fs/proc/proc_sysctl.c | 74 +++++++++++++++++++----------------------- include/linux/sysctl.h | 13 ++------ 2 files changed, 36 insertions(+), 51 deletions(-)fs/proc/proc_sysctl.c +1
-0@@ -17,6 +17,7 @@#include <linux/bpf-cgroup.h> #include <linux/mount.h> #include <linux/kmemleak.h> +#include <linux/cleanup.h> #include "internal.h" #define
list_for_each_table_entry(entry, header)\fs/proc/proc_sysctl.c +5
-38@@ -29,32 +30,6 @@ static const struct inode_operations proc_sys_inode_operations;static const struct file_operations proc_sys_dir_file_operations;static const struct inode_operations proc_sys_dir_operations; -/* Support for permanently empty directories */ -static struct ctl_table sysctl_mount_point[] = { - {.type =SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY } -}; - -/** -* register_sysctl_mount_point() - registers a sysctl mount point -* @path: path for the mount point -* -* Used to create a permanently empty directory to serve as mount point. -* There are some subtle but important permission checks this allows in the -* case of unprivileged mounts. -*/ -struct ctl_table_header *register_sysctl_mount_point (const char *path) -{ -return register_sysctl (path, sysctl_mount_point); -} -EXPORT_SYMBOL (register_sysctl_mount_point); - -#define sysctl_is_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_set_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) -#define sysctl_clear_perm_empty_ctl_header (hptr) \ - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_DEFAULT) -void proc_sys_poll_notify (struct ctl_table_poll *poll) {if (!poll)@@ -226,17 +201,9 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)/* Is this a permanently empty directory? */ -if (sysctl_is_perm_empty_ctl_header (dir_h)) +if (dir->permanently_empty)return -EROFS ; -/* Am I creating a permanently empty directory? */ -if (header->ctl_table_size >0 && -sysctl_is_perm_empty_ctl_header (header)) { -if (!RB_EMPTY_ROOT (&dir->root)) -return -EINVAL ; -sysctl_set_perm_empty_ctl_header (dir_h); - } - dir_h->nreg++; header->parent = dir; err =insert_links (header);@@ -252,8 +219,6 @@ fail:erase_header (header);put_links (header); fail_links: -if (header->ctl_table == sysctl_mount_point) -sysctl_clear_perm_empty_ctl_header (dir_h); header->parent =NULL ;drop_sysctl_table (dir_h);return err;@@ -440,6 +405,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, struct ctl_table_header *head, struct ctl_table *table) { struct ctl_table_root *root = head->root; +struct ctl_dir *ctl_dir;struct inode *inode;struct proc_inode *ei;@@ -473,7 +439,9 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, inode->i_mode |=S_IFDIR ; inode->i_op = &proc_sys_dir_operations; inode->i_fop = &proc_sys_dir_file_operations; -if (sysctl_is_perm_empty_ctl_header (head)) + + ctl_dir = container_of(head, struct ctl_dir, header); +if (ctl_dir->permanently_empty)make_empty_dir_inode (inode); }
fs/proc/proc_sysctl.c static bool get_links(struct ctl_dir *dir, · line 1183
Quoted 7 lines
fs/proc/proc_sysctl.c +1
-2@@ -1211,8 +1179,7 @@ static bool get_links(struct ctl_dir *dir,struct ctl_table_header *tmp_head;struct ctl_table *entry, *link; -if (header->ctl_table_size ==0 || -sysctl_is_perm_empty_ctl_header (header)) +if (header->ctl_table_size ==0 || dir->permanently_empty)return true;
Why are we now checking the target directory whereas before it was the header?
Quoted 6 lines
fs/proc/proc_sysctl.c +1
-0/* Are there links available for every entry in table? */ @@ -1533,6 +1500,33 @@ void unregister_sysctl_table(struct ctl_table_header * header) }EXPORT_SYMBOL (unregister_sysctl_table); +/**
fs/proc/proc_sysctl.c void unregister_sysctl_table(struct ctl_table_header * header) · line 1513
Quoted 10 lines
fs/proc/proc_sysctl.c +10
-0+* register_sysctl_mount_point() - registers a sysctl mount point +* @path: path for the mount point +* +* Used to create a permanently empty directory to serve as mount point. +* There are some subtle but important permission checks this allows in the +* case of unprivileged mounts. +*/ +struct ctl_table_header *register_sysctl_mount_point (const char *path) +{ +struct ctl_dir *dir =sysctl_mkdir_p (&sysctl_table_root.default_set.dir, path);
Even though __register_sysctl_table() did more than we needed it is not obvious how the sysctl_table_root.default_set.dir.header.nreg++ is not needed but I see get_subdir() also bumps it as it is called from sysctl_mkdir_p(), so we were already bumping it at least once. I suppose that is safe.
Wouldn't we be able to re-register the same sysctl mount point more than once with this though?
fs/proc/proc_sysctl.c void unregister_sysctl_table(struct ctl_table_header * header) · line 1518
Quoted 5 lines
fs/proc/proc_sysctl.c +5
-0+ +if (IS_ERR (dir)) +return NULL ; + +guard (spinlock)(&sysctl_lock);
For those that did not get the memo (I guess the docs could be improved):
fs/proc/proc_sysctl.c void unregister_sysctl_table(struct ctl_table_header * header) · line 1523
Quoted 5 lines
fs/proc/proc_sysctl.c +5
-0+ +if (!RB_EMPTY_ROOT (&dir->root)) { +drop_sysctl_table (&dir->header); +return NULL ; + }
This seems to silently allow races in that the above allows an existing sysctl mount point to already exist and here we bail on an assumption we know we can't have.
Quoted 32 lines
fs/proc/proc_sysctl.c +6
-0+ + dir->permanently_empty = true; +return &dir->header; +} +EXPORT_SYMBOL (register_sysctl_mount_point); +void setup_sysctl_set (struct ctl_table_set *set,struct ctl_table_root *root,int (*is_seen)(struct ctl_table_set *))include/linux/sysctl.h +0
-11@@ -137,17 +137,6 @@ struct ctl_table {void *data;int maxlen;umode_t mode; -/** -* enum type - Enumeration to differentiate between ctl target types -* @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations -* @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently -* empty directory target to serve -* as mount point. -*/ -enum { -SYSCTL_TABLE_TYPE_DEFAULT , -SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY - } type;proc_handler *proc_handler;/* Callback for text formatting */ struct ctl_table_poll *poll;void *extra1;
include/linux/sysctl.h struct ctl_dir { · line 190
Quoted 8 lines
include/linux/sysctl.h +2
-0@@ -194,6 +183,8 @@ struct ctl_dir {/* Header must be at the start of ctl_dir */ struct ctl_table_header header;struct rb_root root; +/* Permanently empty directory target to serve as mount point. */ +bool permanently_empty; };struct ctl_table_set {
It's a pretty aggressive cleanup, specially with the new hipster guard() call but I'd love Eric's eyeballs on a proper v2.
Luis
Quoted 26 lines · Luis Chamberlain
Quoted 5 lines · Thomas Weißschuh
Before sending it I'd like to get feedback on the internal rework of the
is_emptydetection from you and/or Luis.https://git.sr.ht/~t-8ch/linux/commit/ea27507070f3c47be6febebe451bbb88f6ea707e
or the attached patch.Please send as a new patch as RFC and please ensure on the To field is first "Eric W. Biederman" <[email protected]> with a bit more elaborate commit log as suggested from my review below. If there are any hidden things me and Joel could probably miss I'm sure Eric will be easily able to spot it.
Quoted 13 lines
From
ea27507070f3c47be6febebe451bbb88f6ea707eMon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <[email protected]>
Date: Sun, 3 Dec 2023 21:56:46 +0100
Subject: [PATCH] sysctl: move permanently empty flag toctl_dir
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitSimplify the logic by always keeping the
permanently_emptyflag on thectl_dir.
The previous logic kept the flag in the leafctl_tableand from there transferred it to thectl_tablefrom the directory.
Quoted 7 lines
Quoted 2 lines
This also removes the need to have a mutable
ctl_tableand will allow the constification of those structs.Please elaborate a bit more on this here in your next RFC.
It's a pretty aggressive cleanup, specially with the new hipster
guard()call but I'd love Eric's eyeballs on a proper v2.
I will look at a v2 time permitting.
My sense is that changing the locking probably make sense as a separate patch.
Eric