Skip to content

Commit

Permalink
Merge tag 'constfy-sysctl-6.11-rc1' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/sysctl/sysctl

Pull sysctl constification from Joel Granados:
 "Treewide constification of the ctl_table argument of proc_handlers
  using a coccinelle script and some manual code formatting fixups.

  This is a prerequisite to moving the static ctl_table structs into
  read-only data section which will ensure that proc_handler function
  pointers cannot be modified"

* tag 'constfy-sysctl-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl:
  sysctl: treewide: constify the ctl_table argument of proc_handlers
  • Loading branch information
torvalds committed Jul 25, 2024
2 parents bba959f + 78eb4ea commit b485625
Show file tree
Hide file tree
Showing 93 changed files with 258 additions and 258 deletions.
2 changes: 1 addition & 1 deletion arch/arm64/kernel/armv8_deprecated.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,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)
{
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/kernel/fpsimd.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,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;
Expand Down
10 changes: 5 additions & 5 deletions arch/s390/appldata/appldata_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -262,7 +262,7 @@ appldata_interval_handler(struct ctl_table *ctl, int write,
* monitoring (0 = not in process, 1 = in process)
*/
static int
appldata_generic_handler(struct ctl_table *ctl, int write,
appldata_generic_handler(const struct ctl_table *ctl, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
struct appldata_ops *ops = NULL, *tmp_ops;
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/kernel/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/kernel/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,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();
Expand Down
6 changes: 3 additions & 3 deletions arch/s390/mm/cmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)
{
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/itmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/cdrom/cdrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,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;
Expand Down Expand Up @@ -1651,7 +1651,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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/mac_hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/vrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,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;
Expand Down
12 changes: 6 additions & 6 deletions drivers/parport/procfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/perf/arm_pmuv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ static void armv8pmu_disable_user_access_ipi(void *unused)
armv8pmu_disable_user_access();
}

static int armv8pmu_proc_user_access_handler(struct ctl_table *table, int write,
static int armv8pmu_proc_user_access_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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/perf/riscv_pmu_sbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ static void riscv_pmu_update_counter_access(void *info)
csr_write(CSR_SCOUNTEREN, 0x2);
}

static int riscv_pmu_proc_user_access_handler(struct ctl_table *table,
static int riscv_pmu_proc_user_access_handler(const struct ctl_table *table,
int write, void *buffer,
size_t *lenp, loff_t *ppos)
{
Expand Down
2 changes: 1 addition & 1 deletion fs/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,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);
Expand Down
2 changes: 1 addition & 1 deletion fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ 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,
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();
Expand Down
2 changes: 1 addition & 1 deletion fs/drop_caches.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,7 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd,

#ifdef CONFIG_SYSCTL

static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
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);
Expand Down
2 changes: 1 addition & 1 deletion fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,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();
Expand Down
2 changes: 1 addition & 1 deletion fs/fs-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -2413,7 +2413,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;
Expand Down
2 changes: 1 addition & 1 deletion fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ 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,
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();
Expand Down
2 changes: 1 addition & 1 deletion fs/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,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,
Expand Down
2 changes: 1 addition & 1 deletion fs/quota/dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,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;
Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/xfs_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,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! */
Expand Down Expand Up @@ -1175,7 +1175,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 */
Expand Down
8 changes: 4 additions & 4 deletions include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,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)
Expand Down Expand Up @@ -3854,7 +3854,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

Expand Down
Loading

0 comments on commit b485625

Please sign in to comment.